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

JGO Knight

Medals: 22
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

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

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

matheus23

JGO Wizard

Medals: 97
Projects: 3

You think about my Avatar right now!

 « Reply #1 - Posted 2013-01-05 22: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: 114
Projects: 4
Exp: 3 years

 « Reply #2 - Posted 2013-01-05 22: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 Wizard

Medals: 97
Projects: 3

You think about my Avatar right now!

 « Reply #3 - Posted 2013-01-05 22: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 Member

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

Seriously?

Edit: Ninja'd. Search for gravity in games or something.
sproingie
 « Reply #5 - Posted 2013-01-05 22: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: 22
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Reply #6 - Posted 2013-01-05 22: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 Wizard

Medals: 97
Projects: 3

You think about my Avatar right now!

 « Reply #7 - Posted 2013-01-05 22: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: 22
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Reply #8 - Posted 2013-01-05 22: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 Wizard

Medals: 97
Projects: 3

You think about my Avatar right now!

 « Reply #9 - Posted 2013-01-05 23: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: 22
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Reply #10 - Posted 2013-01-06 00:22:27 »

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

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

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

PeterNicholson

Senior Member

Medals: 3
Projects: 1

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

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

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 xsi3rr4x (27 views) 2014-04-15 18:08:23 BurntPizza (22 views) 2014-04-15 03:46:01 UprightPath (38 views) 2014-04-14 17:39:50 UprightPath (20 views) 2014-04-14 17:35:47 Porlus (36 views) 2014-04-14 15:48:38 tom_mai78101 (61 views) 2014-04-10 04:04:31 BurntPizza (119 views) 2014-04-08 23:06:04 tom_mai78101 (219 views) 2014-04-05 13:34:39 trollwarrior1 (186 views) 2014-04-04 12:06:45 CJLetsGame (193 views) 2014-04-01 02:16:10
 princec 32x Riven 29x Rayvolution 20x Gibbo3771 15x Roquen 12x BurntPizza 12x saucymeatman 12x ctomni231 11x matheus23 10x theagentd 10x kpars 10x HeroesGraveDev 9x Drenius 9x trollwarrior1 9x JFixby 8x SHC 8x
 List of Learning Resourcesby Longarmx2014-04-08 03:14:44Good Examples2014-04-05 13:51:37Good Examplesby Grunnt2014-04-03 15:48:46Good Examplesby Grunnt2014-04-03 15:48:37Good Examples2014-04-01 18:40:51Good Examples2014-04-01 18:40:34Anonymous/Local/Inner class gotchasby Roquen2014-03-11 15:22:30Anonymous/Local/Inner class gotchasby Roquen2014-03-11 15:05:20
 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