skull

Robert Tamayo

R
B
code
skull

Gravity Should be a Vector

As I make the prototype for Balloon Ghost, I'm adding little things to the "engine" I made for Robot Ops. 

I decided I wanted an enemy that would be able crawl around blocks, similar to the spiky enemies found in both Metroid and Mario games. I don't know what my ultimate solution for it will be, but for now, I'm trying to have his gravity change from falling downwards to falling upwards and to the right and left according to his angle.

Previously, I had only treated gravity as a float. It's a negative number that gets added to the y velocity each frame. What I'm discovering now, however, is that I should have always treated it as a Vector, an object with x and y values. Treating it as a vector will mean I can add it to both the x and y velocities for the enemy each frame; if the x gravity value is 0 for 99% of the enemies, then nothing would be added to the x velocity. In the case that I want the enemy's gravity to be different, it will naturally "fall" in the correct direction.

There are some interesting things I'm learning while going through this code again, and if I weren't just trying to prototype a 30-level game for a quick release, then I would probably spend more time on it. I do miss working with Unreal Engine and Blender, though.
Comments:
Leave a Comment
Submit