online games, multiplayer games
Simcountry is an Online Digital World where you are the President of a country.
No download needed!
What is Simcountry?
Beginners Info
What is Simcountry?

Mobile land defenses (Fearless Blue)

Simcountry: Simcountry Bulletin Board  Mobile land defenses (Fearless Blue)

Alexander Larsson (Golden Rainbow)

Tuesday, February 01, 2005 - 10:16 pm Click here to edit this post
Using a radius of fire is very easy to do, but it might be heavy on the server.

struct sPosition
f32 x;
u32 y;

bool MayFire(sPosition& dest, sPosition& orig, f32 radius)
if sqrt((dest.x - orig.x)*(dest.x - orig.x) + (dest.y - orig.y)*(dest.y - orig.y)) >= radius)
return true;
return false;

Simply use the callback MayFire with all available arms. Crude but it works. Of course there are several improvements that can be made, quadtrees for instance. Enumerating location by location retrieving distance and then check the arms stationed there and lots of variations.

Not hard, but is the 1000 or so database transactions worth it?

Simcountry Introduction