event system and keyboard
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
1
scripts/menus/util/keyboard.gd
Normal file
1
scripts/menus/util/keyboard.gd
Normal file
@@ -0,0 +1 @@
|
||||
extends Control
|
||||
1
scripts/menus/util/keyboard.gd.uid
Normal file
1
scripts/menus/util/keyboard.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bxquk4wo56r22
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user