Sunday, July 22, 2012

Easy Platformer Tutorial In Gamesalad

Many platformer games have long codes, but in this tutorial you will learn to write an easy platformer game. We first off create two actors, naming it player and ground.


We first enter the ground actor changing the density, restitution (bounciness), friction to 0, and uncheck movable (all these attributes are under physics).


We go back to the scene editor and go into the player actor. We change the density, restitution (bounciness), and friction to 0 (all these attributes are under physics). We drag in a collide behavior, making the player collide with the ground.


We also drag in an accelerate behavior and change the direction to 270 (down) and the acceleration to 1000. This is are "gravity".


Then we add our first rule. We say when right key is down and left key is up, change attribute self.motion.linearvelocityx to 200 (this is the speed). In the otherwise section, change attribute self.motion.linearvelocityx to 0 (meaning the player doesn't move). This will make the player move right when the right key is pressed.


We do the same (copy the rule by dragging down while pressing alt), but changing key right is down to up and key left is up to down. Also, change the self.motion.linearvelocityx to -200 (negative). This will move the player left when the left key is down.


Now, go back to the scene editor and drag the player and ground onto the scene. Resize the actors to the sizes you want them to be in. In the next tutorial, I will teach you to make your player jump.


Enjoy :)

CS Genius

1 comment: