Map for Tankz

Started by
3 comments, last by Instigator 16 years, 1 month ago
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?
Advertisement
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.
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.
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?
Anyone??

This topic is closed to new replies.

Advertisement