Page 1 of 1

Radar

PostPosted: Thu Apr 22, 2010 4:12 pm
by destinydesignlabs
Im working on making a game set in the age of intergalatic space travel, and I was wanting a radar on the ship, but I don't know how to do the scripts for it. Basically I was needing the radar to show enemyships when they get close to the ship. Does anyone know how this can be accomplished?

Re: Radar

PostPosted: Thu Apr 22, 2010 5:25 pm
by Thanx
You could have a Filled Region (not wire frame, because that's hallow) around your ship, as big as the range of the radar should be, so when enemies come, they should collide with it, and the collision event should trigger the radar drawing, make sure that the collision event repeats until the actors are out of collision. . The radar could be for instance a background image, with another actor you could call enemyradar. When an enemy is created, have an enemyradar also created, so each enemy actor clone has the appropriate enemyradar actor, with - this way - the same cloneindex as the enemy itself. So on collision with Filled Region the enemy makes its enemyradar visible (at creation its transp should be 1), and here's the hard part.
You need to fixate the width of the region, and the relative positions the incoming enemies may have (from all directions). Mathematically you should figure out how to convert that relative position to the relative position of enemyradar to the radar background... Which is something like this:
getclone(sprintf("enemyradar.%i", cloneindex))->x = radarbckg.x + (enemy.x - region.x)/ratio;
Or something like that... Same should be done with the y coordinate... Collision Finish should make the enemyradar.transp = 1; again
I think that's about it, correct me if the code isn't quite good! The ratio of the actors' sizes is for you to calculate ahead of time. Hope this helped! :wink:

Re: Radar

PostPosted: Thu Apr 22, 2010 7:22 pm
by destinydesignlabs
Thanks I will give it a shot when I get home. Ill let you know if it works right.