diff --git a/.gitignore b/.gitignore index dc48c4d..35c207d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ # Local export artifacts build/ + +# Python-only static checks for the level resources +__pycache__/ +*.pyc diff --git a/README.md b/README.md index 5aba8a9..1d35bf3 100644 --- a/README.md +++ b/README.md @@ -1882,10 +1882,15 @@ Actualizar esta sección conforme avance el proyecto. - Vida, daño, knockback, invulnerabilidad breve y muerte/reinicio del jugador. - CharacterData con cuatro recursos: singer, guitarist, bassist y drummer. - Los cuatro personajes usan provisionalmente las mismas animaciones idle/walk de Diego. -- Primer enemigo Walker: patrulla, gira en paredes/bordes, hace daño por contacto, - recibe daño y muere. +- Walker: persigue y ataca con animacion temporal de aviso, recibe dano y muere. +- Cinco apariencias humanoides del enemigo (roadie, fan del pogo, tecnico, + guardia y guitarrista rival) con SVG originales y estadisticas propias. +- Level 01 ampliado a 8500 unidades, 17 encuentros de recompensa fija sin + respawn y varias plataformas opcionales para probar la movilidad. - Hurtboxes y zonas de ataque visibles en modo debug con rojo semitransparente. - Sala levels/test/combat_test.tscn para probar el combate. +- Objetos recolectables configurables, curacion y siete buffs/cargas distintos. +- HUD de mejoras activas y contador de objetos realmente recogidos en Level 01. - Controles táctiles provisionales para Android usando las mismas acciones del InputMap. - Preset Android preparado para generar un APK arm64 de pruebas. - Script scripts/export_android_debug.sh para exportar el APK desde un servidor sin GUI. @@ -1897,7 +1902,9 @@ Actualizar esta sección conforme avance el proyecto. - Probar y ajustar tamaños/offsets de hurtboxes e hitboxes jugando la sala de combate. - Sustituir las animaciones provisionales cuando exista arte para cada integrante. - Probar tamaños y colocación de los controles táctiles en varios teléfonos. -- Añadir UI provisional de vida si hace falta para seguir afinando el combate. +- Validar la ruta de Level 01 en una APK real: todos los 17 objetos y el + acceso a las plataformas elevadas. +- Ajustar posicion/tamano de los HUDs y controles para distintas pantallas. ``` ## LATER @@ -1905,7 +1912,7 @@ Actualizar esta sección conforme avance el proyecto. ```text - diferencias particulares entre personajes; - invisibilidad del bajista; -- power-ups adicionales; +- coleccionables secretos; - definición completa de capítulos; - bosses; - easter eggs; @@ -1953,9 +1960,27 @@ El objetivo principal es siempre tener una versión pequeña pero completamente - **Implementado:** 17 objetos configurables (`pickups/data/`) con SVG originales de 32×32 (16×16 visibles), textos breves y efectos. - **Implementado:** curación, velocidad, daño, carga del especial, bloqueo de un golpe, reducción de daño, altura de salto y daño aéreo. - **Implementado:** tabla de drops ponderados de Walker; 50% de probabilidad de un objeto por muerte. -- **Implementado:** el objeto del primer nivel usa el mismo sistema que los demás, sin alterar `CharacterData`. -- **Pendiente:** indicadores persistentes de mejoras activas, coleccionables secretos, pruebas visuales en el editor y equilibrado. +- **Implementado:** `level_01.tscn` es ahora un laboratorio de objetos con 17 enemigos, + 17 drops garantizados diferentes, ninguno reaparece, y 5 variantes visuales + originales con un unico comportamiento Walker. +- **Implementado:** indicador de mejoras activas con duracion/escudo, contador + de objetos recogidos y limites de camara adaptados al nivel largo. +- **Implementado:** especial con radio configurable (290 en el laboratorio), + sin modificar el alcance por defecto en el resto de escenas. +- **Pendiente:** coleccionables secretos, test visual en Godot/Android, + equilibrio y sprites/animaciones definitivas. Catálogo, pesos, estados e instrucciones: **[docs/items.md](docs/items.md)**. +Recorrido de Android (17 estaciones, orden y checklist): +**[docs/test_level_01.md](docs/test_level_01.md)**. + +Comprobacion estatica reproducible (sin arrancar Godot): +`python -m unittest discover -s tests -v`. + +La escena de inicio del proyecto ya es `levels/level_01.tscn`. +Para exportar una APK de pruebas, revisa las instrucciones de +`scripts/export_android_debug.sh` y el preset de Android (requiere SDK y +plantillas Godot configuradas localmente). + > Importante: el proyecto contiene un prototipo jugable y arte provisional; la implementación no sustituye una prueba real en Godot ni garantiza una clasificación por edades concreta. diff --git a/assets/enemies/backstage_guard.svg b/assets/enemies/backstage_guard.svg new file mode 100644 index 0000000..3df87b2 --- /dev/null +++ b/assets/enemies/backstage_guard.svg @@ -0,0 +1,4 @@ + +Guardia de camerino + + diff --git a/assets/enemies/feedback_tech.svg b/assets/enemies/feedback_tech.svg new file mode 100644 index 0000000..15a22b1 --- /dev/null +++ b/assets/enemies/feedback_tech.svg @@ -0,0 +1,4 @@ + +Tecnico del feedback + + diff --git a/assets/enemies/pogo_fan.svg b/assets/enemies/pogo_fan.svg new file mode 100644 index 0000000..7f7a152 --- /dev/null +++ b/assets/enemies/pogo_fan.svg @@ -0,0 +1,4 @@ + +Fan del pogo eterno + + diff --git a/assets/enemies/rival_guitarist.svg b/assets/enemies/rival_guitarist.svg new file mode 100644 index 0000000..18191cd --- /dev/null +++ b/assets/enemies/rival_guitarist.svg @@ -0,0 +1,4 @@ + +Guitarrista rival + + diff --git a/assets/enemies/roadie.svg b/assets/enemies/roadie.svg new file mode 100644 index 0000000..2a10a13 --- /dev/null +++ b/assets/enemies/roadie.svg @@ -0,0 +1,4 @@ + +Roadie del mas alla + + diff --git a/docs/items.md b/docs/items.md index 4818a9c..27b12c7 100644 --- a/docs/items.md +++ b/docs/items.md @@ -26,13 +26,26 @@ Los SVG son de 32 x 32 px, y la escena `pickup.tscn` escala el Sprite2D a 0.5: * ## Distribución y reglas -- Walker: 50% de probabilidad de soltar 1 objeto al morir; tabla ponderada en `enemies/walker/walker_drop.tres`. -- `Muelles del Stage Diving` y `Baqueta Sismica`: recursos implementados, disponibles para colocar manualmente en niveles; aún no incluidos en la tabla de Walker. +- Walker normal: 50% de probabilidad de soltar 1 objeto al morir; tabla ponderada en `enemies/walker/walker_drop.tres`. +- En el laboratorio `levels/level_01.tscn`: `guaranteed_drop` asignado en cada uno de los 17 enemigos, 100% de probabilidad y sin respawn. No cambia el drop normal. +- `Muelles del Stage Diving` y `Baqueta Sismica` no están en la tabla aleatoria normal, pero **sí** se pueden probar derrotando las estaciones 15 y 16 del laboratorio. - Las curaciones no se consumen si ya tienes la vida completa; el especial tampoco si está lleno. - Las mejoras de igual tipo renuevan duración y conservan la mayor potencia (no se multiplican entre sí). Mejoras de tipos diferentes conviven. - El escudo bloquea un golpe y aplica la invulnerabilidad habitual del jugador. - Los sprites son iconos originales vectoriales, no se reutilizan imágenes de terceros. +## Prueba de todos los objetos en una APK + +- **Implementado en escena:** 17 estaciones ordenadas de izquierda a derecha, + cada una con un enemigo visual diferente (cinco variantes cíclicas) y un drop + fijo. El HUD cuenta objetos *recogidos*, no enemigos eliminados. +- **Implementado en código:** el HUD del jugador muestra los efectos temporales + y el escudo. Carga especial/curación requieren capacidad disponible para + consumirse; a tope permanecen en el suelo. +- **Por validar:** importación SVG, colisiones, caídas de los items, equilibrio, + funcionamiento con controles táctiles y exportación APK en un teléfono real. +- **Guía:** [Test de Level 01](test_level_01.md) (orden de recompensas y checklist). + ## Pendiente (no implementado) | Coleccionable | Descripción | Estado | @@ -54,5 +67,6 @@ Los SVG son de 32 x 32 px, y la escena `pickup.tscn` escala el Sprite2D a 0.5: * - Probar visualmente las importaciones SVG y cada efecto en Godot 4.7. - Equilibrar tiempos y probabilidades tras jugar varios niveles. -- Añadir indicadores persistentes de buffs en el HUD (ahora se muestra texto flotante al recoger). +- Validar que los indicadores persistentes del HUD se ven y se actualizan + correctamente en Android (implementados en código, aún no probados en dispositivo). - Revisar la clasificación por edades con el cuestionario IARC/Google Play; nombres ficticios no garantizan ninguna clasificación. diff --git a/docs/test_level_01.md b/docs/test_level_01.md new file mode 100644 index 0000000..8fe6120 --- /dev/null +++ b/docs/test_level_01.md @@ -0,0 +1,101 @@ +# Level 01 - Laboratorio de objetos (Android) + +**Implementado en escena / pendiente de validar jugando en Godot y Android.** + +`levels/level_01.tscn` es un recorrido deliberadamente largo para probar una +APK sin alterar el codigo entre partidas. Es la escena inicial configurada en +`project.godot`. + +- **17 enemigos / 17 objetos diferentes**, uno por enemigo, en este orden. +- Cada enemigo suelta **siempre** su objeto asignado al morir y **no reaparece**. +- La tabla normal `enemies/walker/walker_drop.tres` conserva su 50% aleatorio + en las otras escenas (no se ha desactivado globalmente). +- Suelo continuo para no quedarse atascado, con 7 plataformas opcionales. + La primera plataforma alta (x=1690, y=291) esta concebida para alcanzarse + desde la baja (x=1530, y=455), no directamente desde el suelo. Hay doble salto. +- La camara acompana todo el recorrido (hasta x=8500). +- Etiquetas sobre cada enemigo y contador en la esquina superior derecha. +- HUD izquierda: vida, carga especial y mejoras temporales con segundos. +- La meta esta en **x=8180**; muestra resultados y reinicia tras 8 segundos. +- En esta escena el especial tiene radio de 290 unidades para evitar eliminar + enemigos de estaciones vecinas antes de llegar a ellas. + +## Encuentros y recompensas + +| # | X | Enemigo (aspecto) | Drop fijo | Archivo de datos | +|---|---:|---|---|---| +| 01 | 480 | Roadie del Mas Alla | **Pua del Apocalipsis** | `pua_apocalipsis.tres` | +| 02 | 930 | Fan del Pogo Eterno | **Espuma del Pogo** | `beer.tres` | +| 03 | 1380 | Tecnico del Feedback | **Tostado del Averno** | `coffee.tres` | +| 04 | 1830 | Guardia del Camerino | **Casete de la Demo Perdida** | `casete_demo.tres` | +| 05 | 2280 | Guitarrista Rival | **Bocata del Roadie** | `bocata_roadie.tres` | +| 06 | 2730 | Roadie del Mas Alla | **Lata de Feedback** | `lata_feedback.tres` | +| 07 | 3180 | Fan del Pogo Eterno | **Pedal de Distorsion** | `pedal_distorsion.tres` | +| 08 | 3630 | Tecnico del Feedback | **Setlist del Fin del Mundo** | `setlist_fin.tres` | +| 09 | 4080 | Guardia del Camerino | **Pizza Post-Bolo** | `pizza_post_bolo.tres` | +| 10 | 4530 | Guitarrista Rival | **Cuerda de Titanio** | `cuerda_titanio.tres` | +| 11 | 4980 | Roadie del Mas Alla | **Cinta Americana Infinita** | `cinta_americana.tres` | +| 12 | 5430 | Fan del Pogo Eterno | **Tapones del Tecnico** | `tapones_tecnico.tres` | +| 13 | 5880 | Tecnico del Feedback | **Tupper del Bateria** | `tupper_bateria.tres` | +| 14 | 6330 | Guardia del Camerino | **Botas del Doble Bombo** | `botas_doble_bombo.tres` | +| 15 | 6780 | Guitarrista Rival | **Muelles del Stage Diving** | `muelles_stage.tres` | +| 16 | 7230 | Roadie del Mas Alla | **Baqueta Sismica** | `baqueta_sismica.tres` | +| 17 | 7680 | Fan del Pogo Eterno | **Amplificador al 11** | `amplificador_11.tres` | + +## Que comprobar en la APK + +- [ ] La APK abre directamente `level_01`, se puede caminar a derecha durante + todo el nivel y la camara no se detiene en x=4000. +- [ ] Los 17 enemigos tienen apariencia humanoide visible y ataques legibles. +- [ ] Cada muerte deja el objeto esperado (no uno aleatorio), una sola vez. +- [ ] La etiqueta del siguiente objeto y el contador coinciden con la partida. +- [ ] Al recoger objetos, sus efectos se notan; buffs y escudo se listan a la izquierda. +- [ ] Vida llena: las curaciones permanecen en el suelo hasta necesitar HP. +- [ ] Especial lleno: los objetos de carga permanecen hasta consumir el especial (SP). +- [ ] Las dos mejoras de salto/ataque aereo se pueden probar en las plataformas. +- [ ] Hay que saltar a la plataforma baja para alcanzar la alta. +- [ ] Al llegar a la meta se ve el resumen y vuelve a empezar tras 8 s. + +**Nota:** El contador marca objetos efectivamente *recogidos*, no enemigos +muertos. Para obtener 17/17 hay que haber perdido vida antes de tomar curaciones +y haber gastado especial antes de tomar cargadores si esta lleno. Los objetos +no desaparecen por tiempo; puedes volver a recogerlos. + +## Como cambiar una estacion + +En `levels/level_01.tscn`, selecciona `TestEnemies/StationXX` y cambia +`guaranteed_drop` por un recurso de `pickups/data/`. En esta escena no necesitas +modificar la tabla de drops. El valor `respawn_delay = 0` viene del perfil del +enemigo (en `enemies/variants/`). Para volver al reparto aleatorio en un nivel +normal, deja `guaranteed_drop` vacio y usa el Walker original. + +Los cinco perfiles usan el script `enemies/walker/walker.gd`. Son variantes +**visuales y de estadisticas**, no cinco IA diferentes: + +- Roadie del Mas Alla: mochila/cable y gorra. +- Fan del Pogo Eterno: cresta y chaleco de festival. +- Tecnico del Feedback: auriculares, chaleco y mesa de sonido. +- Guardia del Camerino: traje y gafas de sol. +- Guitarrista Rival: melenas y guitarra electrica. + +Sprites SVG de **32x56** (`assets/enemies/`) para una colision aprox. **28x52**. +Los objetos mantienen iconos SVG de **32x32** y representacion a **16x16**. + +## Verificacion antes de exportar + +Desde la raiz del proyecto: + +```bash +python -m unittest discover -s tests -v +``` + +Esto valida rutas, SVG, drops y el layout basico, **pero no ejecuta Godot**. +Abre el proyecto en Godot una vez para importar los SVG y probar la escena. +Para generar un APK en un entorno que tenga Godot y el SDK Android configurados: + +```bash +./scripts/export_android_debug.sh +``` + +El script admite una ruta de salida opcional; por defecto escribe +`build/android/mortal-maze-debug.apk`. No se ha compilado la APK aqui. diff --git a/enemies/variants/backstage_guard.tscn b/enemies/variants/backstage_guard.tscn new file mode 100644 index 0000000..3596465 --- /dev/null +++ b/enemies/variants/backstage_guard.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3] + +[ext_resource type="PackedScene" path="res://enemies/walker/walker.tscn" id="1_walker"] +[ext_resource type="Texture2D" path="res://assets/enemies/backstage_guard.svg" id="2_sprite"] + +[node name="Walker" instance=ExtResource("1_walker")] +enemy_display_name = "Guardia del Camerino" +move_speed = 70.0 +max_health = 30 +attack_damage = 4 +chase_radius = 135.0 +respawn_delay = 0.0 +show_debug_hitboxes = false + +[node name="Visual" parent="." index="0"] +texture = ExtResource("2_sprite") diff --git a/enemies/variants/feedback_tech.tscn b/enemies/variants/feedback_tech.tscn new file mode 100644 index 0000000..01960a7 --- /dev/null +++ b/enemies/variants/feedback_tech.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3] + +[ext_resource type="PackedScene" path="res://enemies/walker/walker.tscn" id="1_walker"] +[ext_resource type="Texture2D" path="res://assets/enemies/feedback_tech.svg" id="2_sprite"] + +[node name="Walker" instance=ExtResource("1_walker")] +enemy_display_name = "Tecnico del Feedback" +move_speed = 55.0 +max_health = 25 +attack_damage = 3 +chase_radius = 135.0 +respawn_delay = 0.0 +show_debug_hitboxes = false + +[node name="Visual" parent="." index="0"] +texture = ExtResource("2_sprite") diff --git a/enemies/variants/pogo_fan.tscn b/enemies/variants/pogo_fan.tscn new file mode 100644 index 0000000..5f7e230 --- /dev/null +++ b/enemies/variants/pogo_fan.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3] + +[ext_resource type="PackedScene" path="res://enemies/walker/walker.tscn" id="1_walker"] +[ext_resource type="Texture2D" path="res://assets/enemies/pogo_fan.svg" id="2_sprite"] + +[node name="Walker" instance=ExtResource("1_walker")] +enemy_display_name = "Fan del Pogo Eterno" +move_speed = 105.0 +max_health = 15 +attack_damage = 2 +chase_radius = 135.0 +respawn_delay = 0.0 +show_debug_hitboxes = false + +[node name="Visual" parent="." index="0"] +texture = ExtResource("2_sprite") diff --git a/enemies/variants/rival_guitarist.tscn b/enemies/variants/rival_guitarist.tscn new file mode 100644 index 0000000..d1134f7 --- /dev/null +++ b/enemies/variants/rival_guitarist.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3] + +[ext_resource type="PackedScene" path="res://enemies/walker/walker.tscn" id="1_walker"] +[ext_resource type="Texture2D" path="res://assets/enemies/rival_guitarist.svg" id="2_sprite"] + +[node name="Walker" instance=ExtResource("1_walker")] +enemy_display_name = "Guitarrista Rival" +move_speed = 87.0 +max_health = 20 +attack_damage = 3 +chase_radius = 135.0 +respawn_delay = 0.0 +show_debug_hitboxes = false + +[node name="Visual" parent="." index="0"] +texture = ExtResource("2_sprite") diff --git a/enemies/variants/roadie.tscn b/enemies/variants/roadie.tscn new file mode 100644 index 0000000..8edaa72 --- /dev/null +++ b/enemies/variants/roadie.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3] + +[ext_resource type="PackedScene" path="res://enemies/walker/walker.tscn" id="1_walker"] +[ext_resource type="Texture2D" path="res://assets/enemies/roadie.svg" id="2_sprite"] + +[node name="Walker" instance=ExtResource("1_walker")] +enemy_display_name = "Roadie del Mas Alla" +move_speed = 65.0 +max_health = 20 +attack_damage = 3 +chase_radius = 135.0 +respawn_delay = 0.0 +show_debug_hitboxes = false + +[node name="Visual" parent="." index="0"] +texture = ExtResource("2_sprite") diff --git a/enemies/walker/walker.gd b/enemies/walker/walker.gd index c5ad6b7..9d0b829 100644 --- a/enemies/walker/walker.gd +++ b/enemies/walker/walker.gd @@ -91,18 +91,26 @@ enum AttackState { @export_category("Drops") -## Table defining what pickups can drop on death (by chance). +## Default weighted drops for normal encounters. @export var drop_table: PickupDropTable - -@export_category("Respawn") +## Optional fixed drop, used by the Level 01 test route. When assigned, this +## object drops with 100% probability INSTEAD of the random table. +@export var guaranteed_drop: PickupData @export_category("Respawn") -## Enough downtime to make defeating an enemy meaningful before it comes back. +## A value of 0 disables respawn (one enemy = one test item). @export var respawn_delay: float = 5.0 +## Limits how far the enemy may chase from its spawn point; 0 = unrestricted. +## Small limits keep independent testing encounters from piling up. +@export var chase_radius: float = 0.0 + +## Only used to describe enemy variants in test HUDs. +@export var enemy_display_name: String = "Walker" + # ============================================================================ # DEBUG @@ -130,6 +138,7 @@ enum AttackState { @onready var attack_collision: CollisionShape2D = $AttackHitbox/CollisionShape2D @onready var floor_probe: RayCast2D = $FloorProbe @onready var visibility_notifier: VisibleOnScreenNotifier2D = $VisibleOnScreenNotifier2D +@onready var visual: Sprite2D = $Visual # ============================================================================ @@ -263,6 +272,8 @@ func _update_facing() -> void: if attack_state == AttackState.IDLE: _reset_attack_hitbox_position() + # The five variants share one collision box and AI, but use different sprites. + visual.flip_h = facing_direction < 0.0 # ============================================================================ @@ -288,6 +299,13 @@ func _update_idle_behaviour() -> void: func _chase_target() -> void: + # Limit chasing to the current testing station when chase_radius is set. + # Going back towards the spawn point is always allowed. + var distance_from_spawn: float = global_position.x - spawn_position.x + if chase_radius > 0.0 and absf(distance_from_spawn) >= chase_radius and signf(distance_from_spawn) == facing_direction: + velocity.x = 0.0 + return + # Do not blindly walk off a platform while chasing. Proper pathfinding is # intentionally postponed until levels actually require it. if is_on_floor() and not floor_probe.is_colliding(): @@ -489,15 +507,18 @@ func _die() -> void: is_dead = true died.emit() - if drop_table != null: - var drops = DROP_MANAGER.roll_drop(drop_table) - if not drops.is_empty(): - var parent := get_tree().current_scene - if parent == null: - parent = get_tree().root.get_child(get_tree().root.get_child_count() - 1) - if parent == null: - parent = get_tree().root - DROP_MANAGER.spawn_drops(drops, parent, global_position) + # Test encounters always drop their assigned item, including the two items + # absent from the normal Walker table. Other levels keep their random loot. + var drops: Array[PickupData] = [] + if guaranteed_drop != null: + drops.append(guaranteed_drop) + elif drop_table != null: + drops = DROP_MANAGER.roll_drop(drop_table) + if not drops.is_empty(): + var parent: Node = get_tree().current_scene + if parent == null: + parent = get_tree().root + DROP_MANAGER.spawn_drops(drops, parent, global_position) velocity = Vector2.ZERO visible = false @@ -508,8 +529,9 @@ func _die() -> void: hurtbox_collision.set_deferred("disabled", true) attack_collision.set_deferred("disabled", true) - await get_tree().create_timer(respawn_delay).timeout - _respawn() + if respawn_delay > 0.0: + await get_tree().create_timer(respawn_delay).timeout + _respawn() func _respawn() -> void: @@ -544,19 +566,24 @@ func _respawn() -> void: # ============================================================================ func _draw() -> void: - # The enemy has no sprite yet. This neutral block makes the actual entity - # visible independently from the debug overlays. - _draw_rectangle_collision( - body_collision, - Color(0.18, 0.18, 0.20, 0.90), - Color(0.85, 0.85, 0.90, 1.0) - ) + # Retain a fallback body if an imported sprite is missing. + if visual.texture == null: + _draw_rectangle_collision( + body_collision, + Color(0.18, 0.18, 0.20, 0.90), + Color(0.85, 0.85, 0.90, 1.0) + ) # Enemy health bar and floating damage numbers (debug overlay). if show_debug_enemy_info: _draw_enemy_health_bar() _draw_damage_texts() + # Orange windup is important gameplay feedback, not a debug hitbox. + # Keep it visible on Android even when red collision overlays are disabled. + if attack_state == AttackState.WINDUP: + _draw_attack_telegraph() + if not show_debug_hitboxes: return @@ -567,11 +594,6 @@ func _draw() -> void: Color(1.0, 0.05, 0.05, 0.55) ) - # Windup: preview the full sweep in orange. It is explicitly NOT dangerous - # yet, so the different colour makes the reaction window easy to understand. - if attack_state == AttackState.WINDUP: - _draw_attack_telegraph() - # Active attack: draw the real moving physics hitbox in strong red. if attack_state == AttackState.ACTIVE: _draw_rectangle_collision( diff --git a/enemies/walker/walker.tscn b/enemies/walker/walker.tscn index 0f849a6..38b4965 100644 --- a/enemies/walker/walker.tscn +++ b/enemies/walker/walker.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=4 format=3] +[gd_scene load_steps=5 format=3] [ext_resource type="Script" path="res://enemies/walker/walker.gd" id="1_walker"] +[ext_resource type="Texture2D" path="res://assets/enemies/roadie.svg" id="2_sprite"] [sub_resource type="RectangleShape2D" id="BodyShape"] size = Vector2(28, 52) @@ -13,6 +14,11 @@ collision_layer = 4 collision_mask = 1 script = ExtResource("1_walker") +[node name="Visual" type="Sprite2D" parent="."] +z_index = -1 +texture_filter = 1 +texture = ExtResource("2_sprite") + [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, 0) shape = SubResource("BodyShape") diff --git a/levels/level_01.gd b/levels/level_01.gd index af827e7..8ec3b56 100644 --- a/levels/level_01.gd +++ b/levels/level_01.gd @@ -1,79 +1,106 @@ extends Node2D -## Señal que se emite cuando el jugador alcanza el final del nivel. +## Android test course: 17 stations / 17 different guaranteed items. +## Encounters are configured in the scene, not spawned by code, so designers can +## freely move a station or switch its drop in the Godot inspector. + signal level_completed -@onready var player: Node2D = $Player -@onready var message_label: Label = $MessageLabel +const TEST_ITEM_COUNT: int = 17 +const LEVEL_WIDTH: int = 8500 +const FINISH_RESTART_SECONDS: float = 8.0 -# Colores temporales de cada plataforma. Se pueden cambiar por texturas más tarde. -var platform_colors: Dictionary = { - "Floor": Color(0.2, 0.7, 0.2, 1.0), # Verde (suelo) - "Platform1": Color(0.4, 0.6, 1.0, 1.0), # Azul - "Platform2": Color(1.0, 0.4, 0.4, 1.0), # Rojo - "Platform3": Color(1.0, 1.0, 0.4, 1.0), # Amarillo -} +@onready var player: Node2D = $Player +@onready var test_enemies: Node2D = $TestEnemies +@onready var status_label: Label = $TestHUD/Overlay/Status +@onready var finish_message: Label = $TestHUD/Overlay/FinishMessage -var victory_timer: float = 0.0 +var collected_items: Dictionary = {} # PickupData.id -> true; count each only once var showing_victory: bool = false +var victory_timer: float = 0.0 func _ready() -> void: - message_label.visible = false - - # Zona de final del nivel (meta). - var finish: Area2D = $FinishZone - if finish: - finish.body_entered.connect(_on_finish_entered) - - # Zona de muerte (caer fuera del nivel). - var death: Area2D = $DeathZone - if death: - death.body_entered.connect(_on_death_entered) - - # Cuando el jugador muere, el nivel se recarga solo (player.gd ya lo hace). - if player.has_signal("died"): - player.died.connect(_on_player_died) + finish_message.visible = false + # Player Camera2D sets its own provisional limit (4000) in _ready. + # Override it here, after child _ready, for the long Android route. + var camera: Camera2D = player.get_node("Camera2D") as Camera2D + camera.limit_right = LEVEL_WIDTH + $FinishZone.body_entered.connect(_on_finish_entered) + $DeathZone.body_entered.connect(_on_death_entered) + player.connect(&"pickup_collected", _on_pickup_collected) + _update_status() func _process(delta: float) -> void: if showing_victory: victory_timer += delta - if victory_timer >= 3.0: + if victory_timer >= FINISH_RESTART_SECONDS: get_tree().reload_current_scene() + return + + _update_status() + + +func _update_status() -> void: + # Each station has one enemy and an assigned pickup. Look ahead to the first + # living enemy so the player knows what to expect without opening a menu. + var next_item: String = "FIN DEL RECORRIDO" + for enemy in test_enemies.get_children(): + if bool(enemy.get("is_dead")): + continue + var enemy_body: Node2D = enemy as Node2D + if enemy_body.position.x < player.position.x - 165.0: + continue + var data: PickupData = enemy.get("guaranteed_drop") as PickupData + if data != null: + next_item = data.display_name + break + + status_label.text = "LAB THRASH %02d / %02d recogidos\nSIGUIENTE: %s" % [ + collected_items.size(), TEST_ITEM_COUNT, next_item + ] + + +func _on_pickup_collected(data: PickupData) -> void: + # A heal at full HP or a charge item with a full meter isn't consumed and + # doesn't count. The object remains on the floor for later collection. + collected_items[data.id] = true + _update_status() func _on_finish_entered(body: Node2D) -> void: - if body != player: + if body != player or showing_victory: return showing_victory = true - message_label.text = "¡NIVEL COMPLETADO!" - message_label.visible = true + level_completed.emit() + finish_message.text = "FIN DEL LAB!\nObjetos recogidos: %d / %d\nReinicio en 8 s" % [ + collected_items.size(), TEST_ITEM_COUNT + ] + finish_message.visible = true func _on_death_entered(body: Node2D) -> void: - if body != player: - return - # Caer al vacío mata al jugador y recarga el nivel. - if body.has_method("take_damage"): + if body == player and body.has_method("take_damage"): body.take_damage(9999, body.global_position) -func _on_player_died() -> void: - # El nivel se recarga automáticamente desde player.gd. - pass - - -# Dibuja las plataformas con colores sólidos para que se vean en juego. -# Esto es solo temporal: se reemplazará por sprites/texturas cuando haya arte. func _draw() -> void: - var world: Node = $World - for child in world.get_children(): - if child is CollisionShape2D: - var shape: Shape2D = child.shape - if shape is RectangleShape2D: - var rect: Rect2 = Rect2(child.position - shape.size / 2.0, shape.size) - var color: Color = platform_colors.get(child.name, Color(0.5, 0.5, 0.5, 1.0)) - draw_rect(rect, color, true) - draw_rect(rect, Color(1, 1, 1, 0.3), false, 2.0) + # Temporary coloured geometry; collision shapes are the single source of + # truth for position and dimensions, so the visuals cannot desynchronise. + for child in $World.get_children(): + if not child is CollisionShape2D: + continue + var collision: CollisionShape2D = child as CollisionShape2D + var rectangle: RectangleShape2D = collision.shape as RectangleShape2D + if rectangle == null: + continue + var color: Color = Color(0.32, 0.57, 0.79) + if collision.name == "Floor": + color = Color(0.20, 0.40, 0.25) + elif collision.name.begins_with("High"): + color = Color(0.68, 0.39, 0.76) + var rect: Rect2 = Rect2(collision.position - rectangle.size / 2.0, rectangle.size) + draw_rect(rect, color, true) + draw_rect(rect, Color(0.93, 0.94, 1.0, 0.6), false, 2.0) diff --git a/levels/level_01.tscn b/levels/level_01.tscn index b221db2..4a8b164 100644 --- a/levels/level_01.tscn +++ b/levels/level_01.tscn @@ -1,83 +1,444 @@ -[gd_scene load_steps=16 format=3] +[gd_scene load_steps=31 format=3] [ext_resource type="PackedScene" path="res://player/player.tscn" id="1_player"] -[ext_resource type="PackedScene" path="res://enemies/walker/walker.tscn" id="2_walker"] -[ext_resource type="PackedScene" path="res://ui/mobile_controls/mobile_controls.tscn" id="4_mobile_controls"] +[ext_resource type="PackedScene" path="res://ui/mobile_controls/mobile_controls.tscn" id="2_mobile"] [ext_resource type="Script" path="res://levels/level_01.gd" id="3_level"] -[ext_resource type="PackedScene" path="res://pickups/pickup.tscn" id="5_pickup"] -[ext_resource type="Resource" path="res://pickups/data/pua_apocalipsis.tres" id="6_pua"] +[ext_resource type="PackedScene" path="res://enemies/variants/roadie.tscn" id="v0"] +[ext_resource type="PackedScene" path="res://enemies/variants/pogo_fan.tscn" id="v1"] +[ext_resource type="PackedScene" path="res://enemies/variants/feedback_tech.tscn" id="v2"] +[ext_resource type="PackedScene" path="res://enemies/variants/backstage_guard.tscn" id="v3"] +[ext_resource type="PackedScene" path="res://enemies/variants/rival_guitarist.tscn" id="v4"] +[ext_resource type="Resource" path="res://pickups/data/pua_apocalipsis.tres" id="item_0"] +[ext_resource type="Resource" path="res://pickups/data/beer.tres" id="item_1"] +[ext_resource type="Resource" path="res://pickups/data/coffee.tres" id="item_2"] +[ext_resource type="Resource" path="res://pickups/data/casete_demo.tres" id="item_3"] +[ext_resource type="Resource" path="res://pickups/data/bocata_roadie.tres" id="item_4"] +[ext_resource type="Resource" path="res://pickups/data/lata_feedback.tres" id="item_5"] +[ext_resource type="Resource" path="res://pickups/data/pedal_distorsion.tres" id="item_6"] +[ext_resource type="Resource" path="res://pickups/data/setlist_fin.tres" id="item_7"] +[ext_resource type="Resource" path="res://pickups/data/pizza_post_bolo.tres" id="item_8"] +[ext_resource type="Resource" path="res://pickups/data/cuerda_titanio.tres" id="item_9"] +[ext_resource type="Resource" path="res://pickups/data/cinta_americana.tres" id="item_10"] +[ext_resource type="Resource" path="res://pickups/data/tapones_tecnico.tres" id="item_11"] +[ext_resource type="Resource" path="res://pickups/data/tupper_bateria.tres" id="item_12"] +[ext_resource type="Resource" path="res://pickups/data/botas_doble_bombo.tres" id="item_13"] +[ext_resource type="Resource" path="res://pickups/data/muelles_stage.tres" id="item_14"] +[ext_resource type="Resource" path="res://pickups/data/baqueta_sismica.tres" id="item_15"] +[ext_resource type="Resource" path="res://pickups/data/amplificador_11.tres" id="item_16"] [sub_resource type="RectangleShape2D" id="FloorShape"] -size = Vector2(1400, 40) +size = Vector2(8500, 40) -[sub_resource type="RectangleShape2D" id="PlatformShape"] -size = Vector2(220, 20) +[sub_resource type="RectangleShape2D" id="StepShape"] +size = Vector2(240, 20) + +[sub_resource type="RectangleShape2D" id="HighShape"] +size = Vector2(180, 16) [sub_resource type="RectangleShape2D" id="FinishShape"] -size = Vector2(60, 40) +size = Vector2(70, 200) [sub_resource type="RectangleShape2D" id="DeathShape"] -size = Vector2(3000, 200) +size = Vector2(9000, 170) [node name="Level01" type="Node2D"] script = ExtResource("3_level") [node name="World" type="StaticBody2D" parent="."] collision_layer = 1 -collision_mask = 1 +collision_mask = 0 [node name="Floor" type="CollisionShape2D" parent="World"] -position = Vector2(700, 620) +position = Vector2(4250, 620) shape = SubResource("FloorShape") -[node name="Platform1" type="CollisionShape2D" parent="World"] -position = Vector2(300, 470) -shape = SubResource("PlatformShape") +[node name="Step1" type="CollisionShape2D" parent="World"] +position = Vector2(1530, 455) +shape = SubResource("StepShape") + +[node name="High1" type="CollisionShape2D" parent="World"] +position = Vector2(1690, 291) +shape = SubResource("HighShape") + +[node name="Step2" type="CollisionShape2D" parent="World"] +position = Vector2(3370, 485) +shape = SubResource("StepShape") + +[node name="High2" type="CollisionShape2D" parent="World"] +position = Vector2(3520, 338) +shape = SubResource("HighShape") + +[node name="Step3" type="CollisionShape2D" parent="World"] +position = Vector2(5600, 455) +shape = SubResource("StepShape") -[node name="Platform2" type="CollisionShape2D" parent="World"] -position = Vector2(1100, 470) -shape = SubResource("PlatformShape") +[node name="High3" type="CollisionShape2D" parent="World"] +position = Vector2(5750, 291) +shape = SubResource("HighShape") -[node name="Platform3" type="CollisionShape2D" parent="World"] -position = Vector2(700, 320) -shape = SubResource("PlatformShape") +[node name="Step4" type="CollisionShape2D" parent="World"] +position = Vector2(6890, 485) +shape = SubResource("StepShape") [node name="Player" parent="." instance=ExtResource("1_player")] -position = Vector2(120, 560) +position = Vector2(140, 557) +show_debug_hitboxes = false +special_radius = 290.0 + +[node name="TestEnemies" type="Node2D" parent="."] + +[node name="Station01" parent="TestEnemies" instance=ExtResource("v0")] +position = Vector2(480, 555) +guaranteed_drop = ExtResource("item_0") + +[node name="Station02" parent="TestEnemies" instance=ExtResource("v1")] +position = Vector2(930, 555) +guaranteed_drop = ExtResource("item_1") + +[node name="Station03" parent="TestEnemies" instance=ExtResource("v2")] +position = Vector2(1380, 555) +guaranteed_drop = ExtResource("item_2") + +[node name="Station04" parent="TestEnemies" instance=ExtResource("v3")] +position = Vector2(1830, 555) +guaranteed_drop = ExtResource("item_3") + +[node name="Station05" parent="TestEnemies" instance=ExtResource("v4")] +position = Vector2(2280, 555) +guaranteed_drop = ExtResource("item_4") + +[node name="Station06" parent="TestEnemies" instance=ExtResource("v0")] +position = Vector2(2730, 555) +guaranteed_drop = ExtResource("item_5") + +[node name="Station07" parent="TestEnemies" instance=ExtResource("v1")] +position = Vector2(3180, 555) +guaranteed_drop = ExtResource("item_6") + +[node name="Station08" parent="TestEnemies" instance=ExtResource("v2")] +position = Vector2(3630, 555) +guaranteed_drop = ExtResource("item_7") + +[node name="Station09" parent="TestEnemies" instance=ExtResource("v3")] +position = Vector2(4080, 555) +guaranteed_drop = ExtResource("item_8") + +[node name="Station10" parent="TestEnemies" instance=ExtResource("v4")] +position = Vector2(4530, 555) +guaranteed_drop = ExtResource("item_9") + +[node name="Station11" parent="TestEnemies" instance=ExtResource("v0")] +position = Vector2(4980, 555) +guaranteed_drop = ExtResource("item_10") + +[node name="Station12" parent="TestEnemies" instance=ExtResource("v1")] +position = Vector2(5430, 555) +guaranteed_drop = ExtResource("item_11") + +[node name="Station13" parent="TestEnemies" instance=ExtResource("v2")] +position = Vector2(5880, 555) +guaranteed_drop = ExtResource("item_12") + +[node name="Station14" parent="TestEnemies" instance=ExtResource("v3")] +position = Vector2(6330, 555) +guaranteed_drop = ExtResource("item_13") -[node name="Walker1" parent="." instance=ExtResource("2_walker")] -position = Vector2(450, 420) +[node name="Station15" parent="TestEnemies" instance=ExtResource("v4")] +position = Vector2(6780, 555) +guaranteed_drop = ExtResource("item_14") -[node name="Walker2" parent="." instance=ExtResource("2_walker")] -position = Vector2(950, 420) +[node name="Station16" parent="TestEnemies" instance=ExtResource("v0")] +position = Vector2(7230, 555) +guaranteed_drop = ExtResource("item_15") + +[node name="Station17" parent="TestEnemies" instance=ExtResource("v1")] +position = Vector2(7680, 555) +guaranteed_drop = ExtResource("item_16") + +[node name="StationSigns" type="Node2D" parent="."] + +[node name="Sign01" type="Label" parent="StationSigns"] +offset_left = 269.0 +offset_top = 467.0 +offset_right = 691.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "01 Roadie del Mas Alla\n>> Pua del Apocalipsis" +horizontal_alignment = 1 + +[node name="Sign02" type="Label" parent="StationSigns"] +offset_left = 719.0 +offset_top = 467.0 +offset_right = 1141.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "02 Fan del Pogo Eterno\n>> Espuma del Pogo" +horizontal_alignment = 1 + +[node name="Sign03" type="Label" parent="StationSigns"] +offset_left = 1169.0 +offset_top = 467.0 +offset_right = 1591.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "03 Tecnico del Feedback\n>> Tostado del Averno" +horizontal_alignment = 1 + +[node name="Sign04" type="Label" parent="StationSigns"] +offset_left = 1619.0 +offset_top = 467.0 +offset_right = 2041.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "04 Guardia del Camerino\n>> Casete de la Demo Perdida" +horizontal_alignment = 1 + +[node name="Sign05" type="Label" parent="StationSigns"] +offset_left = 2069.0 +offset_top = 467.0 +offset_right = 2491.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "05 Guitarrista Rival\n>> Bocata del Roadie" +horizontal_alignment = 1 + +[node name="Sign06" type="Label" parent="StationSigns"] +offset_left = 2519.0 +offset_top = 467.0 +offset_right = 2941.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "06 Roadie del Mas Alla\n>> Lata de Feedback" +horizontal_alignment = 1 + +[node name="Sign07" type="Label" parent="StationSigns"] +offset_left = 2969.0 +offset_top = 467.0 +offset_right = 3391.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "07 Fan del Pogo Eterno\n>> Pedal de Distorsion" +horizontal_alignment = 1 + +[node name="Sign08" type="Label" parent="StationSigns"] +offset_left = 3419.0 +offset_top = 467.0 +offset_right = 3841.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "08 Tecnico del Feedback\n>> Setlist del Fin del Mundo" +horizontal_alignment = 1 + +[node name="Sign09" type="Label" parent="StationSigns"] +offset_left = 3869.0 +offset_top = 467.0 +offset_right = 4291.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "09 Guardia del Camerino\n>> Pizza Post-Bolo" +horizontal_alignment = 1 + +[node name="Sign10" type="Label" parent="StationSigns"] +offset_left = 4319.0 +offset_top = 467.0 +offset_right = 4741.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "10 Guitarrista Rival\n>> Cuerda de Titanio" +horizontal_alignment = 1 + +[node name="Sign11" type="Label" parent="StationSigns"] +offset_left = 4769.0 +offset_top = 467.0 +offset_right = 5191.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "11 Roadie del Mas Alla\n>> Cinta Americana Infinita" +horizontal_alignment = 1 + +[node name="Sign12" type="Label" parent="StationSigns"] +offset_left = 5219.0 +offset_top = 467.0 +offset_right = 5641.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "12 Fan del Pogo Eterno\n>> Tapones del Tecnico" +horizontal_alignment = 1 + +[node name="Sign13" type="Label" parent="StationSigns"] +offset_left = 5669.0 +offset_top = 467.0 +offset_right = 6091.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "13 Tecnico del Feedback\n>> Tupper del Bateria" +horizontal_alignment = 1 + +[node name="Sign14" type="Label" parent="StationSigns"] +offset_left = 6119.0 +offset_top = 467.0 +offset_right = 6541.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "14 Guardia del Camerino\n>> Botas del Doble Bombo" +horizontal_alignment = 1 + +[node name="Sign15" type="Label" parent="StationSigns"] +offset_left = 6569.0 +offset_top = 467.0 +offset_right = 6991.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "15 Guitarrista Rival\n>> Muelles del Stage Diving" +horizontal_alignment = 1 + +[node name="Sign16" type="Label" parent="StationSigns"] +offset_left = 7019.0 +offset_top = 467.0 +offset_right = 7441.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "16 Roadie del Mas Alla\n>> Baqueta Sismica" +horizontal_alignment = 1 + +[node name="Sign17" type="Label" parent="StationSigns"] +offset_left = 7469.0 +offset_top = 467.0 +offset_right = 7891.0 +offset_bottom = 515.0 +theme_override_colors/font_color = Color(0.98, 0.92, 0.72, 1) +theme_override_colors/font_shadow_color = Color(0.04, 0.03, 0.08, 0.95) +theme_override_constants/shadow_offset_x = 2 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 11 +text = "17 Fan del Pogo Eterno\n>> Amplificador al 11" +horizontal_alignment = 1 [node name="FinishZone" type="Area2D" parent="."] -position = Vector2(1280, 600) +collision_layer = 0 +collision_mask = 2 +position = Vector2(8180, 535) -[node name="FinishShape" type="CollisionShape2D" parent="FinishZone"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="FinishZone"] shape = SubResource("FinishShape") -[node name="PowerUp" parent="." instance=ExtResource("5_pickup")] -position = Vector2(300, 440) -pickup_data = ExtResource("6_pua") - [node name="DeathZone" type="Area2D" parent="."] -position = Vector2(0, 680) +collision_layer = 0 +collision_mask = 2 +position = Vector2(4250, 770) -[node name="DeathShape" type="CollisionShape2D" parent="DeathZone"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="DeathZone"] shape = SubResource("DeathShape") -[node name="MessageLabel" type="Label" parent="."] -position = Vector2(376, 300) -size = Vector2(400, 60) -align = 1 -valign = 1 -text = "" -theme_override_colors/font_color = Color(1, 1, 1, 1) -theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9) +[node name="TestHUD" type="CanvasLayer" parent="."] +layer = 87 + +[node name="Overlay" type="Control" parent="TestHUD"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 + +[node name="Status" type="Label" parent="TestHUD/Overlay"] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -500.0 +offset_top = 16.0 +offset_right = -20.0 +offset_bottom = 72.0 +grow_horizontal = 0 +theme_override_colors/font_color = Color(1, 0.93, 0.68, 1) +theme_override_colors/font_shadow_color = Color(0.02, 0.02, 0.02, 0.95) theme_override_constants/shadow_offset_x = 2 theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 17 +text = "LAB THRASH 00 / 17" +horizontal_alignment = 2 + +[node name="FinishMessage" type="Label" parent="TestHUD/Overlay"] +layout_mode = 1 +anchor_left = 0.5 +anchor_top = 0.32 +anchor_right = 0.5 +anchor_bottom = 0.32 +offset_left = -330.0 +offset_top = -35.0 +offset_right = 330.0 +offset_bottom = 95.0 +theme_override_colors/font_color = Color(1, 0.90, 0.32, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) +theme_override_constants/shadow_offset_x = 3 +theme_override_constants/shadow_offset_y = 3 theme_override_font_sizes/font_size = 32 +horizontal_alignment = 1 +vertical_alignment = 1 visible = false -[node name="MobileControls" parent="." instance=ExtResource("4_mobile_controls")] +[node name="MobileControls" parent="." instance=ExtResource("2_mobile")] diff --git a/player/player.gd b/player/player.gd index 938a379..a1bccd5 100644 --- a/player/player.gd +++ b/player/player.gd @@ -4,6 +4,9 @@ extends CharacterBody2D signal health_changed(current_health: int, max_health: int) signal died signal special_charge_changed(current_charge: int, max_charge: int) +## Emitted only after an object successfully applies its effect. +## The test level uses this signal to count items actually collected. +signal pickup_collected(data: PickupData) # Collision layers used by this first playable slice. @@ -148,7 +151,8 @@ const ENEMY_HURTBOX_MASK: int = 1 << 4 ## Maximum damage dealt by the special (at full charge, closest to player). @export_range(0, 100, 1) var special_max_damage: int = 30 -## Radius no longer used for full-screen special; kept for backwards compatibility. +## Optional hard cutoff for the special. Very large = previous full-screen behaviour. +## The Level 01 test sets a smaller radius to keep encounters independent. @export var special_radius: float = 100000.0 @@ -508,6 +512,8 @@ func _apply_special_attack(charge_used: int = special_max_charge) -> void: continue var distance: float = global_position.distance_to(enemy.global_position) + if special_radius > 0.0 and distance > special_radius: + continue # Damage falls off with distance: maximum at the player, lower farther away # affects the whole screen (no hard circle cutoff) var distance_factor: float = 1.0 - clamp(distance / max_distance, 0.0, 1.0) @@ -578,6 +584,7 @@ func collect_pickup(data: PickupData) -> bool: _: push_warning("Unknown pickup effect: %s" % data.effect_type) return false + pickup_collected.emit(data) return true diff --git a/tests/test_level_01_resources.py b/tests/test_level_01_resources.py new file mode 100644 index 0000000..0e81b93 --- /dev/null +++ b/tests/test_level_01_resources.py @@ -0,0 +1,81 @@ +"""Static checks for the Android item test course (no Godot runtime needed). + +Run from the project root: python -m unittest discover -s tests -v +These tests check references and test-course configuration, not gameplay. +""" + +from pathlib import Path +import re +import unittest +from xml.etree import ElementTree + +ROOT = Path(__file__).resolve().parents[1] +SCENE = ROOT / "levels/level_01.tscn" + + +class Level01ConfigurationTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.scene = SCENE.read_text(encoding="utf-8") + cls.resources = dict( + re.findall(r'\[ext_resource [^\n]*path="res://([^"]+)" id="([^"]+)"\]', cls.scene) + ) + # Format is path -> id; invert to follow ExtResource("item_N"). + cls.by_id = {resource_id: path for path, resource_id in cls.resources.items()} + cls.stations = re.findall( + r'\[node name="Station(\d{2})" parent="TestEnemies" instance=ExtResource\("(v\d+)"\)\]' + r'\s*position = Vector2\(([\d.]+), ([\d.]+)\)' + r'\s*guaranteed_drop = ExtResource\("(item_\d+)"\)', + cls.scene, + ) + + def test_seventeen_different_guaranteed_drops(self): + self.assertEqual(len(self.stations), 17) + self.assertEqual([s[0] for s in self.stations], [f"{i:02d}" for i in range(1, 18)]) + files = [self.by_id[station[4]] for station in self.stations] + self.assertEqual(len(set(files)), 17) + for path in files: + self.assertTrue((ROOT / path).is_file(), path) + + def test_enemy_variants_disable_respawn(self): + self.assertEqual(len({station[1] for station in self.stations}), 5) + for station in self.stations: + scene_path = self.by_id[station[1]] + enemy_scene = (ROOT / scene_path).read_text(encoding="utf-8") + self.assertIn("respawn_delay = 0.0", enemy_scene) + self.assertIn("chase_radius = 135.0", enemy_scene) + + def test_floor_covers_all_encounters_and_finish(self): + xs = [float(station[2]) for station in self.stations] + self.assertEqual(xs, sorted(xs)) + self.assertTrue(all(0 <= x <= 8500 for x in xs)) + self.assertIn("size = Vector2(8500, 40)", self.scene) + self.assertIn("position = Vector2(8180, 535)", self.scene) + self.assertIn("camera.limit_right = LEVEL_WIDTH", (ROOT / "levels/level_01.gd").read_text()) + + def test_finish_and_death_areas_detect_player_layer(self): + for area in ("FinishZone", "DeathZone"): + definition = re.search( + rf'\[node name="{area}" type="Area2D" parent="\."\](.*?)(?=\n\[node )', + self.scene, + re.S, + ) + self.assertIsNotNone(definition) + self.assertIn("collision_mask = 2", definition.group(1)) + + def test_every_enemy_svg_is_valid_and_present(self): + folder = ROOT / "assets/enemies" + sprites = sorted(folder.glob("*.svg")) + self.assertEqual(len(sprites), 5) + for svg in sprites: + root = ElementTree.parse(svg).getroot() + self.assertEqual(root.attrib["viewBox"], "0 0 32 56") + self.assertTrue(len(root) > 20, svg.name) + + def test_all_external_scene_references_exist(self): + for path in self.resources: + self.assertTrue((ROOT / path).is_file(), path) + + +if __name__ == "__main__": + unittest.main() diff --git a/ui/hud/player_health_hud.gd b/ui/hud/player_health_hud.gd index ff4c572..edc829a 100644 --- a/ui/hud/player_health_hud.gd +++ b/ui/hud/player_health_hud.gd @@ -10,36 +10,45 @@ extends CanvasLayer @onready var health_bar: ProgressBar = $HUD/HealthBar @onready var health_label: Label = $HUD/HealthBar/HealthLabel -@onready var speed_label: Label = $HUD/SpeedLabel +@onready var effects_label: Label = $HUD/EffectsLabel var player_ref: Node func _ready() -> void: - var player: Node = get_parent() - player_ref = player - if player == null or not player.has_signal(&"health_changed"): - push_error("PlayerHealthHUD must be a child of a Player with health_changed signal.") + player_ref = get_parent() + if not player_ref.has_signal(&"health_changed"): + push_error("PlayerHealthHUD must be a child of a Player.") return - - # Child _ready() runs before Player._ready(). We connect here first and the - # Player will emit its initial health value a moment later during its _ready(). - player.connect(&"health_changed", _on_health_changed) - if speed_label: - speed_label.visible = false + # Children enter _ready before Player. Its initial signal arrives afterward. + player_ref.connect(&"health_changed", _on_health_changed) + effects_label.visible = false func _process(_delta: float) -> void: - if player_ref == null or speed_label == null: + if player_ref == null: return - if "get" in player_ref and player_ref.has_method("get"): - pass - var t = player_ref.get("_speed_boost_timer") - if t != null and float(t) > 0.0: - speed_label.visible = true - speed_label.text = "SPEED UP: %ds" % int(float(t)) - else: - speed_label.visible = false + + # Display each active effect individually: essential when validating all + # eight pickup families on a phone. Property names match Player's timers. + var active: Array[String] = [] + for effect in [ + ["VELOCIDAD", "_speed_boost_timer"], + ["DANO", "_damage_boost_timer"], + ["GOLPE AEREO", "_air_damage_boost_timer"], + ["DEFENSA", "_damage_reduction_timer"], + ["SALTO", "_jump_boost_timer"], + ]: + var seconds: float = float(player_ref.get(effect[1])) + if seconds > 0.0: + active.append("%s: %ds" % [effect[0], ceili(seconds)]) + + var shield_hits: int = int(player_ref.get("_shield_hits")) + if shield_hits > 0: + active.append("ESCUDO: %d golpe(s)" % shield_hits) + + effects_label.visible = not active.is_empty() + effects_label.text = "\n".join(active) func _on_health_changed(current_health: int, max_health: int) -> void: diff --git a/ui/hud/player_health_hud.tscn b/ui/hud/player_health_hud.tscn index 2bcb2aa..486487c 100644 --- a/ui/hud/player_health_hud.tscn +++ b/ui/hud/player_health_hud.tscn @@ -64,16 +64,16 @@ text = "HP 5 / 5" horizontal_alignment = 1 vertical_alignment = 1 -[node name="SpeedLabel" type="Label" parent="HUD"] +[node name="EffectsLabel" type="Label" parent="HUD"] layout_mode = 0 offset_left = 18.0 -offset_top = 70.0 -offset_right = 278.0 -offset_bottom = 98.0 +offset_top = 106.0 +offset_right = 298.0 +offset_bottom = 255.0 theme_override_colors/font_color = Color(1, 0.8, 0.2, 1) theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9) theme_override_font_sizes/font_size = 16 -text = "SPEED UP: 0s" -horizontal_alignment = 1 -vertical_alignment = 1 +text = "VELOCIDAD: 0s" +horizontal_alignment = 0 +vertical_alignment = 0 visible = false diff --git a/ui/hud/special_charge_hud.tscn b/ui/hud/special_charge_hud.tscn index 1f61a9c..4ed6130 100644 --- a/ui/hud/special_charge_hud.tscn +++ b/ui/hud/special_charge_hud.tscn @@ -15,9 +15,9 @@ mouse_filter = 2 [node name="SpecialBar" type="ProgressBar" parent="HUD"] offset_left = 18.0 -offset_top = 44.0 -offset_right = 220.0 -offset_bottom = 64.0 +offset_top = 74.0 +offset_right = 278.0 +offset_bottom = 94.0 max_value = 100.0 value = 0.0 show_percentage = false