Reorganize project structure into scenes and scripts directories
- Move core game objects (player, enemy, projectile, cassette, phonebooth) to scenes/core/
- Move UI helpers (title, pause_screen, game_over, speech) to scenes/helpers/
- Move puzzle logic (phonephreak) to scenes/puzzles/
- Move global utilities to scripts/
- Consolidate levels in scenes/levels/ with new base_level structure
- Fix naming conventions (snake_case for scripts)
- Remove obsolete test and duplicate scenes
47 lines
814 B
GDScript
47 lines
814 B
GDScript
extends CharacterBody2D
|
|
|
|
|
|
var SPEED = Vector2(5, 0)
|
|
const JUMP_VELOCITY = -400.0
|
|
@onready var projectile: PackedScene = preload("res://scenes/core/projectile.tscn")
|
|
var death_counter = 3
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
$Timer.start()
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
if death_counter == 2:
|
|
$ColorRect4.hide()
|
|
if death_counter == 1:
|
|
$ColorRect3.hide()
|
|
if death_counter == 0:
|
|
queue_free()
|
|
velocity += get_gravity() * delta
|
|
move_and_slide()
|
|
patrol()
|
|
|
|
|
|
func patrol():
|
|
position += SPEED
|
|
|
|
|
|
func _on_timer_timeout() -> void:
|
|
SPEED = -SPEED
|
|
$Timer.start()
|
|
|
|
|
|
func _on_area_2d_area_entered(area: Area2D) -> void:
|
|
if GlobalData.hurtable:
|
|
death_counter -= 1
|
|
elif GlobalData.weapon == 2:
|
|
death_counter -= 1
|
|
|
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
|
GlobalData.death_counter -= 1
|