better spawn, heart ui, dash, new map

This commit is contained in:
Daniel Kauss Serna 2026-02-20 17:47:53 +01:00
parent ce27965422
commit 34be761164
16 changed files with 137 additions and 171 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

View file

@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://decmuqi30h2xr"
path="res://.godot/imported/world_1.png-5a6af280f8f4508e378604bf28e718b5.ctex"
uid="uid://dmva40im8d3wa"
path="res://.godot/imported/world1.png-45ebdd817229a620d7b437ef610bed91.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/enviroment/world_1.png"
dest_files=["res://.godot/imported/world_1.png-5a6af280f8f4508e378604bf28e718b5.ctex"]
source_file="res://assets/enviroment/world1.png"
dest_files=["res://.godot/imported/world1.png-45ebdd817229a620d7b437ef610bed91.ctex"]
[params]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

View file

@ -94,6 +94,13 @@ interact={
]
}
[layer_names]
2d_physics/layer_1="Player"
2d_physics/layer_2="Enemies"
2d_physics/layer_3="World Bounds"
2d_physics/layer_4="Obstacles"
[rendering]
textures/canvas_textures/default_texture_filter=0

View file

@ -18,7 +18,6 @@ script = ExtResource("1_mcqwg")
spawn_sfx = ExtResource("2_ef0hr")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=257593575]
modulate = Color(1, 0.45533067, 0.837305, 1)
texture = ExtResource("2_j6vao")
[node name="Trail" type="Line2D" parent="Sprite2D" unique_id=1712481129]

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,16 @@
extends TextureRect
extends Control
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
EventBus.health_changed.connect(_on_health_changed)
_on_health_changed(3)
func _on_health_changed(new : int):
texture.region = Rect2(0, new * 32, 0, 32)
var i = 0;
for c : HealthHeart in get_children():
print(i, new)
if i < new:
c.set_full()
else:
c.set_empty()
i += 1

View file

@ -1,6 +1,6 @@
class_name Player extends Entity
@export var dash_base_cd: float = 0.7
@export var dash_base_cd: float = 0.2
@onready var player_sprite :AnimatedSprite2D = $PlayerSprite
@onready var mask_sprite : Sprite2D = $PlayerSprite/MaskSprite
@ -35,6 +35,11 @@ func _physics_process(delta: float) -> void:
velocity += input_vector * move_speed
dash_cd_timer -= delta
if dash_cd_timer > 0:
collision_mask = (0xFFFF ^ 8) & collision_mask
else:
collision_mask = 8 | collision_mask
if Input.is_action_just_pressed("dash") and dash_cd_timer <= 0:
start_dash(input_vector)
@ -69,8 +74,6 @@ func start_dash(dir: Vector2):
tween.tween_property(player_sprite, "scale:x", 1, 0.1)
func _input(event: InputEvent) -> void:
#if event.is_action_pressed("attack") and current_mask_data:
#use_mask(get_global_mouse_position())
if event.is_action_pressed("interact") and closest_mask_drop:
collect_drop(closest_mask_drop)

View file

@ -1,8 +1,6 @@
class_name RoomSpawn extends Area2D
@export var waves_container: Node2D
var waves: Array[Node] = []
var waves: Array[WaveNode] = []
var current_wave_index: int = 0
var active_enemies: int = 0
var has_triggered: bool = false
@ -10,14 +8,9 @@ var has_triggered: bool = false
func _ready() -> void:
body_entered.connect(_on_body_entered)
if not waves_container:
push_error("Waves container not assigned in RoomSpawn!")
return
waves = waves_container.get_children()
for wave in waves:
wave.hide()
wave.process_mode = Node.PROCESS_MODE_DISABLED
for c in get_children():
if c is WaveNode:
waves.append(c)
func _on_body_entered(body: Node2D) -> void:
if has_triggered:
@ -25,30 +18,18 @@ func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("player"):
has_triggered = true
start_next_wave()
# cant spawn collision shape in body entered
call_deferred("start_next_wave")
func start_next_wave() -> void:
if current_wave_index >= waves.size():
return
var current_wave = waves[current_wave_index]
current_wave.show()
current_wave.process_mode = Node.PROCESS_MODE_INHERIT
current_wave.finished.connect(_on_finished)
current_wave.spawn_wave()
var enemies = current_wave.get_children()
active_enemies = enemies.size()
if active_enemies == 0:
current_wave_index += 1
start_next_wave()
return
for enemy in enemies:
enemy.tree_exited.connect(_on_enemy_died)
func _on_enemy_died() -> void:
active_enemies -= 1
if active_enemies <= 0:
current_wave_index += 1
start_next_wave()
func _on_finished() -> void:
current_wave_index += 1
start_next_wave()

12
scripts/spawner.gd Normal file
View file

@ -0,0 +1,12 @@
class_name Spawner extends Marker2D
signal finished;
@export var spawn_instance : PackedScene;
func spawn():
var entity : Entity = spawn_instance.instantiate()
get_tree().current_scene.add_child(entity)
entity.global_position = global_position
entity.scale.y = 5
#create_tween().tween_property(entity, "scale:y", 1, 0.2)
entity.died.connect(finished.emit)

1
scripts/spawner.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dm2ayvfebi7x5

23
scripts/wave_node.gd Normal file
View file

@ -0,0 +1,23 @@
class_name WaveNode extends Node2D
@export var spawn_interval := 0.2
signal finished;
var entities := 0;
func _ready() -> void:
entities = get_child_count()
func spawn_wave():
if get_child_count() == 0:
finished.emit()
return;
for c : Spawner in get_children():
c.spawn();
c.finished.connect(entity_left)
await get_tree().create_timer(spawn_interval).timeout
func entity_left():
entities -= 1
if entities <= 0:
finished.emit()

1
scripts/wave_node.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://beuumo3n5tycr

7
ui/heart.gd Normal file
View file

@ -0,0 +1,7 @@
class_name HealthHeart extends TextureRect
func set_full():
texture.region = Rect2(0, 96, 0, 32)
func set_empty():
texture.region = Rect2(0, 0, 0, 32)

1
ui/heart.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://xax2m3yjnmxq

View file

@ -7,13 +7,22 @@
[ext_resource type="Texture2D" uid="uid://bng412si6gw5w" path="res://ui/healt_bar.png" id="7_np4cb"]
[ext_resource type="Script" uid="uid://cj6pb1828dcfr" path="res://scripts/health_bar.gd" id="8_8fqmc"]
[ext_resource type="PackedScene" uid="uid://c6f7s7bsitw13" path="res://ui/settings_menu.tscn" id="8_14s75"]
[ext_resource type="Script" uid="uid://xax2m3yjnmxq" path="res://ui/heart.gd" id="8_vi4d2"]
[ext_resource type="Texture2D" uid="uid://efh5dlhsxsnq" path="res://ui/bar_under.png" id="9_fl7ai"]
[ext_resource type="Texture2D" uid="uid://bdi1ga46vj8lt" path="res://ui/bar_progress.png" id="10_iwd8l"]
[ext_resource type="Script" uid="uid://cqrqqn2p0h0kb" path="res://scripts/mask_bar.gd" id="11_01h74"]
[ext_resource type="Script" uid="uid://dgxs6odxyi6s4" path="res://scripts/dmg_flash.gd" id="12_vi4d2"]
[ext_resource type="Shader" uid="uid://djbssih1prixl" path="res://shaders/post_processing.gdshader" id="13_1evs6"]
[sub_resource type="AtlasTexture" id="AtlasTexture_dhpj7"]
[sub_resource type="AtlasTexture" id="AtlasTexture_vi4d2"]
atlas = ExtResource("7_np4cb")
region = Rect2(0, 96, 0, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_1evs6"]
atlas = ExtResource("7_np4cb")
region = Rect2(0, 96, 0, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_umou3"]
atlas = ExtResource("7_np4cb")
region = Rect2(0, 96, 0, 32)
@ -89,11 +98,27 @@ texture_under = ExtResource("9_fl7ai")
texture_progress = ExtResource("10_iwd8l")
script = ExtResource("11_01h74")
[node name="HealthBar" type="TextureRect" parent="UI/PlayerStat" unique_id=1431196763]
[node name="HBoxContainer" type="HBoxContainer" parent="UI/PlayerStat" unique_id=2071372228]
layout_mode = 2
script = ExtResource("8_8fqmc")
[node name="Heart" type="TextureRect" parent="UI/PlayerStat/HBoxContainer" unique_id=1431196763]
layout_mode = 2
size_flags_vertical = 4
texture = SubResource("AtlasTexture_dhpj7")
script = ExtResource("8_8fqmc")
texture = SubResource("AtlasTexture_vi4d2")
script = ExtResource("8_vi4d2")
[node name="Heart2" type="TextureRect" parent="UI/PlayerStat/HBoxContainer" unique_id=415318443]
layout_mode = 2
size_flags_vertical = 4
texture = SubResource("AtlasTexture_1evs6")
script = ExtResource("8_vi4d2")
[node name="Heart3" type="TextureRect" parent="UI/PlayerStat/HBoxContainer" unique_id=1779405800]
layout_mode = 2
size_flags_vertical = 4
texture = SubResource("AtlasTexture_umou3")
script = ExtResource("8_vi4d2")
[node name="SettingsMenu" parent="UI" unique_id=478838648 instance=ExtResource("8_14s75")]
layout_mode = 1