Radar Rotate

Started by
3 comments, last by _Camus_ 14 years, 10 months ago
Hello, I was thinking how to make my enemies radar rotating by the Yaw of the camera, but the problem is: I can rotate the sprite texture of the radar but not the points of enemies together. So i thought maybe there is a thing in DirectX which allow you draw on a temp buffer, draw the sprite, then draw the points, and then rotate the whole buffer then draw it. Is there a such thing ? Thanks.
Advertisement
Ok, i seem to find a start point.

Rotate the sprite.

For the points in radar:

I take a point, create a line from the point to the center point on the radar.
Rotate that line by X degrees, the end of the line will be the new point.

But i have no clue on how to make this process with DirectX.

Could someone please help me ?

Thanks alot.
Actually you should do something like:

- calculate each radar blip position
- rotate the radar blips based on the player's rotation
- draw the radar
Wouldn't there be a way around this with multiplying the world defining matrix in a different order? Like Translate*Rotate*Scale or something?

If not your best solution is some mathematical equation based on radian movement.

=============================RhinoXNA - Easily start building 2D games in XNA!Projects

I did something like that time ago:

for(;max enemies;)
D3DXVECTOR2 dir = yourPos - enemiePos[];
D3DXMatrixTransformation2D(&Matrix,NULL,NULL,NULL,NULL,YAW_on_Radians,NULL);
SpriteObj->SetTransform(&Matrix);
D3DXVec2TransformCoord(&dir,&dir,&Matrix);
D3DXVECTOR2 FinalVect(dir.x+SCREENXOFFSET,dir.y+SCREENYOFFSET);
D3DXMatrixTransformation2D(&Matrix,&D3DXVECTOR2(0,0),0.0,NULL,NULL,0.0,&FinalVect);
SpriteObj->SetTransform(&Matrix);
DRAW YOUR ENEMY POINT ON THE RADAR

I mixed pseudo code and code because that are the directx 2d functions,
the variable YAW_on_Radians is the Yaw of your camera, yourPos are the
2D vector that represent your position, the enemiePos are the position of
each of your enemies, SCREENOFFSET for x and y are the offset of your screen
coordinates on pixels.

Hope that can help, my video with the radar:



the graphics part is not good, but the radar works =P

This topic is closed to new replies.

Advertisement