diff options
| author | David Luevano Alvarado <david@luevano.xyz> | 2022-05-31 03:49:28 -0600 |
|---|---|---|
| committer | David Luevano Alvarado <david@luevano.xyz> | 2022-05-31 03:49:28 -0600 |
| commit | bd197168c39551c3456099ed2a39375a8442483f (patch) | |
| tree | adeafb80b75e3566918f35141c2392af590897c3 /src/entities/actors/snake/head/head.gd | |
| parent | 2838046928db956b7712d24dfb63ee45fbc4d050 (diff) | |
working snake generation and path following, minor refactor
Diffstat (limited to 'src/entities/actors/snake/head/head.gd')
| -rw-r--r-- | src/entities/actors/snake/head/head.gd | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/entities/actors/snake/head/head.gd b/src/entities/actors/snake/head/head.gd deleted file mode 100644 index 96707b7..0000000 --- a/src/entities/actors/snake/head/head.gd +++ /dev/null @@ -1,34 +0,0 @@ -extends Node2D - -var speed: float = Global.SNAKE_SPEED -var rot_speed: float = Global.SNAKE_ROT_SPEED -var position_update_interval: float = Global.SNAKE_POSITION_UPDATE_INTERVAL - -var _direction: Vector2 = Vector2.UP -var _time_elapsed: float = 0.0 - - -func _ready(): - Event.emit_signal("new_curve_point", global_position) - - -func _process(delta: float) -> void: - if Input.is_action_pressed("move_left"): - # _direction = _direction.rotated(deg2rad(-ROT_SPEED)) - rotate(deg2rad(-rot_speed * delta)) - if Input.is_action_pressed("move_right"): - # _direction = _direction.rotated(deg2rad(ROT_SPEED)) - rotate(deg2rad(rot_speed * delta)) - - move_local_x(_direction.x * speed * delta) - move_local_y(_direction.y * speed * delta) - - _handle_time_elapsed(delta) - - -# using a timer is not recommended for < 0.01 -func _handle_time_elapsed(delta: float) -> void: - if _time_elapsed >= position_update_interval: - Event.emit_signal("new_curve_point", global_position) - _time_elapsed = 0.0 - _time_elapsed += delta |
