Having a problem with SetRotation

BlitzMax Forums/BlitzMax Beginners Area/Having a problem with SetRotation

The value set with SetRotation affects all subsequent drawing commands. Best idea is to reset it to 0 before drawing text e.t.c

Here's an example of how to move your player in the direction you want.

Graphics 800,600,0

'make a sprite
Local player:TImage = CreateImage(32,32,1,DYNAMICIMAGE)
SetImageHandle player,16,16
DrawOval 0,0,32,32
SetLineWidth 3
SetColor 255,0,0
DrawLine 16,0,10,6
DrawLine 16,0,22,6
DrawLine 10,6,22,6
GrabImage player,0,0,0
SetColor 255,255,255


Local px#=400,py#=300,direction#=0
Local movespeed#=5.0
Local turnspeed#=4.0

While Not KeyDown(KEY_ESCAPE)

	If KeyDown(KEY_LEFT)
		direction:- turnspeed
		If direction<0 Then direction:+360 'stay within 0 to 360
	Else If KeyDown(KEY_RIGHT)
		direction:+ turnspeed
		If direction>360 Then direction:-360
	End If
	
	If KeyDown(KEY_UP)
		'use Sin & Cos to convert the angle in degrees to x,y translation values (a 2D Vector)
		px:+ Sin(direction)*movespeed
		py:- Cos(direction)*movespeed
	End If
	
	Cls
	
	'set the player direction
	SetRotation direction
	DrawImage player,px,py
	
	'reset rotation before drawing
	SetRotation 0
	DrawText("Look, I aint rotated! :)",0,0)
	
	Flip
Wend



Tom