Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / SIN and COS Help making RADAR MAP that rotates all enemies around me

Author
Message
billy777
23
Years of Service
User Offline
Joined: 9th Jan 2003
Location:
Posted: 10th Jan 2003 04:45
I can make a simple radar map showing the "player" and all enemy positions, but not sure how to make a radar map that actually ROTATES depending on player's rotation/angle.

I know there's probably some SIN and COS in the code but i dont even know where to begin.

Im not even interested in depicting terrain in the map - I just want the player shown in the center of the map (just a white dot) and the enemies (shown as red dots) but the enemies need to rotate around player depending on players direction/angle/rotation.

Any sample code out there?

Thanks
Bill
The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 11th Jan 2003 01:05
I don't have any sample code, but it's a good enough challenge for me to write some. Bear with me, this could take a while.
Jam
23
Years of Service
User Offline
Joined: 20th Nov 2002
Location:
Posted: 11th Jan 2003 13:22
Have a look at this code - it is an early stage of a ship simulator I have been writing, and has radar like you described.



I have put in the whole program - all I have removed is the loading of textures, so all you need is the code

James

Shadow
23
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 11th Jan 2003 19:16
If you work out the overall distance of an enemy:

enemydist=sqrt(xdist^2+zdist^2)

and it's angle from you:

angle=atan(zdist/xdist)

You can position your radar dot like this:

dotX=enemydist*sin(angle)* radarsize * enemydist/maxrange
dotZ=enemydist*cos(angle)* radarsize * enemydist/maxrange

To change this so that it rotates:

angle=wrapvalue(atan(zdist/xdist)+playerangle)
billy777
23
Years of Service
User Offline
Joined: 9th Jan 2003
Location:
Posted: 17th Jan 2003 06:04
Thanks - I will try out that code

Login to post a reply

Server time is: 2026-06-09 10:56:16
Your offset time is: 2026-06-09 10:56:16