Radar

Blitz3D Forums/Blitz3D Beginners Area/Radar

Myrmydon(Posted 2006) [#1]
Hi a am in code trouble yet again and i need help with the radar (sometimes referred to map in rts games such as Age of empires)


AJirenius(Posted 2006) [#2]
I guess the simpiest way to actually do a "radar" is to do like this. This is just a concept and not actual code so must translate it into your own code:

Create an empty image which will be the map.

RadarXSize = 80
RadarYSize = 80

PointX = (UnitXPosition/MapXSize)*RadarXSize
PointY = (UnitXPosition/MapXSize)*RadarXSize

Choose a nice colour for your unitpixel and:
Plot (PointX,PointY)

You will do exactly the same with all important radardata (buildings, environment) but some of this must not be updated all the time (maybe even once a game).

Hope you understand the concept beause it's actually harder to give you a working code as we don't know what your code looks like so far.

Plot (PointX,PointY)


Myrmydon(Posted 2006) [#3]
you mean something like this




Buggy(Posted 2006) [#4]
load images like this:

image = LoadImage("Cruise missile.bmp")


use them like this:

DrawImage image, PointX, PointY


Also, this should be in your main loop, as you probably want the radar updated every frame, but however you don't need to load the image every time you use it... just once. So your overall code should be something like this:

;Before the main loop...

radarImage = LoadImage("radar.bmp")
cruiseMissileImage = LoadImage("cruise missile.bmp")

RadarXSize = 80
RadarYSize = 80

;somewhere in your main loop...

PointX = ("cruisemissile"/MapXSize)*RadarXSize
PointY = ("cruisemissile"/MapXSize)*RadarXSize

DrawImage radarImage, 0, 0
DrawImage cruiseMissileImage, PointX, PointY


...or something to that effect. Hope that helps!


Myrmydon(Posted 2006) [#5]
I knew about the load image stuff but I was focusing on the radar portion of the code btw