#### Archived

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

# Creating a 2D radar in 2D space

This topic is 5534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
Thanks for the alternative but ive figured out the cause of my problem.

• 11
• 19
• 12
• 9
• 34
• ### Forum Statistics

• Total Topics
631398
• Total Posts
2999840
×