Geometry Cage

In this project, we're going to learn about video game physics!

1) First, let's make our character sprite. You don't have to copy mine, but it should be four colors, one on each side because we'll use that later.

2) And then let's make the rest of the sprites. These are less important, so make them look however you like. We need floors and walls (mine are red!), we need a turret (mine is yellow and purple!), we need a goal (mine is a blue crystal!), and we need bullets (mine is yellow!).

3) Okay, let's talk about velocity. Velocity is kind of like speed. The difference is that speed is always positive (how can you travel -45 mph?) while velocity can be negative. In our case, if we are talking about X, positive velocity is speed in the right direction and negative velocity is speed in the left direction. Confused yet? It's okay let's practice! Make an "x velocity" variable. Make it a slider and change the slider range to -10 to +10. Then make your hero sprite constantly change its x position by 'x velocity.' Move the slider around and watch what your character does. Experiment with different values. What does a positive 'x velocity' do? What does a negative 'x velocity' do? What does 0 'x velocity' do?

4) Repeat for Y. What does a positive 'x velocity' do? What does a negative 'x velocity' do? What does 0 'x velocity' do?

5) You are currently constantly changing x and y by their velocities. Now, constantly change y velocity! Try different values, negative, positive, big, small. Using this, add gravity to your hero sprite. What kind of number would be best?

6) When you move into a platform, move back and stop moving. You can't go through solid floors, what's wrong with you!?

7) Use the colors on your hero sprite to keep from going through floors, walls, and ceilings. Hint: Use the colors to figure out which side is touching so you'll know which direction you need to send the hero back.

8) Add left and right keyboard controls to your hero sprite. Remember to work with velocity, not x or y position!

9) Prevent your character from getting faster than 5 steps per loop when pushing left or right.

10) Friction! Friction is what slows your character down when you let go of the buttons. Constantly halve your X velocity when you aren't pushing any buttons.

11) Create a 'jumps' variable. When you touch the ground, set it to 1. In previous projects, when you jumped, you changed y position right? Now for this project, I want jumping to change your y velocity instead. When you push the jump key, if you have any 'jumps,' jump!

12) Add a double jump or even triple jump. Hint: this should be really really simple! Make it so you can only jump once every 0.5 seconds.

13) We are finally finished with your character! Whew! Let's start on your turret. Make your turret constantly point at your hero sprite.

14) Every second, have your turrent create a clone of your bullet. The bullet should travel straight forward and delete 0.5 seconds after hitting the edge of the screen.

15) If a bullet hits your top, knock your hero down. If it hits the right side, knock it left. Left side, right. Bottom, up. Animate the explosion and delete the bullet afterwards.

16) Perfect! Last sprite. Add a goal for you to try and touch. When you touch it, go to the next level!

17) Add more levels!

18) Finally, add a gameover screen for when the players win! You did it!