Alternating gravity
Gravity can be a harsh mistress; if you've ever fallen from a height, you know what I mean. I often think it would be great if we could somehow lessen gravity's hold on us, but then I wonder what it would be like if we could just reverse it all together! Imagine flipping a switch and then walking on the ceiling! I, for one, think that it would be great. However, since we don't have the technology to do it in real life, I'll have to settle for doing it in video games.
Getting ready
For this recipe, let's simplify things and use the physics environment that we created in the previous recipe.
How to do it
- In
obj_control
, open the code block in the Create event. - Add the following code:
physics_world_gravity(0, -10);
That's it! Test the environment and see what happens when you create your physics objects.
How it works
GameMaker's physics world gravity is vector-based. This means that you simply need to change the values of x and y in order to change...