Преглед изворни кода

Turn liner as soon as key is hit

Increase game responsiveness and player feedback.
DricomDragon пре 5 година
родитељ
комит
532deb60f0
1 измењених фајлова са 4 додато и 4 уклоњено
  1. 4 4
      Player.gd

+ 4 - 4
Player.gd

@@ -56,9 +56,13 @@ func _ready():
 func _unhandled_input(event):
 	if event.is_pressed():
 		if event.is_action(turn_left_action):
+			tween.rotate_char(self, rotation_degrees - 90)
+
 			dire_delta = -1
 			get_tree().set_input_as_handled()
 		elif event.is_action(turn_right_action):
+			tween.rotate_char(self, rotation_degrees + 90)
+
 			dire_delta = 1
 			get_tree().set_input_as_handled()
 
@@ -83,15 +87,11 @@ func move():
 	generate_wall()
 
 	if dire_delta == -1 and !rayLeft.is_colliding():
-		tween.rotate_char(self, rotation_degrees - 90)
-
 		dire += dire_delta
 		if dire < 0:
 			dire = 3
 
 	elif dire_delta == 1 and !rayRight.is_colliding():
-		tween.rotate_char(self, rotation_degrees + 90)
-
 		dire += dire_delta
 		if dire > 3:
 			dire = 0