Box2D Forums

It is currently Tue Sep 02, 2014 10:29 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Tank
PostPosted: Fri Dec 07, 2007 7:57 am 
Offline

Joined: Fri Dec 07, 2007 7:50 am
Posts: 7
Hey i was wondering what code did you use for explosions ? I spent some time with box2das3 and i came up with this:
http://eduneuro.pl/test/PhysTest.swf
(Move with lef-right arrow up-down move the turret and space shoots)
however i need explosion code for the bullets :)


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Fri Dec 07, 2007 9:59 am 
Offline

Joined: Wed Nov 28, 2007 9:46 pm
Posts: 34
cool! getting a working turrent was going to be my next step.

The bombs work by tracking collisions, if the the force of the collision is over a certain threshold, it decreases a 'strength' value in a class assigned to m_userData in the shape, As the strength value decreases, the color changes, when if finally reaches 0, I add a large amount of angular velocity to the body the shape belongs too, and destroy it the body in the next time step. I'd be happy to share the code with you, just drop me an email or hop on the box2d IRC channel. ninjascience@gmail.com.

It's not a true bomb. For instance, nearby objects will often remain completely unaffected. My idea for a better bomb would be to define a circle that represents the bomb's shockwave radius. For every shape in the circle, apply a force outward from the circle, with the amount of force dropping off the further the shape is from the blast center. I'm not sure if this kind of area based collision testing is supported by the engine though.


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Fri Dec 07, 2007 11:15 am 
Offline

Joined: Fri Dec 07, 2007 7:50 am
Posts: 7
I see, i think i could use aabb query to get objects nearby then check the distance from the center of the explosion and apply proper force to objects. However i would also want to check if bodies aren't hidden behind a static object like wall. However that might be more difficult


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Sat Dec 08, 2007 3:39 pm 
Offline

Joined: Fri Dec 07, 2007 7:50 am
Posts: 7
I spent another day working with box2d. I have rewritten all the code creating some simple base for future. So there's not a lot of new stuff however here's another demo : http://oek.nazwa.pl/t/PhysTest.swf
Turret is controlled with the mouse and left mouse button fires a bullet. It still has a lot of issues but i guess it could become a fun game someday. Is there anyone interested in working together on such a game ?


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Sun Dec 09, 2007 1:46 pm 
Offline

Joined: Wed Nov 28, 2007 9:46 pm
Posts: 34
i certainly am! I think we're on the same page as far as the basic concept, and I have an excellent concept artist willing to work for free.

my email is in the opening post, drop me a line.


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Tue Dec 18, 2007 12:36 pm 
Offline

Joined: Sat Dec 15, 2007 2:03 pm
Posts: 22
Hello.
Phervers, please give to us the source code. I very need it.
I should learn as to create explode and how to trace how much "health" loses object at impacts.


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Tue Dec 18, 2007 2:09 pm 
Offline

Joined: Wed Nov 28, 2007 9:46 pm
Posts: 34
phervers and I have teamed up on this tank game. We aren't willing to release all the sourcode at this point, but we'd be happy to share tips and techniques.

Tracking health is a matter of tracking all the collisions each time the world updates itself. There's a method or property in the world object to get a collection of all the collisions. You can loop over that and apply the force of the collision to both objects in the collision, decreasing the health for each object.


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Wed Dec 19, 2007 4:04 am 
Offline

Joined: Sat Dec 15, 2007 2:03 pm
Posts: 22
You can post small code, which get a collection of all the collisions in b2world and forces of these collisions?


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Wed Dec 19, 2007 9:11 am 
Offline

Joined: Tue Dec 11, 2007 3:05 am
Posts: 106
Yes, I agree. Let's start sharing some more code. It will benefit all.


Top
 Profile  
 
 Post subject: Re: Tank
PostPosted: Wed Dec 19, 2007 9:26 am 
Offline

Joined: Wed Nov 28, 2007 9:46 pm
Posts: 34
I don't have a problem posting some code snippets, just not our entire source code.

That's actually why I suggested the Box2D wiki, so we have a more organized place to put code snippets, tips, techniques, etc.

I have yet to talk to phervers about how he feels about posting code snippets from our project. I doubt he'll have a problem with it,
but courtesy demands we discuss it first.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 8 hours [ DST ]


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:
Powered by phpBB® Forum Software © phpBB Group