Slick Forums

Discuss the Slick 2D Library
It is currently Sat May 25, 2013 11:13 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sun Feb 20, 2011 8:18 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
I'm integrating Fizzy into this game here... and am having problems. Since I'm new at using physics libraries (always wrapped my own), I'm a bit at loss why this doesn't work as straight forward as I hoped.

First, it's a top-down tank game, the only obstacles are crates. I want the tank to be able hit into these crates, push them around. The tank should be able to "push" about 3-4 crates max. So, imagine a 10 ton tank pushing around 2 ton crates.

Second, I'm currently moving the tank around by calling Body.setVelocity and Body.applyForce. However, these don't seem to work as I thought. Body.setVelocity does nothing unless I call Body.applyForce. Seems strange. Anyway, what I want here is to apply a little "thrust" of certain value to the body whenever the player is moving the tank forward.

Third, whenever something collides, the bodies (using rectangles) seem to rotate slowly for a long time. This is not that behavior I'm looking for. I've tried adjusting the parameters for density, damping, friction, restitution, but to no success.

Fourth, the rectangles for the bodies seem to overlap a lot, and then I mean a lot. This isn't good, I don't want my tank to overlap with the crates at all!

Fifth, setting offset for the Rectangle in the Body doesn't seem to work very well.

Sixth, sometimes it's like bodies collide even though they don't.

Seventh, density = mass?


Most of this can be explained by my bad knowledge of physics libraries, but still, it's sort of strange.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 20, 2011 9:13 pm 
Offline

Joined: Sun Aug 15, 2010 5:23 pm
Posts: 13
Look at the way the WorldCanvas draws the bodies :) They're drawn at teir center instead of top-left corner

Oh, and I'm pretty sure the engine is built for parameters from 0.0001 to 10 or along those lines :)

_________________
~Mads


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 20, 2011 9:55 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
In a empty world, how should I move a tank around using Body?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 20, 2011 10:19 pm 
Offline

Joined: Sun Aug 15, 2010 5:23 pm
Posts: 13
appel wrote:
In a empty world, how should I move a tank around using Body?


Thats a very good question.. I cant answer it though (hence my thread about vehicles). Im thinking about rotating the body, but Im having trouble welding it all together if the chassis should stay on top and stand still..

_________________
~Mads


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2011 8:52 pm 
Offline

Joined: Sun Jun 26, 2011 10:22 pm
Posts: 13
Location: Seattle, WA, USA
It sounds like you want a revolute joint between the turret and the main chassis, as per the Box2D manual. I'm reasonably sure that Fizzy actually doesn't surface this, but I'm sure JBox2D does. I'm not sure, but I suspect you'll need to configure the turret and the tank explicitly to not collide with each other. So...unfortunately, this does mean you need to do a little bit of leg work to modify Fizzy. If you'd be so kind, you can do this by forking my repository, here: https://github.com/nanodeath/fizzy

If you find the joints system of JBox2D to be really rough around the edges, feel free to design your own joint abstraction layer on top of JBox2D. Otherwise, just create doppelganger classes that mimic JBox2D without tightly coupling application code to JBox2D. Then send me a pull request when you're finished and I can try to incorporate it into the "main" Fizzy engine.

Thanks,
Max


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2011 11:12 pm 
Offline

Joined: Sun Jan 02, 2011 8:39 pm
Posts: 64
You could take a look at Dyn4j physics engine. Might have what you want.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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