Platform Game Example

Monkey Forums/Monkey Beginners/Platform Game Example

En929(Posted 2015) [#1]
I was wondering how do some of you handle platforms when you write platform games like Mario. For example, when Mario stands on top of a block vs.when he is under the same block and can can't go through it, etc. How do you write that? I just need to see an example for one platform and one character.

Thanks


Pakz(Posted 2015) [#2]
I make platformer game examples for my blog. I have a number of platformer examples on my blog. Below is one example of a map with platforms where a player can bump into and be ontop of platforms. The code can be copied and pasted into monkey and will work without extra media needed.

http://monkeygameprogramming.blogspot.nl/2015/01/monkey-x-platformer-movementplayermap.html

Browse my blog for more examples.

I was planning on making a example with rotating platforms where the player can jump on/off.

edit :

I modified the map array to only have one platform. code below. If you have questions about the code then ask in this thread. Or if you need just the example of the player moving/jumping and one tile with bumping on standing on then let me know.



the map array hold the platforms. the way it is coded it treats every 1 value as a platform. It uses the rectsoverlap function to see if the coordinates of the player is inside a platform and then things are handled.

Things like player movement and jumping is difficult for beginners to. I have a example of only that on my blog. You should start with collision and player movement and jumping. Then tilemaps for that is what games like mario uses. You check every one pixel movement of the player with the nearest platforms on the map. If he is jumping and is inside a tile with the next movement then he changes to falling down(bump)
when he is falling down and is inside a platform in the next step of movement then the jump is stopped and he does not fall down anymore.


En929(Posted 2015) [#3]
Pakz, that was a perfect example and was exactly what I needed. Thanks!


therevills(Posted 2015) [#4]
Here's another example too:



This one uses ray casting for its collision detection, this allows you to have really fast objects moving around the map.


En929(Posted 2015) [#5]
therevillis, that was an excellent example. That way was helpful too. Thanks for making that.


vic(Posted 2015) [#6]
Thanks guys... for both examples :)