Object always facing the player?

BlitzMax Forums/BlitzMax Beginners Area/Object always facing the player?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Graphics 800,600,0,-1
Cls

DrawRect 0,0,50,10

Flip

Tank:TImage = CreateImage(50,10,1)
GrabImage(Tank,0,0)
MidHandleImage Tank


Global TX#,TY#
Global PX,PY
Global SpeedX#
Global SpeedY#
Global TSpeed# = 1.5

TX = 200
Ty = 200

While Not KeyHit(Key_Escape)
Cls

PX = MouseX()
PY = MouseY()


Local angle:Int = ATan2(TY-PY,TX-PX)

SpeedX = Cos(angle)*TSpeed 
SpeedY = Sin(Angle)*-TSpeed
TX:-SpeedX
TY:+SpeedY


SetRotation Angle
DrawImage Tank,Tx,Ty
SetRotation 0

Flip
Wend


I hope this will help you.