Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (755) Games in Android Showcase (229) games submitted by our members Games in WIP (842) 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 8856 times) 0 Members and 1 Guest are viewing this topic.
wreed12345

JGO Knight

Medals: 28
Projects: 3
Exp: 5 years

https://github.com/wreed12345

 « 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: 138
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: 167
Projects: 5
Exp: 6 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: 138
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
Best Username Ever

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: 28
Projects: 3
Exp: 5 years

https://github.com/wreed12345

 « 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: 138
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: 28
Projects: 3
Exp: 5 years

https://github.com/wreed12345

 « 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: 138
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: 28
Projects: 3
Exp: 5 years

https://github.com/wreed12345

 « 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...
Pages: [1]
 ignore  |  Print

 DesertCoockie (52 views) 2018-05-13 18:23:11 nelsongames (82 views) 2018-04-24 18:15:36 nelsongames (74 views) 2018-04-24 18:14:32 ivj94 (757 views) 2018-03-24 14:47:39 ivj94 (87 views) 2018-03-24 14:46:31 ivj94 (643 views) 2018-03-24 14:43:53 Solater (102 views) 2018-03-17 05:04:08 nelsongames (184 views) 2018-03-05 17:56:34 Gornova (426 views) 2018-03-02 22:15:33 buddyBro (1086 views) 2018-02-28 16:59:18
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org