# [Game Maker] Top-Down Jumping

This topic is 616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, guys! First of all sorry for my bad English, I hope you can understand everything.
I am working on a Top-down game similar to Alundra:

The player and other instances are able to jump on other objects and platforms. I spend so much time making a jump system like Alundra's but it doesn't work. I especially have problems with the object's depth because I don't know how to set it correctly. The depth specifies the order in which the objects are drawn to the surface.

I wonder how they did it in Alundra:

Thank you really much!

Regards,
Kerberos.

Edited by Kerberos99

##### Share on other sites

The way I would do it is sort objects by their y value. Assuming +y is downward, if your player's y (probably best to check the player's position at their feet) is less-than the object's y (offset a little from the top), then the player gets drawn first. Whereas if the player's y is > object's y then the player gets drawn first. This will get you proper sorting for if the player is behind or in front of.

For jumping, you would have a "z" value in addition to the x and y. The z value would represent the player's jump height. When the player's sprite gets drawn you draw the sprite at (x, y + z).

I haven't used Gamemaker, but if there is a "depth" value that specifies draw order, just set that depth value to the object's y location. For the player sprite, it would be a good idea to get the y position of the feet (y + spriteHeight) for best results.

For jumping onto objects, you would have to think about the 3rd dimension. Normally you just do intersection testing with the bounding box of the object to figure out if the player collided with the object. To keep things simple since this isn't "real" 3D, I would have a "height" value for an object. So for example, that table could have a height of 4 units tall. When the collision check happens, I would just do something like: if collidedWithObject AND player.z > table.height THEN allow movement ELSE collide. Then as the player falls down from gravity and lands on the table, you would set the player's "z" to the table's height. Then of course you would have to set the z value to 0 once the player gets off the box.

It is complicated, and theres a lot more work to be done. I don't know how to translate this into gamemaker, but that is the concept behind it.

Edited by CirdanValen

##### Share on other sites

CirdanValen has it the way I would do it(and I have used Gamemaker though never done this exact thing before).  Assuming you already have a way to detect collision with the table and not walk through it, you will need to add some variables to your object.  You will need to track your x and y position as usual, and unless everything you can stand on is the same height, you need a 'z' value.  Separately you will need to control your depth as well, since you could be standing on the floor behind the table to make your character draw ahead of the table or by being on top of the table.

You would likely take over the draw event and manually draw your character.  This would be easier than constantly changing the x/y for the height, letting you only modify it as needed to change the draw position.  As far as everything is concerned, the character will have the x/y it would have had if the table wasn't there.  The draw event will add the 'z' to the y(technically subract it since going up means Y goes negative).

About collisions, you will have a collision event with the table, or you will have code that is directly checking it.  In either case, you need to verify your 'z' value to see if you are really colliding or are just on top, and change the response accordingly.

I think your best bet is to try some code, and then post what you have if you can't get it working.  I also recommend you use the Gamemaker Forum unless for some reason you can't.  There are many more people over there that know GML/Gamemaker so you would more likely get better help sooner than on a general gamedev forum like this one(in my opinion anyway).

##### Share on other sites

There is nice YouTube tutorials done with Game Maker and 2,5D graphics, e.g.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013294
×