Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Making a 2.5d game - Golden Axe style- need suggestions for the JUMP  (Read 3150 times)

0 Members and 2 Guests are viewing this topic.

Despairy

  • Newbie
  • *
  • Posts: 14
    • View Profile
I'm not so sure about how to implement the jumping functions .

obviously I have the x and y cordinates on the screen
once the user jumps i need to DEcrease the y coordinate only for the sprite to go up for jumping
but I need to change it as the Z coordinate since walking up is decreasing the y coordinate aswell.

 i thought of saving the old Y coordinate before jumping and check for FLOORs collision with the same old Y
but if i jump from one surface to another i need to know where to land on the Y coordinate

added an amazing photoshopped picture , hope you understood what i meant :)

thanks

[attachment deleted by admin]

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Making a 2.5d game - Golden Axe style- need suggestions for the JUMP
« Reply #1 on: June 17, 2012, 10:44:27 pm »
An 'easy' solution would be to disallow Z movements while jumping but I guess this would defeat the gameplay.

But isn't it possible to just implement a normal jump machanism and instead of checking just at one position you take in account the Z position and check accordingly?

For the movement along the Z axis you should just decrese the X and Y movement relative to the Z position.

How did you implement the Z movment without jumping?

Or did I get your question completly wrong?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Despairy

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Making a 2.5d game - Golden Axe style- need suggestions for the JUMP
« Reply #2 on: June 18, 2012, 01:28:46 am »
if there are no jumping theres no need for Z movement ( unless you speak of falling)
well I need to declare floors and rectangles and make a collision detection with them
anyhow i have a simple idea of figuring out the distance of the character from the bottom point of the floor
and if i hit another floor i need to have around the same distance.... problem is from jumping from small
area to larger ( or opposite ) that this calculation wont be good enough...

ill make more photoshops if it might help u help me ;)
ty

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Making a 2.5d game - Golden Axe style- need suggestions for the JUMP
« Reply #3 on: June 18, 2012, 03:17:00 am »
So to clearify if we're talking about the same coordination system.
The X axis goes horizontally, the Y axis goes vertically and the Z axis goes into the picture, is this the same system you had in mind?

Also the image didn't reall help since you just put there some colors without explain what they stand for etc. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Despairy

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Making a 2.5d game - Golden Axe style- need suggestions for the JUMP
« Reply #4 on: June 18, 2012, 09:25:25 am »
yeah that is the right coordinate system.

and yeah the colors are like meaningless :P
but its like golden axe when jumping it changes  the Z coordinate

could use an idea ;) ty

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Making a 2.5d game - Golden Axe style- need suggestions for the JUMP
« Reply #5 on: June 18, 2012, 12:13:16 pm »
You basically have to do 3D->2D transformations. Even if you have a 2D game, you're simulating depth, therefore you have to store your object's positions using a 3D coordinate system and transform them into 2D for rendering. You won't run into trouble with hacking your positions anymore.

x and y of each object can still be transformed 1:1, however you have to transform z into x and/or y (because those are the only axes you have for rendering). When an object moves further afar, the z value decreases (or increases, which depends on your implementation of your coordinate system). Visually you see that by moving the object up, that means you decrease y of the rendered visual (for a good effect you should also scale objects down that are far).

A very simple example for a transformation:
sf::Vector2f transform_to_screen( const sf::Vector3f& origin ) {
  return sf::Vector2f( origin.x, origin.y - origin.z );
}

You might want to play around with how origin.z is added to origin.y. However you won't mix axes anymore like you tried to do before (to recall: jumping affects y axis, moving far/near not, that's why you had issues).

 

anything