Jump to content


Photo

How to jump in RPG-style game?


  • Please log in to reply
2 replies to this topic

#1 the potato whisperer

the potato whisperer

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM8.1

Posted 05 April 2012 - 11:09 PM

i have been working on rpg game but i do not know how to make a jumping player. i need a way to jump and still be able to move in ALL 4 DIRECTIONS.
Help?
  • 0

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 06 April 2012 - 12:46 AM

For future reference, questions about programming that are not specific to one version of Game Maker should be in the Novice & Intermediate Users forum. I've moved it for you this time, but in the future a mod might just close it, so be careful ;) .

Now, as for your question...

Jumping is completely dependent on the view of your game. An RPG is usually top-down, so I'll assume that's what yours is. In that case, "jumping" is not very well-defined. What should jumping do? Allow you to collide with dangers/holes without getting hurt? Pass through obstacles?

Since you didn't give much information about your game, nor about what jumping means in your game, the best I can say functionally is that when you jump, you should set a "jumping" variable to true. In the CREATE event, "jumping" should be initialized to false.

As for the visual aspect, it's easiest to just use a sinusoidal function (that is, sin or cos) to change the scale of the sprite. As it scales up, it looks like he's jumping higher, and as it scales down it looks like he's falling. When the scale reaches 1 again, he's landed, so that's when you'd set "jumping" to false.

For example (with a centered origin on your sprite!):

/* CREATE */
jumping = false;
jumpHeight = 0;

/* Jump key pressed event */
jumping = true;
jumpHeight = 0;

/* STEP event */
jumpHeight += 1;
image_xscale = 1 + 0.5 * sin(jumpHeight);
image_yscale = image_xscale;

if (sin(jumpHeight) <= 0) { jumping=false; image_xscale=0; image_yscale=0; }

The 0.5 can be changed to anything; it's the maximum addition to the scaling. At 0.5, the sprite will be scaled to 1.5x at max height. If you made it 1 instead, for instance, max height would scale it to 2x.

-IMP
  • 0

#3 Bcm27

Bcm27

    GMC Member

  • New Member
  • 333 posts
  • Version:GM8

Posted 06 April 2012 - 03:11 AM

For future reference, questions about programming that are not specific to one version of Game Maker should be in the Novice & Intermediate Users forum. I've moved it for you this time, but in the future a mod might just close it, so be careful ;) .

Now, as for your question...

Jumping is completely dependent on the view of your game. An RPG is usually top-down, so I'll assume that's what yours is. In that case, "jumping" is not very well-defined. What should jumping do? Allow you to collide with dangers/holes without getting hurt? Pass through obstacles?

Since you didn't give much information about your game, nor about what jumping means in your game, the best I can say functionally is that when you jump, you should set a "jumping" variable to true. In the CREATE event, "jumping" should be initialized to false.

As for the visual aspect, it's easiest to just use a sinusoidal function (that is, sin or cos) to change the scale of the sprite. As it scales up, it looks like he's jumping higher, and as it scales down it looks like he's falling. When the scale reaches 1 again, he's landed, so that's when you'd set "jumping" to false.

For example (with a centered origin on your sprite!):

/* CREATE */
jumping = false;
jumpHeight = 0;

/* Jump key pressed event */
jumping = true;
jumpHeight = 0;

/* STEP event */
jumpHeight += 1;
image_xscale = 1 + 0.5 * sin(jumpHeight);
image_yscale = image_xscale;

if (sin(jumpHeight) <= 0) { jumping=false; image_xscale=0; image_yscale=0; }

The 0.5 can be changed to anything; it's the maximum addition to the scaling. At 0.5, the sprite will be scaled to 1.5x at max height. If you made it 1 instead, for instance, max height would scale it to 2x.

-IMP


Exactly what he said, the basics of creating a jumping effect all depend on your point of view. Most of the time you will be using gravity and a bunch of other stuff, there are PLENTY of tutorials out there.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users