Using chipmunk in "Golden Axe" alike game

Official forum for the Chipmunk2D Physics Library.
Post Reply
pachanga
Posts: 4
Joined: Tue Nov 08, 2011 4:21 am
Contact:

Using chipmunk in "Golden Axe" alike game

Post by pachanga »

Hi!

I'm about to start developing a 2D game where I'm planning to use chipmunk for collision detection of projectiles with other game entities. The game is going to be "Golden Axe" alike where characters may have different "depths" when standing on the ground.

Since there is no notion of "depth" available in chipmunk, I'm going to cheat a little: I'm planning not to use gravity for projectiles and entities, so they are going to be "floating" in the chipmunk space.

Entities will not be physically driven, body positions will be updated each frame. However, projectiles are going to be physically driven: I'm going to apply a force or an impulse or maybe a constant velocity to the projectile when it's shot.

I'm wondering if it's the right way to go or maybe there are any better alternatives. Thanks!
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Using chipmunk in "Golden Axe" alike game

Post by slembcke »

Well, if you don't actually want physics, Chipmunk is probably way overkill for you. Probably it would be unhelpful even as it doesn't even do the pseudo-3d you want anyway.

For a game like golden axe, you could very easily get away with using point sampling your projectiles against cylinders, ellipsoids or even just bounding boxes against the player. It's really easy to check if a point is inside of those shapes, and the projectiles don't move that fast. So just loop over all of the characters and check if a projectile is inside or not. Until you have thousands of characters and bullets onscreen, a few simple nested for loops are going to be the simplest and fastest thing you could do.

If you really wanted physics in your game (i.e. let Chipmunk update them instead of setting positions or velocities every frame) then you have a few options.

1) Only the ground plane in that game seems to be important. Jumping really just seems to be added in as a hack that allows you to dodge or use fancy melee attacks.

2) Do depth like Little Big Planet. You can move in and out of the screen, but only to three discrete layers. Chipmunk's layer bitmask would easily allow you to emulate that.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
pachanga
Posts: 4
Joined: Tue Nov 08, 2011 4:21 am
Contact:

Re: Using chipmunk in "Golden Axe" alike game

Post by pachanga »

Thanks a lot for the quick and helpful response!

To be honest with you, I was thinking of implementing a very simple collision subsystem but I hoped I wouldn't have to re-invent the wheel since it's all already nicely implemented in chipmunk :) Another concern was the fact I may need something more complicated in the future and again I it's probably already implemented in chipmunk.

Regarding possible options,

1) Well, yes, the ground plane is the most important one. I have even prototyped a bit projectiles and entities using chipmunk and it almost works as expected :) The gravity vector is 0. Entities and projectiles have circle shapes attached to bodies "floating" in the chipmunk space. Projectiles are spawned with some constant velocity and collision handlers are fired as expected. I mentioned "almost" since it's not perfect: a) There is some strange jitter of bodies once projectile collides with an entity (and, yes, I'm using fixed update step which equals to 1/120 sec) b) I may need to re-check but it looks like even with no gravity at all projectiles tend to gradually 'fall' down...

2) Thanks for the idea but discrete depth layers don't seem an option for me
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests