Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (581) Games in Android Showcase (163) games submitted by our members Games in WIP (632) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Home Help Search Login Register
Pages: [1]
 ignore  |  Print
 Making a sprite jump?  (Read 3914 times) 0 Members and 1 Guest are viewing this topic.
wreed12345

JGO Knight

Medals: 25
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Posted 2013-01-05 21:01:08 »

In order to make something simply jump would I use a parabola or something simpler?

matheus23

JGO Kernel

Medals: 121
Projects: 3

You think about my Avatar right now!

 « Reply #1 - Posted 2013-01-05 21:09:43 »

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29 `public class JumpingThing {   // You might want to play around with this:   public static final float METER_TO_PIXELS = 32f;   public static final float SECONDS_TO_FRAMES = 1f / 60f;   // 9.81 [m/s²] is the average ground factor on earth. This is the value to play around,    // if you want the game to play on the moon, for example   public static final float GRAVITY = 9.81f * METER_TO_PIXELS * SECONDS_TO_FRAMES;   // Play around with this value as well:   public static final float JUMP_POWER = 10f; // The higher this value, the higher (stronger) it jumps.   // Usually you'd also have X position and so on, but I leave it out, since it's only going up or down   private float velocityY;   private float positionY;   public void update() {      // Make the object accelerate towards the bottom      velocityY += GRAVITY;      // If you use this method names I'll kill you :P      if (thisThingWantsToJump() && thisThingIsAbleToJump()) {         // It's minus, because it's going down, not up.         // Remove the minus, when you have your y values          // increasing to the top.         velocityY = -JUMP_POWER;      }      positionY += velocityY;   }} // That's it!`

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Jimmt
« League of Dukes »

JGO Kernel

Medals: 161
Projects: 5
Exp: 3 years

 « Reply #2 - Posted 2013-01-05 21:32:47 »

http://lmgtfy.com/?q=jumping+in+java

Seriously, you needed to create a new thread for this? There are countless examples and explanations online and even here on this forum.
 Games published by our own members! Check 'em out!
matheus23

JGO Kernel

Medals: 121
Projects: 3

You think about my Avatar right now!

 « Reply #3 - Posted 2013-01-05 21:34:09 »

http://lmgtfy.com/?q=jumping+in+java

Seriously, you needed to create a new thread for this? There are countless examples and explanations online and even here on this forum.

I hate lmgtfy links, but basically you're right.

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github

Junior Devvie

 « Reply #4 - Posted 2013-01-05 21:36:12 »

Seriously?

Edit: Ninja'd. Search for gravity in games or something.
sproingie

JGO Kernel

Medals: 202

 « Reply #5 - Posted 2013-01-05 21:45:44 »

In order to make something simply jump would I use a parabola or something simpler?

This endless parade of really basic questions is really starting to wear on people here.  You need to do some really basic research first, and if you're still stuck, flesh out your questions with something you've already tried.  Show a little effort.
wreed12345

JGO Knight

Medals: 25
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Reply #6 - Posted 2013-01-05 21:48:35 »

I suppose you are right about that, i try and learn things quickly and often dont find results as quickly as I want so I come here... I will start spending more time researching from now on

matheus23

JGO Kernel

Medals: 121
Projects: 3

You think about my Avatar right now!

 « Reply #7 - Posted 2013-01-05 21:49:57 »

I suppose you are right about that, i try and learn things quickly and often dont find results as quickly as I want so I come here... I will start spending more time researching from now on

Now, did my post help you, at least?

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
wreed12345

JGO Knight

Medals: 25
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Reply #8 - Posted 2013-01-05 21:51:47 »

I have not tried it yet but should velocityY += GRAVITATION; in the second line of the update method be velocityY += GRAVITY; ?

matheus23

JGO Kernel

Medals: 121
Projects: 3

You think about my Avatar right now!

 « Reply #9 - Posted 2013-01-05 22:35:35 »

I have not tried it yet but should velocityY += GRAVITATION; in the second line of the update method be velocityY += GRAVITY; ?
Yes. sorry, typo *fixing it*

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
 Games published by our own members! Check 'em out!
wreed12345

JGO Knight

Medals: 25
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Reply #10 - Posted 2013-01-05 23:22:27 »

Thanks it works great! i now know I shouldnt ask things like this here

ReBirth
 « Reply #11 - Posted 2013-01-06 01:57:11 »

Also, this is wrong forum section. Should be Newbie Questions

PeterNicholson

Senior Devvie

Medals: 3
Projects: 1

 « Reply #12 - Posted 2013-01-06 13:32:11 »

Hmmm?? maybe wreed12345 doesent like doing his homework...