event system and keyboard

This commit is contained in:
2025-10-16 00:54:49 +02:00
parent f87cc28c57
commit 69c3e6f396
11 changed files with 313 additions and 6 deletions

View File

@@ -1,6 +1,24 @@
extends Node
var player_free: bool = true
var player: Player
func transition() -> void:
enum Events { NONE, PUMPKIN_CARVE, OUTSIDE_NORMAL }
var current_event: Events = Events.NONE
func transition_start() -> void:
pass
func transition_end() -> void:
pass
func run_event(event: Events, player_postion: Vector2 = Vector2.ZERO):
current_event = event
transition_start()
if player != null && player_postion != Vector2.ZERO:
player.position = player_postion
match event:
Events.PUMPKIN_CARVE:
get_tree().change_scene_to_file("uid://ccfdsdgaon63m") # scenes/levels/home.tscn
pass
transition_end()

View File

@@ -28,7 +28,7 @@ func update_name() -> void:
next.text = "Finish"
elif index > max_index:
profile.save()
index = max_index
EventManager.run_event(EventManager.Events.PUMPKIN_CARVE)
return
else:
next.text = "Next"

View File

@@ -0,0 +1 @@
extends Control

View File

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

View File

@@ -1,3 +1,4 @@
class_name Player
extends CharacterBody2D
const SPEED: int = 800
@@ -9,6 +10,7 @@ var tilesize: int = 32
var position_limit_rect: Rect2
func _ready() -> void:
EventManager.player = self
var used_tilemap_rect: Rect2i = tilemap.get_used_rect()
tilesize = tilemap.tile_set.tile_size.x