Custom Platform Movements Part 2
Author: | Shen
|
Submitted: | 30th August, 2002
|
Views: | 6958
| Rated: |
|
|
Straight in...
Up and Down
Up and Down can be much harder to do than Left and Right, because of gravity and floor detecting. Right.
Bottom is not overlapping a backdrop
And Value A is less than 6:
Add 1 to Value A
Bottom is overlapping a backdrop
And Only one action when event loops:
Set Y position of Player to Y position of Player - Value A
Set Value A to 0
If the Bottom marker - the lowest marker - is not overlapping anything, the player is most likely in the air, so add 1 to Value A to simulate gravity. When it is overlapping the background, stop the player from falling any more, and move the player up a bit (if you don't do this the player might fall into the floor a bit)
What about jumping? You need to set Value A to a minus value, such as -5, when the user presses the jump button:
Shift button is pressed
And Bottom is overlapping the background:
Set Value A to -5
Note that we have to check if the player is in the air or not, so the player can't carry on jumping. And when a wall is hit:
Top marker collides with the background:
Set Y position to Y position - Value A
Set Value A to 1
This stops the player from going up any higher. And that pretty much covers the main platform movement. Try it, change a few things, and fiddle with it enough to suit your needs.
Other stuff you can do
Springs: You can change Value A to -8 for a vertical spring, or Value B to -8 or 8 for a wall spring.
Double Jumping: Use Value C. Set it to 0 when the player is on the ground. When a jump occurs, add 1 to Value C. Finally, restrict the Jump event so the player can only jump if Value C is 2 or less, instead of the bottom marker being on the ground.
Swimming: This can be quite tricky. You did put your events into groups, right? If you didn't, do it. Anyway. Basically it goes like this: If the player is in water, disable the movement groups, and enable them again when the player is out of water. Enable the new 'Swimming' group when in water. When the right arrow key is pressed, move the player in that direction - up arrow key takes you 1 pixel up, right takes you 1 pixel right, and so on. When no keys are pressed, move the player down a bit. You could add speeds and stuff, but I might write another article about swimming movements soon so look there
Ladders: You'll need to edit the falling event for this - if the player is on a ladder, don't let the player fall. However, the rest is quite easy - bottom marker is overlapping a ladder, and an arrow key is pressed, move the player 2 pixels up or down.
And finally...
Why didn't I make an example out of this instead of telling you what events to put in? Because making it into an article like this encourages people to remember what events they use and develop more things to add to it, rather than taking a whole load of pre-done code and not knowing how it works or how to change it. There are many ultimate platform tutorials, on the Clickteam File Archives or here on the Daily Click. Use them if you need to, but try to understand it and change it first.
Shen
|
|
ShenPossibly Insane
Registered 14/05/2002
Points 3497
|