idk
This commit is contained in:
@@ -16,15 +16,16 @@ func transition_end() -> void:
|
||||
|
||||
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:
|
||||
player_free = false
|
||||
get_tree().change_scene_to_file("uid://ccfdsdgaon63m") # scenes/levels/home.tscn
|
||||
|
||||
transition_end()
|
||||
transition_scene_file("uid://ccfdsdgaon63m") # scenes/levels/home.tscn
|
||||
await get_tree().scene_changed
|
||||
await get_tree().create_timer(2).timeout
|
||||
var pumpkin_carve: Control = preload("res://scenes/menus/pumpkin_carve.tscn").instantiate()
|
||||
add_child(pumpkin_carve)
|
||||
|
||||
func transition_scene_file(scene: String) -> void:
|
||||
if !animation_player.is_playing():
|
||||
|
||||
@@ -5,7 +5,9 @@ signal interacted(player: Player)
|
||||
|
||||
@export var auto_interact: bool = false
|
||||
|
||||
func interact(player: Player) -> void: interacted.emit(player)
|
||||
func interact(player: Player) -> void:
|
||||
if !auto_interact:
|
||||
interacted.emit(player)
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
|
||||
@@ -36,7 +36,9 @@ func _on_interacted(p_player: Player) -> void:
|
||||
if player:
|
||||
unmount()
|
||||
else:
|
||||
y_sort_enabled = false
|
||||
player = p_player
|
||||
player.z_index = 2
|
||||
input_released = move_input.length() == 0
|
||||
player.animated_sprite.animation = "sit"
|
||||
player.animated_sprite.flip_h = direction == Direction.LEFT
|
||||
@@ -58,5 +60,7 @@ func unmount() -> void:
|
||||
else:
|
||||
player.position = Vector2(position.x, position.y + 8)
|
||||
player.animated_sprite.animation = "down"
|
||||
player.z_index = 0
|
||||
player = null
|
||||
input_released = true
|
||||
y_sort_enabled = true
|
||||
|
||||
@@ -8,14 +8,23 @@ var drawing: bool = false
|
||||
var erasing: bool = false
|
||||
var undo_stack: Array[Image] = []
|
||||
var bgimage: Image
|
||||
var save_path: String = "user://pumpkin_carving.png"
|
||||
|
||||
func _ready() -> void:
|
||||
image = Image.create_empty(32, 32, false, Image.FORMAT_RGBA8)
|
||||
dtexture = $DrawTexture
|
||||
bgtexture = $Background
|
||||
bgimage = bgtexture.texture.get_image()
|
||||
load_image()
|
||||
update_texture()
|
||||
|
||||
func load_image() -> void:
|
||||
if FileAccess.file_exists(save_path):
|
||||
var loaded: Image = Image.load_from_file(save_path)
|
||||
if loaded:
|
||||
image = loaded
|
||||
return
|
||||
image = Image.create_empty(32, 32, false, Image.FORMAT_RGBA8)
|
||||
|
||||
func update_texture() -> void:
|
||||
var texture: ImageTexture = ImageTexture.create_from_image(image)
|
||||
dtexture.texture = texture
|
||||
@@ -40,14 +49,15 @@ func draw_at_mouse() -> void:
|
||||
var color: Color = Color.BLACK if not erasing else Color(0, 0, 0, 0)
|
||||
pixel(pixel_pos, color)
|
||||
update_texture()
|
||||
save_image()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed and not event.is_echo():
|
||||
if event.keycode == KEY_Z and Input.is_key_pressed(KEY_CTRL):
|
||||
undo()
|
||||
return
|
||||
|
||||
if event is InputEventMouseButton and not event.is_echo():
|
||||
if event is InputEventMouseButton and !event.is_echo():
|
||||
var mouse_pos = get_global_mouse_position()
|
||||
var drect = dtexture.get_global_rect()
|
||||
if not drect.has_point(mouse_pos):
|
||||
return
|
||||
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if event.pressed:
|
||||
push_undo_state()
|
||||
@@ -72,3 +82,10 @@ func undo() -> void:
|
||||
if undo_stack.size() > 0:
|
||||
image = undo_stack.pop_back()
|
||||
update_texture()
|
||||
save_image()
|
||||
|
||||
func save_image() -> void:
|
||||
image.save_png(save_path)
|
||||
|
||||
func _on_undo_button_pressed() -> void:
|
||||
undo()
|
||||
|
||||
@@ -72,5 +72,5 @@ func _physics_process(delta: float) -> void:
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouse:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
elif !event.is_action("escape"):
|
||||
elif EventManager.player_free && !EventManager.animation_player.is_playing() && !event.is_action("escape"):
|
||||
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
|
||||
|
||||
Reference in New Issue
Block a user