Page 1 of 1
2d "zone" detection
Posted: Thu Feb 16, 2012 11:41 pm
by Paradan
hi all,
for my little game demo I'm making I need to detect what kind of terrain the model is over. right now Im just making big invisible models and using the native collision detection. i was wondering if theres an easy way for me to make a B&W zone map and compare the models position to in order to trigger an event.
basically, are they standing in the mud?

Posted: Fri Feb 17, 2012 11:31 am
by Kjell
Hi Paradan,
How are you creating / generating your level / terrain? Is it one big texture, or are you using polygons as well?
There are a bunch of different techniques you can use for this .. which one is best depends a little on your situation.
One approach would be to use your terrain as height-map, and determine whether you're "in the mud" based on that. But you might want something with more precision / that's more controllable.
K
Posted: Sat Feb 18, 2012 1:25 am
by Paradan
im using one giant sprite thats in the OnRender of the ground model.
ive got an ortho cam active and the ground model is 1 unit below everything else. its the only map/level in the demo and player movement will be constrained to its boundaries.
Posted: Sat Feb 18, 2012 2:23 am
by Kjell
Hi Paradan,
Alright, the simplest method is probably to "mask" the terrain types using different alpha values. Then on loading the bitmap, you copy the values into a 2D array so they can be read easily by the player(s). Attached is a basic example.
K
Posted: Sat Feb 18, 2012 11:42 am
by Paradan
thank you.
thats exactly what I was looking for.
quick question:
switch(i)
{
case 1: fun;
break;
case 100: excitement;
break;
}
if i = 50 then you get excitement?
Posted: Sat Feb 18, 2012 11:58 am
by Kjell
Paradan wrote:if i = 50 then you get excitement?
No, if "i = 50" then it doesn't do anything. It will only do something when "i" is exactly 1 or 100 in your example.
K