Sign in to follow this  
Instigator

Map for Tankz

Recommended Posts

I'm creating a 2D tank game which has 2 bitmap images representing each level. The first bitmap image has a grass background with trees and mountains (as obsticles). My second image is technically the same image as the first but with one main difference, it only has only 2 colors: Red repesents an obsticle while white represents grass, and thereby passable. This system is what I'm planning to use as a template for what my tanks can go through and what it can't. Is this a good way to check for collision in a 2D game WITHOUT using a tile based background? If it is, what library should I be looking at to work with images in C++. However, if this isn't the best way, what technique should I try?

Share this post


Link to post
Share on other sites
You could use geometric collision instead. Make a simple level editor that takes a level image and allows you to draw rectangles over it. It's pretty simple to collide a rectangle for the player with rectangles for the level.

Share this post


Link to post
Share on other sites
You could use a 'cookie cutter' method.

Basically, you render your tank to a buffer in the same way as you collision graph (i.e.black and white) then logically and together the pixels. If there is any 'white' in the resultant picture then there is a collision.

Try a google on 'cookie cutter collision' for a more detailed description.

Share this post


Link to post
Share on other sites
Alright, I think I'll try the cookie cutter method then. What format should my 2 images be in .png .bmp? Also, what library in C++ should I read up on that has a method like 'getpixelcolour(x,y)' .. so that I can see if a collision occurs?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this