Creating a 2D radar in 2D space

Started by
1 comment, last by Bluehair 20 years, 11 months ago
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));
Advertisement
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 )
Thanks for the alternative but ive figured out the cause of my problem.

This topic is closed to new replies.

Advertisement