Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jun 20, 2013 3:57 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Jan 09, 2012 3:46 am 
Offline

Joined: Mon Jan 09, 2012 2:10 am
Posts: 17
Hey guys,

I want to roll a simple platformer with some physics elements in Slick, and I've been trying to set up Fizzy. I'm having some weird trouble with gravity, though. When I launch, my player sprite drops to the nearest solid surface, as expected. But when I move him upward (using applyForce) he'll just hang in the air until I either push him left, right, or down. As soon as I do, gravity seems to work on him again. This is my movement code, from my update method...

Code:
if (gc.getInput().isKeyDown(Input.KEY_LEFT)) {playerBody.applyForce(-0.01f, 0f);}
if (gc.getInput().isKeyDown(Input.KEY_RIGHT)) {playerBody.applyForce(0.01f, 0f);}
if (gc.getInput().isKeyDown(Input.KEY_UP)) {playerBody.applyForce(0f, -0.06f);}
if (gc.getInput().isKeyDown(Input.KEY_DOWN)) {playerBody.applyForce(0f, 0.01f);}

...

mapWorld.update(delta);


playerBody is a Rectangular DynamicBody, and gravity is set to 0.0001f -- I'm working at a really small scale right now, and when it actually acts on the player, that amount of gravity is more than enough. Any ideas what I'm doing wrong? Thanks in advance for any suggestions!

Edit: Want to apologize for the double-post. This was my first post to these forums and I managed to forget that I'd already made a submission and it got caught in the new-user filter.


Top
 Profile  
 
PostPosted: Mon Jan 09, 2012 9:37 am 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
ForSpareParts wrote:
Edit: Want to apologize for the double-post. This was my first post to these forums and I managed to forget that I'd already made a submission and it got caught in the new-user filter.


No problem at all - especially because the "new-user filter" is completely human controlled :wink:

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group