|
Terrain with masked bitmaps |
ingo
Member #6,576
November 2005
|
I would like to code a game that has Liero-style terrain destruction. (Think worms, scorched earth, etc). I get the theory behind what I am trying to do, I am just having trouble thinking about how to translate it into code. Maps have two bitmaps: the actual fresh, clean map that isn't touched, and the mask, that has the information about which pixels can be destroyed, solid, already empty, etc. To accomplish this, I need to be able to do this: I do not believe the magic pink color would not work for this method, because there will be multiple colors that I will be checking. Thank you for your help |
James Stanley
Member #7,275
May 2006
|
What do you mean by 'checking multiple colours'? EDIT: |
Kauhiz
Member #4,798
July 2004
|
Quote: Magic pink is invisible, so drawing that on to something will have no difference. Unless you use regular blit --- |
CGamesPlay
Member #2,559
July 2002
|
I used this post to help me, but it required a lot of changing. -- Ryan Patterson - <http://cgamesplay.com/> |
ingo
Member #6,576
November 2005
|
I know, you can only use the magic pink by default. This is why I am not asking anything about the built in functions. Like i said before, there will be the map that looks all pretty, and then a colored mask for that map. To explain in more detail, the colored mask has different colors to specify what's going on. For example, anything that is black is solid, anything that is grey is destroyable, anything that is red is insta-death, anything that is white is free space. I am horrible about explaining things, so here is a diagram i found: http://jnrdev.72dpiarmy.com/en/jnrdev5/files/1_bmp2map.gif that should pretty much explain it. See how the mask is multicolored? Basically i want to use the mask as a cookie cutter. Any pixel on the mask that is white, don't draw it when displaying the map. there are two bitmaps- a mask and a map. The map isn't manipulated at all at runtime, only the mask. Does this make more sense? Thank you for all your responses. |
CGamesPlay
Member #2,559
July 2002
|
Er, just use three bitmaps. Draw the entire terrain mask, and when you destroy terrain form that, blit the transparent mask color to it. Then blit the non-destroyable mask over the destroyable mask, that way one cannot destroy the non-destroyable mask. -- Ryan Patterson - <http://cgamesplay.com/> |
ingo
Member #6,576
November 2005
|
Thanks for the replies, but my main question still hasn't been answered (although I am getting some good extra information). So people understand, I'll try once more to see if this makes more sense on what I am asking. I have mask.bmp and map.bmp. They are the same size. How do I get map.bmp to only display what the mask wants? Here is that picture again: |
Matthew Dalrymple
Member #7,922
October 2006
|
The only way I can think of doing this would be to use putpixel and getpixel
I didn't compile that of course. I hope that's what you were looking for. =-----===-----===-----= |
ingo
Member #6,576
November 2005
|
Exactly what I was looking for, Matthew! Thanks a bunch. Also, thanks to all who inputted, you've given me solutions to other questions too. Cheers. |
gnolam
Member #2,030
March 2002
|
Quote: makecol(/*YOUR MASK COLOR HERE*/))
bitmap_mask_color() -- |
ingo
Member #6,576
November 2005
|
Yeah, I have a function called update_map() that does what Matt suggested. It is only called at the beginning, and then whenever I need the map to change. Thanks for the bitmap_mask_color() function. |
CGamesPlay
Member #2,559
July 2002
|
Quote: I have mask.bmp and map.bmp. They are the same size. How do I get map.bmp to only display what the mask wants? Okay, that was answered in my first post. But apparently you're happy with 3 FPS -- Ryan Patterson - <http://cgamesplay.com/> |
James Stanley
Member #7,275
May 2006
|
Quote: Unless you use regular blit If you use a regular blit you have to apply colour to the whole image. |
|