PDA

View Full Version : Video Game Concepts Vol. 2 - Gravity


x2495iiii
08-04-2009, 02:49 AM
Though the first video game concept I wrote only got three votes, they were all requests to see more, so here's another one: gravity.

Background: I've seen plenty of platformer-type games which have tried to deal with the issue of gravity and falling characters. The big issue seems to be animating the fall back to the ground to be both realistic and functional.

Explanation: Gravity is a part of the game's physics which forces all objects in the game to move toward the ground (or a platform) at all times. If the object is in contact with the ground, movement stops, but the force remains present should the object move away from the ground (i. e. jumping).

Example: Three objects in the world immediately fall to the ground upon clicking the play button. Pressing the space bar will cause the penguin to jump, and holding the shift key while clicknig and dragging any of the objects will allow you to move any of the objects above the ground. After the mouse is released, the object will fall to the ground once again.

Key Ideas: In my opinion, this is a very solid way to render gravity with Alice. It may not be foolproof and would require extra coding (lots of if/else if statements) if platforms were included, but it does keep an omnipresent force acting on each of the objects which stops once the objects come into contact with the ground (although for some reason, the penguin's feet will sometimes get a little buried).

Application: This method isn't especially large, using only one infinite loop (while the world is running) and a corresponding object list. It could easily be used in many games, though the addition of many objects to the list may cause problems (not likely, however, as I've worked with lists over 1,000 items long.)

Veryuhbull
08-04-2009, 11:34 AM
Very well done.:) It's not real physics, but that's not the point here. This is all one really needs to simulate gravity.

PS
I messed it up by moving the ground down then back over their heads.

x2495iiii
08-04-2009, 11:46 AM
Ah yes. That can be fixed by making the ground a "notFirstClass" object. To do that, click on the ground, then click the properties tab on the left, then go to the seldom used properties near the bottom, then change the "isFirstClass" boolean property to false. This makes the ground impossible to click on and should make it so that it can't be moved by the mouse.

onij
08-17-2009, 05:21 PM
I've got to be missing something. The duration on the fall is 0 seconds, yet it takes about a second for each object to fall.
When I set the duration to something like 1 second, it take almost a minute for the object to fall.... I've looked through your 2 methods and 2 variables... what am I missing....

Why does it take so long for them to fall with a 0 second duration?

x2495iiii
08-20-2009, 01:25 AM
It's the miniscule distance traveled. When Alice is told to move an object almost zero meters in exactly zero seconds repeatedly, it creates a slow, smooth line of motion which can be easily interrupted.

dubastot
08-24-2009, 10:40 PM
There's one problem. what if you have more than one section of ground. In my game I have water and land, each separate.

x2495iiii
08-24-2009, 11:20 PM
you'd either need a different gravity method with markers to indicate which ground they were over, or special If/Else If conditions in just one gravity method.

Would you like a demonstration?

dubastot
08-25-2009, 09:57 PM
An example would be most appreciated. My game is where when you go over water, you sink, but on land you stay above the ground(like any game).

x2495iiii
09-17-2009, 02:19 AM
I wrote Vol. 3 and made the topic multi-terrain gravity. It deals with land and water and hopefully addresses your needs (apologies for the delay).

dubastot
09-17-2009, 05:59 PM
Oh yeah, that's completely fine. I haven't gotten around to looking at it yet, but I downloaded it.

reuben2011
10-04-2009, 03:12 AM
How would you implement gravity if there are objects you want to land on inbetween the ground and the falling object?

x2495iiii
10-04-2009, 11:17 AM
You'd need more if/else if statements, like

if both [penguin is within (squareWidth) of square] and [penguin is above square]
then peguin move down until it hits the square
else penguin move down until it hits the ground