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 | |
parent | 2838046928db956b7712d24dfb63ee45fbc4d050 (diff) |
working snake generation and path following, minor refactor
Diffstat (limited to 'src/entities/actors/snake/head')
-rw-r--r-- | src/entities/actors/snake/head/Head.tscn | 13 | ||||
-rw-r--r-- | src/entities/actors/snake/head/head.gd | 34 |
2 files changed, 0 insertions, 47 deletions
diff --git a/src/entities/actors/snake/head/Head.tscn b/src/entities/actors/snake/head/Head.tscn deleted file mode 100644 index a77cbef..0000000 --- a/src/entities/actors/snake/head/Head.tscn +++ /dev/null @@ -1,13 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://entities/actors/snake/sprites/head.png" type="Texture" id=1] -[ext_resource path="res://entities/actors/snake/head/head.gd" type="Script" id=2] - -[node name="HeadPoint" type="Node2D"] -script = ExtResource( 2 ) - -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 1 ) - -[node name="NextPivot" type="Node2D" parent="."] -position = Vector2( 0, 8 ) 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 |