## Recommended Posts

yoni1993    122
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.

##### Share on other sites
yoni1993    122
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.

Thanks alot.

##### Share on other sites
EJH    315
Actually you should do something like:

- calculate each radar blip position
- rotate the radar blips based on the player's rotation
- draw the radar

##### Share on other sites
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.

##### Share on other sites
_Camus_    138
I did something like that time ago:

for(;max enemies;)
D3DXVECTOR2 dir = yourPos - enemiePos[];
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

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account