From 36874a535a3d5f7f2955f33e34aa1a4768b6fec1 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 4 Jun 2022 03:17:22 -0600 Subject: added hud for snake size and grow progress --- assets/ui/hud/grow_progress/over.aseprite | Bin 0 -> 447 bytes assets/ui/hud/grow_progress/over.png | Bin 0 -> 135 bytes assets/ui/hud/grow_progress/progress.aseprite | Bin 0 -> 450 bytes assets/ui/hud/grow_progress/progress.png | Bin 0 -> 120 bytes assets/ui/hud/grow_progress/under.aseprite | Bin 0 -> 437 bytes assets/ui/hud/grow_progress/under.png | Bin 0 -> 120 bytes assets/ui/hud/snake_hud/body.aseprite | Bin 0 -> 541 bytes assets/ui/hud/snake_hud/body.png | Bin 0 -> 127 bytes assets/ui/hud/snake_hud/body1.png | Bin 0 -> 105 bytes assets/ui/hud/snake_hud/body2.png | Bin 0 -> 105 bytes assets/ui/hud/snake_hud/body3.png | Bin 0 -> 105 bytes assets/ui/hud/snake_hud/head.aseprite | Bin 0 -> 667 bytes assets/ui/hud/snake_hud/head.png | Bin 0 -> 290 bytes assets/ui/hud/snake_hud/head1.png | Bin 0 -> 163 bytes assets/ui/hud/snake_hud/head2.png | Bin 0 -> 172 bytes assets/ui/hud/snake_hud/head3.png | Bin 0 -> 174 bytes assets/ui/hud/snake_hud/tail.aseprite | Bin 0 -> 430 bytes assets/ui/hud/snake_hud/tail.png | Bin 0 -> 107 bytes src/Main.tscn | 8 ++- src/entities/actors/snake/scripts/snake.gd | 24 ++++--- src/entities/food/scenes/Food.tscn | 16 ----- src/entities/food/scenes/FoodBasic.tscn | 16 +++++ src/entities/food/scenes/FoodManager.tscn | 4 +- src/entities/food/scripts/food.gd | 59 ++++++++++++++---- src/entities/food/scripts/food_basic.gd | 10 +++ src/entities/food/scripts/food_manager.gd | 19 +++--- src/event.gd | 7 ++- src/global.gd | 3 + src/project.godot | 6 ++ src/tools/score_manager/ScoreManager.tscn | 6 ++ src/tools/score_manager/score_manager.gd | 26 ++++++++ src/ui/UI.tscn | 27 +++++--- .../hud/progress_bars/scenes/GrowthProgress.tscn | 12 ++++ .../hud/progress_bars/scripts/growth_progress.gd | 10 +++ src/ui/hud/progress_bars/sprites/over.png | Bin 0 -> 135 bytes src/ui/hud/progress_bars/sprites/over.png.import | 35 +++++++++++ src/ui/hud/progress_bars/sprites/progress.png | Bin 0 -> 120 bytes .../hud/progress_bars/sprites/progress.png.import | 35 +++++++++++ src/ui/hud/progress_bars/sprites/under.png | Bin 0 -> 120 bytes src/ui/hud/progress_bars/sprites/under.png.import | 35 +++++++++++ src/ui/hud/snake/scenes/SnakeHUD.tscn | 12 ++++ src/ui/hud/snake/scenes/SnakeHead.tscn | 8 +++ src/ui/hud/snake/scenes/SnakeSegment.tscn | 5 ++ src/ui/hud/snake/scripts/snake_head.gd | 29 +++++++++ src/ui/hud/snake/scripts/snake_hud.gd | 69 +++++++++++++++++++++ src/ui/hud/snake/sprites/body.png | Bin 0 -> 127 bytes src/ui/hud/snake/sprites/body.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/body1.png | Bin 0 -> 105 bytes src/ui/hud/snake/sprites/body1.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/body2.png | Bin 0 -> 105 bytes src/ui/hud/snake/sprites/body2.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/body3.png | Bin 0 -> 105 bytes src/ui/hud/snake/sprites/body3.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/head.png | Bin 0 -> 290 bytes src/ui/hud/snake/sprites/head.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/head1.png | Bin 0 -> 163 bytes src/ui/hud/snake/sprites/head1.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/head2.png | Bin 0 -> 172 bytes src/ui/hud/snake/sprites/head2.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/head3.png | Bin 0 -> 174 bytes src/ui/hud/snake/sprites/head3.png.import | 35 +++++++++++ src/ui/hud/snake/sprites/tail.png | Bin 0 -> 107 bytes src/ui/hud/snake/sprites/tail.png.import | 35 +++++++++++ src/ui/ui.gd | 14 +---- 64 files changed, 738 insertions(+), 72 deletions(-) create mode 100644 assets/ui/hud/grow_progress/over.aseprite create mode 100644 assets/ui/hud/grow_progress/over.png create mode 100644 assets/ui/hud/grow_progress/progress.aseprite create mode 100644 assets/ui/hud/grow_progress/progress.png create mode 100644 assets/ui/hud/grow_progress/under.aseprite create mode 100644 assets/ui/hud/grow_progress/under.png create mode 100644 assets/ui/hud/snake_hud/body.aseprite create mode 100644 assets/ui/hud/snake_hud/body.png create mode 100644 assets/ui/hud/snake_hud/body1.png create mode 100644 assets/ui/hud/snake_hud/body2.png create mode 100644 assets/ui/hud/snake_hud/body3.png create mode 100644 assets/ui/hud/snake_hud/head.aseprite create mode 100644 assets/ui/hud/snake_hud/head.png create mode 100644 assets/ui/hud/snake_hud/head1.png create mode 100644 assets/ui/hud/snake_hud/head2.png create mode 100644 assets/ui/hud/snake_hud/head3.png create mode 100644 assets/ui/hud/snake_hud/tail.aseprite create mode 100644 assets/ui/hud/snake_hud/tail.png delete mode 100644 src/entities/food/scenes/Food.tscn create mode 100644 src/entities/food/scenes/FoodBasic.tscn create mode 100644 src/entities/food/scripts/food_basic.gd create mode 100644 src/tools/score_manager/ScoreManager.tscn create mode 100644 src/tools/score_manager/score_manager.gd create mode 100644 src/ui/hud/progress_bars/scenes/GrowthProgress.tscn create mode 100644 src/ui/hud/progress_bars/scripts/growth_progress.gd create mode 100644 src/ui/hud/progress_bars/sprites/over.png create mode 100644 src/ui/hud/progress_bars/sprites/over.png.import create mode 100644 src/ui/hud/progress_bars/sprites/progress.png create mode 100644 src/ui/hud/progress_bars/sprites/progress.png.import create mode 100644 src/ui/hud/progress_bars/sprites/under.png create mode 100644 src/ui/hud/progress_bars/sprites/under.png.import create mode 100644 src/ui/hud/snake/scenes/SnakeHUD.tscn create mode 100644 src/ui/hud/snake/scenes/SnakeHead.tscn create mode 100644 src/ui/hud/snake/scenes/SnakeSegment.tscn create mode 100644 src/ui/hud/snake/scripts/snake_head.gd create mode 100644 src/ui/hud/snake/scripts/snake_hud.gd create mode 100644 src/ui/hud/snake/sprites/body.png create mode 100644 src/ui/hud/snake/sprites/body.png.import create mode 100644 src/ui/hud/snake/sprites/body1.png create mode 100644 src/ui/hud/snake/sprites/body1.png.import create mode 100644 src/ui/hud/snake/sprites/body2.png create mode 100644 src/ui/hud/snake/sprites/body2.png.import create mode 100644 src/ui/hud/snake/sprites/body3.png create mode 100644 src/ui/hud/snake/sprites/body3.png.import create mode 100644 src/ui/hud/snake/sprites/head.png create mode 100644 src/ui/hud/snake/sprites/head.png.import create mode 100644 src/ui/hud/snake/sprites/head1.png create mode 100644 src/ui/hud/snake/sprites/head1.png.import create mode 100644 src/ui/hud/snake/sprites/head2.png create mode 100644 src/ui/hud/snake/sprites/head2.png.import create mode 100644 src/ui/hud/snake/sprites/head3.png create mode 100644 src/ui/hud/snake/sprites/head3.png.import create mode 100644 src/ui/hud/snake/sprites/tail.png create mode 100644 src/ui/hud/snake/sprites/tail.png.import diff --git a/assets/ui/hud/grow_progress/over.aseprite b/assets/ui/hud/grow_progress/over.aseprite new file mode 100644 index 0000000..cb1f08b Binary files /dev/null and b/assets/ui/hud/grow_progress/over.aseprite differ diff --git a/assets/ui/hud/grow_progress/over.png b/assets/ui/hud/grow_progress/over.png new file mode 100644 index 0000000..82714cf Binary files /dev/null and b/assets/ui/hud/grow_progress/over.png differ diff --git a/assets/ui/hud/grow_progress/progress.aseprite b/assets/ui/hud/grow_progress/progress.aseprite new file mode 100644 index 0000000..16a5fc2 Binary files /dev/null and b/assets/ui/hud/grow_progress/progress.aseprite differ diff --git a/assets/ui/hud/grow_progress/progress.png b/assets/ui/hud/grow_progress/progress.png new file mode 100644 index 0000000..0d9ba96 Binary files /dev/null and b/assets/ui/hud/grow_progress/progress.png differ diff --git a/assets/ui/hud/grow_progress/under.aseprite b/assets/ui/hud/grow_progress/under.aseprite new file mode 100644 index 0000000..2f78684 Binary files /dev/null and b/assets/ui/hud/grow_progress/under.aseprite differ diff --git a/assets/ui/hud/grow_progress/under.png b/assets/ui/hud/grow_progress/under.png new file mode 100644 index 0000000..8c8b269 Binary files /dev/null and b/assets/ui/hud/grow_progress/under.png differ diff --git a/assets/ui/hud/snake_hud/body.aseprite b/assets/ui/hud/snake_hud/body.aseprite new file mode 100644 index 0000000..6c39210 Binary files /dev/null and b/assets/ui/hud/snake_hud/body.aseprite differ diff --git a/assets/ui/hud/snake_hud/body.png b/assets/ui/hud/snake_hud/body.png new file mode 100644 index 0000000..8fb53c1 Binary files /dev/null and b/assets/ui/hud/snake_hud/body.png differ diff --git a/assets/ui/hud/snake_hud/body1.png b/assets/ui/hud/snake_hud/body1.png new file mode 100644 index 0000000..e2671b3 Binary files /dev/null and b/assets/ui/hud/snake_hud/body1.png differ diff --git a/assets/ui/hud/snake_hud/body2.png b/assets/ui/hud/snake_hud/body2.png new file mode 100644 index 0000000..0b82cd9 Binary files /dev/null and b/assets/ui/hud/snake_hud/body2.png differ diff --git a/assets/ui/hud/snake_hud/body3.png b/assets/ui/hud/snake_hud/body3.png new file mode 100644 index 0000000..9ba7c5a Binary files /dev/null and b/assets/ui/hud/snake_hud/body3.png differ diff --git a/assets/ui/hud/snake_hud/head.aseprite b/assets/ui/hud/snake_hud/head.aseprite new file mode 100644 index 0000000..7118215 Binary files /dev/null and b/assets/ui/hud/snake_hud/head.aseprite differ diff --git a/assets/ui/hud/snake_hud/head.png b/assets/ui/hud/snake_hud/head.png new file mode 100644 index 0000000..c2cd997 Binary files /dev/null and b/assets/ui/hud/snake_hud/head.png differ diff --git a/assets/ui/hud/snake_hud/head1.png b/assets/ui/hud/snake_hud/head1.png new file mode 100644 index 0000000..1d29792 Binary files /dev/null and b/assets/ui/hud/snake_hud/head1.png differ diff --git a/assets/ui/hud/snake_hud/head2.png b/assets/ui/hud/snake_hud/head2.png new file mode 100644 index 0000000..473f669 Binary files /dev/null and b/assets/ui/hud/snake_hud/head2.png differ diff --git a/assets/ui/hud/snake_hud/head3.png b/assets/ui/hud/snake_hud/head3.png new file mode 100644 index 0000000..c95b2d7 Binary files /dev/null and b/assets/ui/hud/snake_hud/head3.png differ diff --git a/assets/ui/hud/snake_hud/tail.aseprite b/assets/ui/hud/snake_hud/tail.aseprite new file mode 100644 index 0000000..ee70bec Binary files /dev/null and b/assets/ui/hud/snake_hud/tail.aseprite differ diff --git a/assets/ui/hud/snake_hud/tail.png b/assets/ui/hud/snake_hud/tail.png new file mode 100644 index 0000000..77f361d Binary files /dev/null and b/assets/ui/hud/snake_hud/tail.png differ diff --git a/src/Main.tscn b/src/Main.tscn index d633409..83f263d 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://entities/actors/snake/scenes/Snake.tscn" type="PackedScene" id=1] +[ext_resource path="res://tools/score_manager/ScoreManager.tscn" type="PackedScene" id=2] [ext_resource path="res://ui/UI.tscn" type="PackedScene" id=3] [ext_resource path="res://main.gd" type="Script" id=4] [ext_resource path="res://entities/food/scenes/FoodManager.tscn" type="PackedScene" id=5] @@ -14,6 +15,11 @@ script = ExtResource( 4 ) [node name="FoodManager" parent="." instance=ExtResource( 5 )] WORLD_GENERATOR_NP = NodePath("../WorldGenerator") +[node name="ScoreManager" parent="." instance=ExtResource( 2 )] + [node name="Snake" parent="." instance=ExtResource( 1 )] [node name="UI" parent="." instance=ExtResource( 3 )] +__meta__ = { +"_edit_horizontal_guides_": [ 8.0 ] +} diff --git a/src/entities/actors/snake/scripts/snake.gd b/src/entities/actors/snake/scripts/snake.gd index 01e09da..91e4e39 100644 --- a/src/entities/actors/snake/scripts/snake.gd +++ b/src/entities/actors/snake/scripts/snake.gd @@ -6,8 +6,8 @@ export(PackedScene) var TAIL_SEGMENT_NP: PackedScene onready var path: Path2D = $Path +var finished_adding_initial_segments: bool = false var current_body_segments: int = 0 -var max_body_initial_segments: int = 1 var body_segment_stack: Array var tail_segment: PathFollow2D # didn't konw how to name this, basically holds the current path lenght @@ -20,16 +20,17 @@ func _ready(): set_physics_process(false) set_process_input(false) Event.connect("snake_path_new_point", self, "_on_snake_path_new_point") + Event.connect("snake_add_new_segment", self, "_on_snake_add_new_segment") Event.connect("snake_added_new_segment", self, "_on_snake_added_new_segment") Event.connect("snake_added_initial_segments", self, "_on_snake_added_initial_segments") - Event.connect("food_eaten", self, "_on_food_eaten") + # Event.connect("food_eaten", self, "_on_food_eaten") # need to always set a new curve when ready, so when restarting it's af resh curve path.curve = Curve2D.new() func _physics_process(delta: float) -> void: - if body_segment_queue.size() != 0 and current_body_segments > max_body_initial_segments: + if body_segment_queue.size() != 0 and current_body_segments >= Global.SNAKE_INITIAL_SEGMENTS: _add_new_segment() # if body_segment_stack.size() > 0: @@ -75,6 +76,7 @@ func _add_initial_segment(type: PackedScene) -> void: tail_segment = _temp_body_segment path.add_child(_temp_body_segment) + # just to keep things going, tail shouldn't count as body segment current_body_segments += 1 Event.emit_signal("snake_added_new_segment", _temp_body_segment.TYPE) @@ -93,14 +95,17 @@ func _on_snake_path_new_point(coordinates: Vector2) -> void: # update call is to draw curve as there are new points to the path's curve # update() - if current_body_segments < max_body_initial_segments: - _add_initial_segment(BODY_SEGMENT_NP) - elif current_body_segments == max_body_initial_segments: - _add_initial_segment(TAIL_SEGMENT_NP) + if not finished_adding_initial_segments: + if current_body_segments < Global.SNAKE_INITIAL_SEGMENTS: + _add_initial_segment(BODY_SEGMENT_NP) + elif current_body_segments == Global.SNAKE_INITIAL_SEGMENTS: + _add_initial_segment(TAIL_SEGMENT_NP) func _on_snake_added_new_segment(type: String) -> void: if type == "tail": + current_body_segments -= 1 + finished_adding_initial_segments = true Event.emit_signal("snake_added_initial_segments") @@ -109,5 +114,6 @@ func _on_snake_added_initial_segments() -> void: set_process_input(true) -func _on_food_eaten(type: int, location: Vector2) -> void: - _add_segment_to_queue() +func _on_snake_add_new_segment(amount: int) -> void: + for i in amount: + _add_segment_to_queue() diff --git a/src/entities/food/scenes/Food.tscn b/src/entities/food/scenes/Food.tscn deleted file mode 100644 index 7accbc6..0000000 --- a/src/entities/food/scenes/Food.tscn +++ /dev/null @@ -1,16 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://entities/food/scripts/food.gd" type="Script" id=2] - -[sub_resource type="CircleShape2D" id=1] -radius = 4.0 - -[node name="Food" type="Area2D"] -collision_layer = 256 -collision_mask = 0 -script = ExtResource( 2 ) - -[node name="Sprite" type="Sprite" parent="."] - -[node name="Collision" type="CollisionShape2D" parent="."] -shape = SubResource( 1 ) diff --git a/src/entities/food/scenes/FoodBasic.tscn b/src/entities/food/scenes/FoodBasic.tscn new file mode 100644 index 0000000..5a4474e --- /dev/null +++ b/src/entities/food/scenes/FoodBasic.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://entities/food/scripts/food_basic.gd" type="Script" id=1] + +[sub_resource type="CircleShape2D" id=1] +radius = 4.0 + +[node name="FoodBasic" type="Area2D"] +collision_layer = 256 +collision_mask = 0 +script = ExtResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] + +[node name="Collision" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) diff --git a/src/entities/food/scenes/FoodManager.tscn b/src/entities/food/scenes/FoodManager.tscn index 3287271..e56b9de 100644 --- a/src/entities/food/scenes/FoodManager.tscn +++ b/src/entities/food/scenes/FoodManager.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://entities/food/scenes/Food.tscn" type="PackedScene" id=1] +[ext_resource path="res://entities/food/scenes/FoodBasic.tscn" type="PackedScene" id=1] [ext_resource path="res://entities/food/scripts/food_manager.gd" type="Script" id=2] [node name="FoodManager" type="Node2D"] script = ExtResource( 2 ) -FOOD = ExtResource( 1 ) +FOOD_BASIC = ExtResource( 1 ) diff --git a/src/entities/food/scripts/food.gd b/src/entities/food/scripts/food.gd index e8b0261..2e00978 100644 --- a/src/entities/food/scripts/food.gd +++ b/src/entities/food/scripts/food.gd @@ -1,24 +1,59 @@ class_name Food extends Area2D -enum Type { - APPLE -} +onready var _sprite: Sprite = $Sprite -var _type_texture: Dictionary = { - Type.APPLE: preload("res://entities/food/sprites/apple.png") -} +var texture: Dictionary +var timer: Timer -export(Type) var TYPE -onready var _sprite: Sprite = $Sprite -var location: Vector2 +var properties: Dictionary +var points: int = 1 +var time_to_live: float = -1.0 func _ready(): + randomize_stats() + _set_properties() + timer = Timer.new() + timer.one_shot = true + + timer.connect("timeout", self, "_on_timer_timeout") connect("body_entered", self, "_on_body_entered") - _sprite.texture = _type_texture[TYPE] + + +func set_type(type: int) -> void: + set_property("type", type) + _sprite.texture = texture[type] + + +func set_location(loc: Vector2) -> void: + set_property("location", loc) + + +func set_timer(time: float) -> void: + time_to_live = time + if time_to_live != -1.0: + timer.wait_time = time_to_live + timer.start() + + +func set_property(property: String, value) -> void: + properties[property] = value + + +func _set_properties() -> void: + set_property("points", points) + + +func randomize_stats() -> void: + points = int(rand_range(1, 30)) func _on_body_entered(body: Node) -> void: - Event.emit_signal("food_eaten", TYPE, location) - queue_free() \ No newline at end of file + Event.emit_signal("food_eaten", properties) + queue_free() + + +func _on_timer_timeout() -> void: + Event.emit_signal("food_timed_out", properties) + queue_free() diff --git a/src/entities/food/scripts/food_basic.gd b/src/entities/food/scripts/food_basic.gd new file mode 100644 index 0000000..0a56208 --- /dev/null +++ b/src/entities/food/scripts/food_basic.gd @@ -0,0 +1,10 @@ +class_name FoodBasic +extends Food + +enum Type { + APPLE +} + + +func _ready(): + texture[Type.APPLE] = preload("res://entities/food/sprites/apple.png") \ No newline at end of file diff --git a/src/entities/food/scripts/food_manager.gd b/src/entities/food/scripts/food_manager.gd index 426677c..4196806 100644 --- a/src/entities/food/scripts/food_manager.gd +++ b/src/entities/food/scripts/food_manager.gd @@ -1,7 +1,7 @@ class_name FoodManager extends Node2D -export(PackedScene) var FOOD: PackedScene +export(PackedScene) var FOOD_BASIC: PackedScene export(NodePath) var WORLD_GENERATOR_NP: NodePath onready var world_generator: Node2D = get_node(WORLD_GENERATOR_NP) onready var possible_food_locations: Array = world_generator.get_valid_map_coords() @@ -21,17 +21,21 @@ func _process(delta) -> void: func _place_new_food() -> void: - var food: Area2D = FOOD.instance() - Event.emit_signal("food_placing_new_food", food.TYPE) + var food: FoodBasic = FOOD_BASIC.instance() + var type: int = FoodBasic.Type.APPLE + Event.emit_signal("food_placing_new_food", type) var pos_loc: Array = _get_random_pos() var pos: Vector2 = pos_loc[0] var loc: Vector2 = pos_loc[1] + # need to set the position first, else it will spawn on the middle and the moved food.global_position = pos - food.location = loc add_child(food) + food.set_type(FoodBasic.Type.APPLE) + food.set_location(loc) + food.properties["points"] = 1 current_food.append(loc) - Event.emit_signal("food_placed_new_food", food.TYPE, loc) + Event.emit_signal("food_placed_new_food", food.properties["type"], food.properties["location"]) func _get_random_pos() -> Array: @@ -40,7 +44,6 @@ func _get_random_pos() -> Array: var location: Vector2 while not found_valid_loc: - print("trying") index = randi() % possible_food_locations.size() location = possible_food_locations[index] if current_food.find(location) == -1: @@ -49,6 +52,6 @@ func _get_random_pos() -> Array: return [world_generator.get_centered_world_position(location), location] -func _on_food_eaten(type: int, location: Vector2) -> void: - var index: int = current_food.find(location) +func _on_food_eaten(properties: Dictionary) -> void: + var index: int = current_food.find(properties["location"]) current_food.remove(index) diff --git a/src/event.gd b/src/event.gd index 054781f..991b0e2 100644 --- a/src/event.gd +++ b/src/event.gd @@ -4,17 +4,20 @@ signal game_start signal game_over signal snake_path_new_point(coordinates) +signal snake_add_new_segment(amount) signal snake_adding_new_segment(type) signal snake_added_new_segment(type) signal snake_added_initial_segments signal snake_segment_body_entered(body) signal snake_rotated +signal snake_growth_progress(progress) signal food_placing_new_food(type) signal food_placed_new_food(type, location) -signal food_eaten(type, location) +signal food_eaten(properties) +signal food_timed_out(properties) signal world_gen_walker_started(id) signal world_gen_walker_finished(id) signal world_gen_walker_died(id) -signal world_gen_spawn_walker_unit(location) \ No newline at end of file +signal world_gen_spawn_walker_unit(location) diff --git a/src/global.gd b/src/global.gd index 72cb294..1ed4d29 100644 --- a/src/global.gd +++ b/src/global.gd @@ -5,8 +5,11 @@ var TILE_SIZE: int = 16 var WORLD_TILE_PATH: int = 0 var WORLD_TILE_WALL: int = 1 +var SNAKE_INITIAL_SEGMENTS: int = 1 var SNAKE_SPEED: float = 50.0 var SNAKE_ROT_SPEED: float = 300.0 var SNAKE_POSITION_UPDATE_INTERVAL: float = 0.001 # this usually corresponds to the sprite size var SNAKE_SEGMENT_SIZE: float = 6.0 + +var POINTS_TO_GROW: int = 10 diff --git a/src/project.godot b/src/project.godot index 9319699..159bfd5 100644 --- a/src/project.godot +++ b/src/project.godot @@ -14,6 +14,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://entities/food/scripts/food.gd" }, { +"base": "Food", +"class": "FoodBasic", +"language": "GDScript", +"path": "res://entities/food/scripts/food_basic.gd" +}, { "base": "Node2D", "class": "FoodManager", "language": "GDScript", @@ -51,6 +56,7 @@ _global_script_classes=[ { } ] _global_script_class_icons={ "Food": "", +"FoodBasic": "", "FoodManager": "", "GifDecoder": "", "GifRecorder": "res://addons/GifMaker/gif.svg", diff --git a/src/tools/score_manager/ScoreManager.tscn b/src/tools/score_manager/ScoreManager.tscn new file mode 100644 index 0000000..136b294 --- /dev/null +++ b/src/tools/score_manager/ScoreManager.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://tools/score_manager/score_manager.gd" type="Script" id=1] + +[node name="ScoreManager" type="Node2D"] +script = ExtResource( 1 ) diff --git a/src/tools/score_manager/score_manager.gd b/src/tools/score_manager/score_manager.gd new file mode 100644 index 0000000..3b5ddba --- /dev/null +++ b/src/tools/score_manager/score_manager.gd @@ -0,0 +1,26 @@ +extends Node + + +var score: int = 0 +var growth: int = 0 + + +func _ready(): + Event.connect("food_eaten", self, "_on_food_eaten") + + +func _on_food_eaten(properties: Dictionary) -> void: + var points: int = properties["points"] + var score_to_grow: int = (growth + 1) * Global.POINTS_TO_GROW - score + var amount_to_grow: int = 0 + score += points + if points >= score_to_grow: + amount_to_grow += 1 + points -= score_to_grow + # maybe be careful with this + amount_to_grow += points / Global.POINTS_TO_GROW + growth += amount_to_grow + Event.emit_signal("snake_add_new_segment", amount_to_grow) + + score_to_grow = Global.POINTS_TO_GROW - ((growth + 1) * Global.POINTS_TO_GROW - score) + Event.emit_signal("snake_growth_progress", score_to_grow) diff --git a/src/ui/UI.tscn b/src/ui/UI.tscn index 207a5fa..14701f0 100644 --- a/src/ui/UI.tscn +++ b/src/ui/UI.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://ui/ui.gd" type="Script" id=1] -[ext_resource path="res://fonts/MonogramExtended.tres" type="DynamicFont" id=2] +[ext_resource path="res://ui/hud/snake/scenes/SnakeHUD.tscn" type="PackedScene" id=3] +[ext_resource path="res://ui/hud/progress_bars/scenes/GrowthProgress.tscn" type="PackedScene" id=4] [node name="UI" type="CanvasLayer"] script = ExtResource( 1 ) @@ -11,19 +12,27 @@ anchor_right = 1.0 anchor_bottom = 1.0 [node name="StatsHUD" type="MarginContainer" parent="Root"] -margin_left = 10.0 -margin_top = 10.0 -margin_right = 130.0 -margin_bottom = 50.0 +margin_left = 4.0 +margin_top = 4.0 +margin_right = 124.0 +margin_bottom = 44.0 [node name="VBox" type="VBoxContainer" parent="Root/StatsHUD"] margin_right = 120.0 margin_bottom = 40.0 -[node name="SnakeSize" type="Label" parent="Root/StatsHUD/VBox"] +[node name="SnakeHUD" parent="Root/StatsHUD/VBox" instance=ExtResource( 3 )] margin_right = 120.0 -margin_bottom = 13.0 -custom_fonts/font = ExtResource( 2 ) +margin_bottom = 8.0 + +[node name="HBoxProgressBars" type="HBoxContainer" parent="Root/StatsHUD/VBox"] +margin_top = 12.0 +margin_right = 120.0 +margin_bottom = 20.0 + +[node name="GrowthProgress" parent="Root/StatsHUD/VBox/HBoxProgressBars" instance=ExtResource( 4 )] +margin_right = 40.0 +margin_bottom = 8.0 [node name="MarginContainer" type="MarginContainer" parent="Root"] anchor_top = 1.0 diff --git a/src/ui/hud/progress_bars/scenes/GrowthProgress.tscn b/src/ui/hud/progress_bars/scenes/GrowthProgress.tscn new file mode 100644 index 0000000..0a0d9a8 --- /dev/null +++ b/src/ui/hud/progress_bars/scenes/GrowthProgress.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://ui/hud/progress_bars/sprites/progress.png" type="Texture" id=1] +[ext_resource path="res://ui/hud/progress_bars/sprites/over.png" type="Texture" id=2] +[ext_resource path="res://ui/hud/progress_bars/sprites/under.png" type="Texture" id=3] +[ext_resource path="res://ui/hud/progress_bars/scripts/growth_progress.gd" type="Script" id=4] + +[node name="GrowthProgress" type="TextureProgress"] +texture_under = ExtResource( 3 ) +texture_over = ExtResource( 2 ) +texture_progress = ExtResource( 1 ) +script = ExtResource( 4 ) diff --git a/src/ui/hud/progress_bars/scripts/growth_progress.gd b/src/ui/hud/progress_bars/scripts/growth_progress.gd new file mode 100644 index 0000000..a9d455c --- /dev/null +++ b/src/ui/hud/progress_bars/scripts/growth_progress.gd @@ -0,0 +1,10 @@ +extends TextureProgress + + +func _ready(): + Event.connect("snake_growth_progress", self, "_on_snake_growth_progress") + max_value = Global.POINTS_TO_GROW + + +func _on_snake_growth_progress(progress: int) -> void: + value = progress diff --git a/src/ui/hud/progress_bars/sprites/over.png b/src/ui/hud/progress_bars/sprites/over.png new file mode 100644 index 0000000..82714cf Binary files /dev/null and b/src/ui/hud/progress_bars/sprites/over.png differ diff --git a/src/ui/hud/progress_bars/sprites/over.png.import b/src/ui/hud/progress_bars/sprites/over.png.import new file mode 100644 index 0000000..6dab18d --- /dev/null +++ b/src/ui/hud/progress_bars/sprites/over.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/over.png-0642cc73272ad1f8af9be593e496f68d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/progress_bars/sprites/over.png" +dest_files=[ "res://.import/over.png-0642cc73272ad1f8af9be593e496f68d.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/progress_bars/sprites/progress.png b/src/ui/hud/progress_bars/sprites/progress.png new file mode 100644 index 0000000..0d9ba96 Binary files /dev/null and b/src/ui/hud/progress_bars/sprites/progress.png differ diff --git a/src/ui/hud/progress_bars/sprites/progress.png.import b/src/ui/hud/progress_bars/sprites/progress.png.import new file mode 100644 index 0000000..342daaf --- /dev/null +++ b/src/ui/hud/progress_bars/sprites/progress.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/progress.png-30af99e69a9aa36165f02ed64d480a2f.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/progress_bars/sprites/progress.png" +dest_files=[ "res://.import/progress.png-30af99e69a9aa36165f02ed64d480a2f.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/progress_bars/sprites/under.png b/src/ui/hud/progress_bars/sprites/under.png new file mode 100644 index 0000000..8c8b269 Binary files /dev/null and b/src/ui/hud/progress_bars/sprites/under.png differ diff --git a/src/ui/hud/progress_bars/sprites/under.png.import b/src/ui/hud/progress_bars/sprites/under.png.import new file mode 100644 index 0000000..c6f0d16 --- /dev/null +++ b/src/ui/hud/progress_bars/sprites/under.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/under.png-2db90a564085e100d8ec82ea8500cf5d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/progress_bars/sprites/under.png" +dest_files=[ "res://.import/under.png-2db90a564085e100d8ec82ea8500cf5d.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/scenes/SnakeHUD.tscn b/src/ui/hud/snake/scenes/SnakeHUD.tscn new file mode 100644 index 0000000..4b33885 --- /dev/null +++ b/src/ui/hud/snake/scenes/SnakeHUD.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://ui/hud/snake/scenes/SnakeHead.tscn" type="PackedScene" id=1] +[ext_resource path="res://ui/hud/snake/scripts/snake_hud.gd" type="Script" id=2] +[ext_resource path="res://ui/hud/snake/sprites/head1.png" type="Texture" id=3] + +[node name="SnakeHUD" type="HBoxContainer"] +custom_constants/separation = 0 +script = ExtResource( 2 ) + +[node name="SnakeHead" parent="." instance=ExtResource( 1 )] +texture = ExtResource( 3 ) diff --git a/src/ui/hud/snake/scenes/SnakeHead.tscn b/src/ui/hud/snake/scenes/SnakeHead.tscn new file mode 100644 index 0000000..79eb7d1 --- /dev/null +++ b/src/ui/hud/snake/scenes/SnakeHead.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/hud/snake/scripts/snake_head.gd" type="Script" id=1] + +[node name="SnakeHead" type="TextureRect"] +margin_right = 8.0 +margin_bottom = 8.0 +script = ExtResource( 1 ) diff --git a/src/ui/hud/snake/scenes/SnakeSegment.tscn b/src/ui/hud/snake/scenes/SnakeSegment.tscn new file mode 100644 index 0000000..069a812 --- /dev/null +++ b/src/ui/hud/snake/scenes/SnakeSegment.tscn @@ -0,0 +1,5 @@ +[gd_scene format=2] + +[node name="SnakeSegment" type="TextureRect"] +margin_right = 4.0 +margin_bottom = 4.0 diff --git a/src/ui/hud/snake/scripts/snake_head.gd b/src/ui/hud/snake/scripts/snake_head.gd new file mode 100644 index 0000000..a414e23 --- /dev/null +++ b/src/ui/hud/snake/scripts/snake_head.gd @@ -0,0 +1,29 @@ +extends TextureRect + +enum { + IDLE, + EAT, + DEAD +} + +var frames = { + IDLE: preload("res://ui/hud/snake/sprites/head1.png"), + EAT: preload("res://ui/hud/snake/sprites/head2.png"), + DEAD: preload("res://ui/hud/snake/sprites/head3.png") +} + + +func _ready(): + texture = frames[IDLE] + Event.connect("food_eaten", self, "_on_food_eaten") + Event.connect("game_over", self, "_on_game_over") + + +func _on_food_eaten(properties: Dictionary) -> void: + texture = frames[EAT] + yield(get_tree().create_timer(0.25), "timeout") + texture = frames[IDLE] + + +func _on_game_over() -> void: + texture = frames[DEAD] \ No newline at end of file diff --git a/src/ui/hud/snake/scripts/snake_hud.gd b/src/ui/hud/snake/scripts/snake_hud.gd new file mode 100644 index 0000000..b50b72e --- /dev/null +++ b/src/ui/hud/snake/scripts/snake_hud.gd @@ -0,0 +1,69 @@ +extends HBoxContainer + +enum { + BODY1, + BODY2, + BODY3, + TAIL +} + +var frames: Dictionary = { + BODY1: preload("res://ui/hud/snake/sprites/body1.png"), + BODY2: preload("res://ui/hud/snake/sprites/body2.png"), + BODY3: preload("res://ui/hud/snake/sprites/body3.png"), + TAIL: preload("res://ui/hud/snake/sprites/tail.png") +} + +var last_tail_index: int = -1 +var last_frame: int = -1 +var frame_direction: int = 1 + + +func _ready(): + Event.connect("snake_added_new_segment", self, "_on_snake_added_new_segment") + + +func _on_snake_added_new_segment(type: String) -> void: + match type: + "body": + _add_body_frame() + _move_tail_frame() + "tail": + _add_tail_frame() + + +func _add_body_frame() -> void: + var texture_rect: TextureRect = TextureRect.new() + texture_rect.texture = frames[_get_next_body_frame()] + add_child(texture_rect) + + +func _add_tail_frame() -> void: + var texture_rect: TextureRect = TextureRect.new() + texture_rect.texture = frames[TAIL] + add_child(texture_rect) + last_tail_index = get_child_count() - 1 + + +func _move_tail_frame() -> void: + var child_count: int = get_child_count() + if child_count > Global.SNAKE_INITIAL_SEGMENTS + 1: + var last_child: TextureRect = get_child(last_tail_index) + move_child(last_child, child_count - 1) + last_tail_index = child_count - 1 + + +func _get_next_body_frame() -> int: + match last_frame: + -1: + last_frame = BODY2 + BODY2: + last_frame += frame_direction + BODY3: + frame_direction = -1 + last_frame += frame_direction + BODY1: + frame_direction = 1 + last_frame += frame_direction + + return last_frame diff --git a/src/ui/hud/snake/sprites/body.png b/src/ui/hud/snake/sprites/body.png new file mode 100644 index 0000000..8fb53c1 Binary files /dev/null and b/src/ui/hud/snake/sprites/body.png differ diff --git a/src/ui/hud/snake/sprites/body.png.import b/src/ui/hud/snake/sprites/body.png.import new file mode 100644 index 0000000..3891d75 --- /dev/null +++ b/src/ui/hud/snake/sprites/body.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/body.png-cd3faf610a4d26eadd0148f5ade8a21a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/body.png" +dest_files=[ "res://.import/body.png-cd3faf610a4d26eadd0148f5ade8a21a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/body1.png b/src/ui/hud/snake/sprites/body1.png new file mode 100644 index 0000000..e2671b3 Binary files /dev/null and b/src/ui/hud/snake/sprites/body1.png differ diff --git a/src/ui/hud/snake/sprites/body1.png.import b/src/ui/hud/snake/sprites/body1.png.import new file mode 100644 index 0000000..9573e97 --- /dev/null +++ b/src/ui/hud/snake/sprites/body1.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/body1.png-5d85028b95914799a2aebc60349a56c2.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/body1.png" +dest_files=[ "res://.import/body1.png-5d85028b95914799a2aebc60349a56c2.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/body2.png b/src/ui/hud/snake/sprites/body2.png new file mode 100644 index 0000000..0b82cd9 Binary files /dev/null and b/src/ui/hud/snake/sprites/body2.png differ diff --git a/src/ui/hud/snake/sprites/body2.png.import b/src/ui/hud/snake/sprites/body2.png.import new file mode 100644 index 0000000..17356a4 --- /dev/null +++ b/src/ui/hud/snake/sprites/body2.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/body2.png-01a5c5dad5a83f4d4d299b857c658e39.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/body2.png" +dest_files=[ "res://.import/body2.png-01a5c5dad5a83f4d4d299b857c658e39.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/body3.png b/src/ui/hud/snake/sprites/body3.png new file mode 100644 index 0000000..9ba7c5a Binary files /dev/null and b/src/ui/hud/snake/sprites/body3.png differ diff --git a/src/ui/hud/snake/sprites/body3.png.import b/src/ui/hud/snake/sprites/body3.png.import new file mode 100644 index 0000000..bfa7791 --- /dev/null +++ b/src/ui/hud/snake/sprites/body3.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/body3.png-5bcd745ab0fc40d3e8ef2d150e7b7d4d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/body3.png" +dest_files=[ "res://.import/body3.png-5bcd745ab0fc40d3e8ef2d150e7b7d4d.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/head.png b/src/ui/hud/snake/sprites/head.png new file mode 100644 index 0000000..c2cd997 Binary files /dev/null and b/src/ui/hud/snake/sprites/head.png differ diff --git a/src/ui/hud/snake/sprites/head.png.import b/src/ui/hud/snake/sprites/head.png.import new file mode 100644 index 0000000..5b9b768 --- /dev/null +++ b/src/ui/hud/snake/sprites/head.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/head.png-4b4fedad924e66f19c046d3ce4c1b58a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/head.png" +dest_files=[ "res://.import/head.png-4b4fedad924e66f19c046d3ce4c1b58a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/head1.png b/src/ui/hud/snake/sprites/head1.png new file mode 100644 index 0000000..1d29792 Binary files /dev/null and b/src/ui/hud/snake/sprites/head1.png differ diff --git a/src/ui/hud/snake/sprites/head1.png.import b/src/ui/hud/snake/sprites/head1.png.import new file mode 100644 index 0000000..72d345d --- /dev/null +++ b/src/ui/hud/snake/sprites/head1.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/head1.png-b86145ede399b444d822e7b0ec71dada.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/head1.png" +dest_files=[ "res://.import/head1.png-b86145ede399b444d822e7b0ec71dada.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/head2.png b/src/ui/hud/snake/sprites/head2.png new file mode 100644 index 0000000..473f669 Binary files /dev/null and b/src/ui/hud/snake/sprites/head2.png differ diff --git a/src/ui/hud/snake/sprites/head2.png.import b/src/ui/hud/snake/sprites/head2.png.import new file mode 100644 index 0000000..78c9241 --- /dev/null +++ b/src/ui/hud/snake/sprites/head2.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/head2.png-565eeac8eb1428ec8155a0982d857bb6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/head2.png" +dest_files=[ "res://.import/head2.png-565eeac8eb1428ec8155a0982d857bb6.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/head3.png b/src/ui/hud/snake/sprites/head3.png new file mode 100644 index 0000000..c95b2d7 Binary files /dev/null and b/src/ui/hud/snake/sprites/head3.png differ diff --git a/src/ui/hud/snake/sprites/head3.png.import b/src/ui/hud/snake/sprites/head3.png.import new file mode 100644 index 0000000..e51f75c --- /dev/null +++ b/src/ui/hud/snake/sprites/head3.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/head3.png-e8a18efff02063d9a43d2babeb798767.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/head3.png" +dest_files=[ "res://.import/head3.png-e8a18efff02063d9a43d2babeb798767.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/hud/snake/sprites/tail.png b/src/ui/hud/snake/sprites/tail.png new file mode 100644 index 0000000..77f361d Binary files /dev/null and b/src/ui/hud/snake/sprites/tail.png differ diff --git a/src/ui/hud/snake/sprites/tail.png.import b/src/ui/hud/snake/sprites/tail.png.import new file mode 100644 index 0000000..fd6334d --- /dev/null +++ b/src/ui/hud/snake/sprites/tail.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/tail.png-292b09567a886543da0b95c4d3dfad3c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/hud/snake/sprites/tail.png" +dest_files=[ "res://.import/tail.png-292b09567a886543da0b95c4d3dfad3c.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/ui/ui.gd b/src/ui/ui.gd index 8132d52..1ceff2f 100644 --- a/src/ui/ui.gd +++ b/src/ui/ui.gd @@ -1,26 +1,14 @@ class_name UI extends CanvasLayer -onready var _snake_size_label: Label = $Root/StatsHUD/VBox/SnakeSize onready var _start_button: Button = $Root/MarginContainer/CenterContainer/Start -var snake_size: int = 0 -var _snake_size_fmt: String = "Snake size: %s" - func _ready(): - Event.connect("snake_added_new_segment", self, "_on_Snake_added_new_segment") - _snake_size_label.text =_snake_size_fmt % snake_size - _start_button.connect("pressed", self, "_on_start_button_pressed") -func _on_Snake_added_new_segment(type: String) -> void: - snake_size += 1 - _snake_size_label.text =_snake_size_fmt % snake_size - - func _on_start_button_pressed() -> void: _start_button.disabled = true _start_button.visible = false - Event.emit_signal("game_start") \ No newline at end of file + Event.emit_signal("game_start") -- cgit v1.2.3