Archived

This topic is now archived and is closed to further replies.

Bluehair

Creating a 2D radar in 2D space

Recommended Posts

Im trying to create a simple radar for my space game, but I am having some problems. Ive got my angle and distance, and the radar works fine when either: player_x = enemy_x || player_y = enemy_y, but when both axis are not the same then the dot swirls around like a madman. Help greatfully appreciated. Here I have scaled the radar. 6000 is twice the size of the radar range (3000). temp = distance; temp = temp / 6000; temp = temp*100; This is where I find the x and y coordinates of the blip to be placed in the radar. new_x = 400 + (temp*cos(angle)); new_y = 530 - (temp*-sin(angle));

Share this post


Link to post
Share on other sites
Why exactly are you dealing with angles in a 2D space game? The radar should just be a scaled version of your space map.

The radar has its own coordinate system with the center (0,0) being located at the player. It also has some scale, say 10, so it can display 10 times the distance you see on screen. Then where to plot everything becomes simple.

Player goes at (0,0)
Objects go at ( (object.x-player.x)/scale , (object.y-player.y)/scale )

Share this post


Link to post
Share on other sites