Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sponge

[java] Collision Detection

This topic is 5316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, does anybody know the game Liero? Well basically it''s like worms in real time. I''m thinking of writing a similar game for a project but im not sure how to write an effective collision detection algorithm, with lots of particles flying around. Particles don''t need to hit other particles, just the floor and the players. Any help would be appreciated...

Share this post


Link to post
Share on other sites
Advertisement
Also, which would be better for the bullets, a linked list or an array? i know an array limits my maximum number of objects but using a linked list could be slower during collision detection(?).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There are cases where an array would be faster, there are cases where a linked list would be faster.

If you need to do a lot of adding and deleting elements (which is indeed the case with bullets) use a linked list.

If you plan to add a bunch of elements, and they remain pretty much static (no items removed or deleted), for example maybe the players/clients logged in to your game, use an array.

Share this post


Link to post
Share on other sites
I''m assuming that you are building a game with oldschool style pixel graphics (and not using hardware acceleration). Implementing collisions depends on what you want to emphasize in the collisions events.

Classic way how old games do it is to use a collision mask image in addition to the level image data itself. In that case all collisions are done against the collision mask image, which can be even just a bitmask (one bit per pixel). With this method it is very easy to check if a coordinate mapped to a pixel is colliding with terrain or not. Even if you want to check collisions e.g. for high speed particles you can draw a line from current to new location and see if one of the pixels is colliding. This method makes it a bit harder to bounce particles and other things realistically from ground (to the right angle) but it''s still doable. If you want to make a terrain which can be modified e.g. by explosions or bullets, just update the collision mask while changing the level image data.

Modern way how the collisions might be implemented would be to construct collision volumes from polygons or other primitive objects (like boxes and spheres for example). Most efficient collision against data like this will require partitioning the space for a quick search to the nearest collision primitives, and perhaps doing quick elimination tests e.g. by bounding boxes or spheres to check if more fine collision should be tested against. This method makes it easy to do precise collisions and make correct bounces, but the implementation itself is much harder compared to the pixel collisions. Also modifiable terrain becomes an issue if you would like to support that.. (It''s possible but even more work.)

I made a 2D cave flying & shooting game back in 1996 called KOPS which uses pixel collisions etc. with a modifiable terrain. It''s not exactly a game like Liero, but goes almost in the same genre. After a few years the game was ported to Win & Linux, and last year I open sourced (GPL). Check out http://kops.sourceforge.net/ if you are interested. The source or implementation isn''t that pretty but some bits of it may still be interesting.


--
tonic - http://jet.ro

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!