Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  Jumping in a platformer  (Read 3568 times)
0 Members and 1 Guest are viewing this topic.
Offline zparticle

Senior Duke




Thick As A Brick


« Posted 2002-12-17 00:42:59 »

I'm working on a platformer (Mario Bros. esq) and have a question. When character jumps I current have his vertical velocity decreasing as he goes up and then increasing as he comes down.  While this seems correct the feel of it is strange. What do most platformer type game do for this?

Offline Harley Rana

Junior Duke




Java games rock!


« Reply #1 - Posted 2002-12-17 05:41:46 »

Hi i think you just need to use acceleration.

Having a accel[4], which contains the acceleration for each direction.  Then you can find the resulting movement from the remainder between the 2 opposite accelerations,  and at each frame when you process key presses you add the right accel_step to each direction.

       int accel_y = acceleration[2] - acceleration[0];
       int accel_x = acceleration[1] - acceleration[3];        
       
       x += (int)(accel_x * time_step);
       y += (int)(accel_y * time_step);

I used this in a space shooter to get a nice accleration feeling.  Instead of moving at a constant speed, you accelerate and deccelerate properly.

Hope that helps.  Harley.
Offline JuddMan

Senior Duke


Medals: 1


Your Ad Here


« Reply #2 - Posted 2002-12-18 09:45:21 »

Assuming that up is positive, you need to start with a high velocity, and decrease it constantly... when it gets to zero that's when your character is at the top of his jump, and then it will still be decreasing into negative velocity meaning he'll be starting to come down.

here is my really bad implementation of Mario Bros... it uses very bad system to draw the images but a reasonable movement one although the clipping not too good. (collision detection)

http://members.austarmetro.com.au/~juddman/files/java/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zparticle

Senior Duke




Thick As A Brick


« Reply #3 - Posted 2002-12-18 14:26:23 »

I can't get the guy to move. I hit the go button and he appeared but then the button retains the focus.

Offline JuddMan

Senior Duke


Medals: 1


Your Ad Here


« Reply #4 - Posted 2002-12-19 01:32:41 »

sorry about that, but the keylistener class i made doesnt seem to work in 1.4

i wrote it in java 1.3... anyone know why? also you might try adding that keylistener to the go button if it retains focus, or you could add mainFrame.requestFocus to the go buttons actionlistener but as i dont have 1.4 yet i cant really test this.

edit: x and z for run and jump

i'm going to be rewriting the whole program soon. that file is the final working one, at the moment i have started over entirely.

edit: Ok i installed 1.4 and to fix it temporarily you can modify the line 160: this.addKeyListener(keys);
to go.addKeyListener(keys);

and it works... it's a little diferent to 1.3,  it runs faster...
Offline JuddMan

Senior Duke


Medals: 1


Your Ad Here


« Reply #5 - Posted 2002-12-19 02:40:56 »

for those too lazy or cant be bothered editing the source there's a new reecompiled exe at
http://members.austarmetro.com.au/~juddman/files/java/
Offline zparticle

Senior Duke




Thick As A Brick


« Reply #6 - Posted 2002-12-19 12:23:06 »


Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #7 - Posted 2002-12-19 12:53:44 »

you need the zip too - extract it, and copy the fixed exe inside

Offline JuddMan

Senior Duke


Medals: 1


Your Ad Here


« Reply #8 - Posted 2002-12-19 14:02:56 »

Thanks for telling him  Smiley

i'm just wondering, are these .exe files more or less convenient?

double clicking the jar usually does the same as opening the exe without error reporting

ZParticle, i hope this has helped you with your platformer. how far have you got with it? could you post a screenshot? more people should post screenshots of their games to the board.

Offline zparticle

Senior Duke




Thick As A Brick


« Reply #9 - Posted 2002-12-19 18:47:34 »

Well I'll post post something up when I feel better about it, right now I'm still waiting to see if a number of people that offered to work on the graphics are going to come through or not. I suspect they won't. The system and the basic game structure are in place and running well I simply need decent graphics and level ideas.

I implemented the jump in the manner you suggested but there is still something about it that bothers me. It just doesn't feel right where he stops going up and then starts dropping.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Harley Rana

Junior Duke




Java games rock!


« Reply #10 - Posted 2002-12-19 21:15:28 »

Hey check out
http://www.gamedev.net/reference/articles/article437.asp

Its really an old falling body physics question.
The real equation is newSpeed = oldSpeed * vel * time + 1/2 ^a*time2

which is correct but not really useable in the game.

Now this it probally what you have already, but this seems to work.

float up_accel = 0.0f;

         if(jump){            
           up_accel = 1.0f;
           jump = false;
         }
         int y = (int)(py - up_accel * speed);          
         
         if(up_accel > 0.0){
         up_accel -= gravity;
         }
                   py = y;

you can just tweak gravity and speed to change how fast you go down and up.  gravity's a float 0-1, speed is an it like 8;

Hope that actually helps!  Harley.
Offline JuddMan

Senior Duke


Medals: 1


Your Ad Here


« Reply #11 - Posted 2002-12-20 01:21:24 »

i admit i am no phycisist, but having the sprite accellerate up off the ground would sort of look like he's being pulled up on an invisible rope? the accelleration should always be downwards, and the velocity should start at a high number and get set back to zero when he hits the ground.

ZP, what sort of graphics? If it's a rip off of mariobros, you can use mine if you want  Smiley or if you tell us a little about the character, the plot, and a bit of other stuff, i could try make up some little sprites and post them. i'll probably be changing the graphics on my game when it's finished.

at the moment i have managed to dig out the JLabels and first changed them to JComponents with their own Paint methods, but that didn't seem much faster than the label, so i've started now on working on the paint method of the panel that displays the sprites, adding them to it's own bufferedimage. it seems a lot faster but there are a few bugs i have to work out like the artifacts left in the wake of any image. ATM my game would not be playable. i am intent on getting the graphics system for it working at a playable level before i start adding anything else to it and it's a headache.
Offline zparticle

Senior Duke




Thick As A Brick


« Reply #12 - Posted 2002-12-20 02:51:45 »

Juddman and Harley, please join me at http://www.scottshaver2000.com/forum under the Jumping Jimmy topic. I realy appreciate your input.

Offline rgeimer

Senior Newbie





« Reply #13 - Posted 2002-12-20 12:11:22 »

I agree with JuddMan. Start with an initial up velocity, say 3 pixels / tick, then decrement it with each tick. Stop falling when your feet collide with something.

ticks | velocity | total up distance
0        0           0
0        3           3
1        2           5
2        1           6
3        0           6 (pauses in midair like Michael Jordan)
4       -1           5
5       -2           3
6       -3           0 (hits the ground)


Rick

Offline zparticle

Senior Duke




Thick As A Brick


« Reply #14 - Posted 2002-12-20 15:42:19 »

JuddMan the project description can be found at http://www.scottshaver2000.com/projects/jnj.html

Offline Harley Rana

Junior Duke




Java games rock!


« Reply #15 - Posted 2002-12-21 02:01:55 »

Hey, JuddMan an myself are really talking about the same thing.  "you need to start with a high velocity, and decrease it constantly... ", i just called it acceleration.

The method i posted actually worked (i tested it with a ball ), but i haven't made a platformer game.  For this application velocity and acceleration are pretty much the same thing.  As it isn't the real equations, but a simplifed version it doesn't make a difference.

Harley.
Offline zparticle

Senior Duke




Thick As A Brick


« Reply #16 - Posted 2002-12-21 02:18:26 »

Thank you both very much for your input.

Offline leknor

Junior Duke




ROCK!!!


« Reply #17 - Posted 2002-12-21 02:20:50 »

At first I was of the impression that an acceleration formula should be used but I'm not so sure any more. Think about this, your character jump off of a high platform. Do we want it to continue to accelerate until it lands or should it max out at about the same velocity as the jump was started at. I think that I would prefer a cap on the character's fall velocity and I think I'd like a slight hover at the top of a jump. IMO a precalculated jump velocity table would be the way to go. That said, I haven't written a platformer so I could be wrong, maybe I should refresh my memory: http://www.mame.net/
Offline zparticle

Senior Duke




Thick As A Brick


« Reply #18 - Posted 2002-12-21 19:06:57 »

Another question:

In platformer type games do you all like the idea of a limited time to complete a level or the idea of player lives?

Remember that this is targeted for children.

Offline leknor

Junior Duke




ROCK!!!


« Reply #19 - Posted 2002-12-21 22:08:01 »

Quote
do you all like the idea of a limited time to complete a level or the idea of player lives?

Is the level a rich enviroment? If there is little more to do in a level than get through it than a timer would be acceptable, but if there are hidden blocks, items, etc than a time would discourage exploration.

Outside the context of a coin operated game lives don't serve much of a purpose, plus what's the point if you can load a saved game. One thing you do see is "continues" which basicly let you resume playing with little loss of progress instead of having to start from the last save point.
Offline zparticle

Senior Duke




Thick As A Brick


« Reply #20 - Posted 2002-12-22 15:32:37 »

JuddMan for screen shots you can go to:

http://www.scottshaver2000.com/forum

look in the Jumping Jimmy forum. Note that these shots are temporary graphics. Look at the "work continues" threads.

Offline JuddMan

Senior Duke


Medals: 1


Your Ad Here


« Reply #21 - Posted 2002-12-30 08:19:39 »

hey sorry i was away, actually i still am... on holidays, just checking back. Velocity and accelleration arent the same thing in platformers, and some of the things in them are also related to physics.

edit: hey that guy looks like the one on the nes game Impossible Mission!
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.

Longarmx (37 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!