Jump to content
  • Advertisement
Sign in to follow this  
Instigator

Map for Tankz

This topic is 3780 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

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
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.

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
Sign in to follow this  

  • 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!