THE NECESSARY STUFF
Start by drawing the costumes for your level(s):
| My levels. |
Next, make the player sprite:
| The sprite I am using. You can make yours however you want. |
NOW FOR THE CODING
First, make the variables you'll be using for the project. You need one for x Velocity and one for Gravity:
Now we need to make some jumping script. You can make your sprite jump as high as you want depending on how high your platforms are. The way this script works is it sets gravity to a positive value to go up, and since the player is no longer touching the platform sprite, the gravity will slow it down until it eventually comes to a stop, then moves it downwards until it is toughing the platform sprite.
Next we need to add horizontal movement. To do this, we will make an acceleration system similar to that we used for gravity.
FINISHING UP
Now we need to make the level change when the player touches a sprite. You ca make yours however you want: a flag, a wall on the right of the screen, a portal, or anything else you want. I've made a flag for mine:
Now let's make some script for the level changing:
Put this script in your flag/whatever your end sprite is....
FINAL TOUCHES
Now we need to make it so the player can't go through the ground when they jump up and move horizontally. Start by making the sprites:
Now for the scripting:
| UP Script |
| LEFT Script |
| RIGHT Script |
NOTE: Make sure you draw the levels in the same color you use in all the < touching color [] > s.
And you're done!
I hope you liked this tutorial and that it was useful to you. Thanks!
-Erick
No comments:
Post a Comment