- if event.is_action_pressed("player_left"):
- global_rotate(Vector3.UP, PI/2)
- elif event.is_action_pressed("player_right"):
- global_rotate(Vector3.UP, -PI/2)
-
-func _physics_process(delta: float) -> void:
- velocity = global_transform.basis.z * speed
- move_and_slide()
+ if _state == state.ALIVE:
+ if event.is_action_pressed(_input_map.left):
+ global_rotate(Vector3.UP, PI/2)
+ playerTurn.emit(self)
+ elif event.is_action_pressed(_input_map.right):
+ global_rotate(Vector3.UP, -PI/2)
+ playerTurn.emit(self)
+ else:
+ if event.is_action_pressed(_input_map.restart):
+ playerRestart.emit(self)
+
+
+func _physics_process(_delta: float) -> void:
+ if _state == state.ALIVE:
+ velocity = global_transform.basis.z * speed
+ move_and_slide()
+ if velocity.length() == 0:
+ _explode()
+
+
+func _explode() -> void:
+ _skin.visible = false
+ _state = state.DEAD
+ playerDestroyed.emit(self)
+
+
+func get_camera_rid() -> RID:
+ return _camera.get_camera_rid()
+
+
+func set_input_map(input_map) -> void:
+ _input_map = input_map