-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorld.gd
59 lines (50 loc) · 1.32 KB
/
World.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
#func _ready():
# pass # Replace with function body.
var rot = 0
var is_rotating = 0;
var init_rot
var rot_speed = rad2deg(0.1) # 30 deg/sec
var final_rot
var idx = 0
onready var player = get_node("player")
func _process(delta):
if Input.is_action_just_pressed("rotate") and is_rotating == 0:
is_rotating = 1
init_rot = rot
final_rot = init_rot+deg2rad(90)
idx = idx-1
if idx == -1:
idx=3
if is_rotating == 1:
if rot < init_rot + deg2rad(90):
var delta_rot = rot_speed * delta
rot += delta_rot
rotate(delta_rot)
player.rotate(-delta_rot)
else:
rotate(final_rot - rot)
player.rotate(rot - final_rot)
is_rotating = 0
if Input.is_action_just_pressed("rotate_anti") and is_rotating == 0:
is_rotating = -1
init_rot = rot
final_rot = init_rot-deg2rad(90)
idx = (idx+1)%4
if is_rotating == -1:
if rot > init_rot - deg2rad(90):
var delta_rot = -rot_speed * delta
rot += delta_rot
rotate(delta_rot)
player.rotate(-delta_rot)
else:
rotate(final_rot - rot)
player.rotate(rot - final_rot)
is_rotating = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass