2015-05-12 13:17:09 +02:00
|
|
|
|
|
|
|
extends Sprite
|
|
|
|
|
2015-11-21 16:13:43 +01:00
|
|
|
# Member variables
|
|
|
|
const MODE_DIRECT = 0
|
|
|
|
const MODE_CONSTANT = 1
|
|
|
|
const MODE_SMOOTH = 2
|
2015-05-12 13:17:09 +02:00
|
|
|
|
|
|
|
const ROTATION_SPEED = 1
|
|
|
|
const SMOOTH_SPEED = 2.0
|
|
|
|
|
2015-11-21 16:13:43 +01:00
|
|
|
export(int, "Direct", "Constant", "Smooth") var mode = MODE_DIRECT
|
|
|
|
|
2015-05-12 13:17:09 +02:00
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
var mpos = get_viewport().get_mouse_pos()
|
|
|
|
|
2015-11-21 16:13:43 +01:00
|
|
|
if (mode == MODE_DIRECT):
|
2015-05-12 13:17:09 +02:00
|
|
|
look_at(mpos)
|
2015-11-21 16:13:43 +01:00
|
|
|
elif (mode == MODE_CONSTANT):
|
2015-05-12 13:17:09 +02:00
|
|
|
var ang = get_angle_to(mpos)
|
|
|
|
var s = sign(ang)
|
2015-11-21 16:13:43 +01:00
|
|
|
ang = abs(ang)
|
2015-05-12 13:17:09 +02:00
|
|
|
|
2015-11-21 16:13:43 +01:00
|
|
|
rotate(min(ang, ROTATION_SPEED*delta)*s)
|
|
|
|
elif (mode == MODE_SMOOTH):
|
|
|
|
var ang = get_angle_to(mpos)
|
2015-05-12 13:17:09 +02:00
|
|
|
|
2015-11-21 16:13:43 +01:00
|
|
|
rotate(ang*delta*SMOOTH_SPEED)
|
|
|
|
|
2015-05-12 13:17:09 +02:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
# Initialization here
|
|
|
|
set_process(true)
|