diff --git a/aseprite/knife.aseprite b/aseprite/knife.aseprite new file mode 100644 index 0000000..661d0cd Binary files /dev/null and b/aseprite/knife.aseprite differ diff --git a/aseprite/pumpkin.aseprite b/aseprite/pumpkin.aseprite new file mode 100644 index 0000000..651d51f Binary files /dev/null and b/aseprite/pumpkin.aseprite differ diff --git a/aseprite/pumpkin_inner.aseprite b/aseprite/pumpkin_inner.aseprite new file mode 100644 index 0000000..fccfd26 Binary files /dev/null and b/aseprite/pumpkin_inner.aseprite differ diff --git a/aseprite/pumpkin_outer.aseprite b/aseprite/pumpkin_outer.aseprite new file mode 100644 index 0000000..cabf42b Binary files /dev/null and b/aseprite/pumpkin_outer.aseprite differ diff --git a/aseprite/tileset_grass_random.aseprite b/aseprite/tileset_grass_random.aseprite index 3a6291d..5f9b7e0 100644 Binary files a/aseprite/tileset_grass_random.aseprite and b/aseprite/tileset_grass_random.aseprite differ diff --git a/assets/textures/knife.png b/assets/textures/knife.png new file mode 100644 index 0000000..13f7d55 Binary files /dev/null and b/assets/textures/knife.png differ diff --git a/assets/textures/knife.png.import b/assets/textures/knife.png.import new file mode 100644 index 0000000..5c9a92d --- /dev/null +++ b/assets/textures/knife.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bdd7wo7tepih2" +path="res://.godot/imported/knife.png-d0b6856fee8a5dcf1feec66ef7daeb45.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/knife.png" +dest_files=["res://.godot/imported/knife.png-d0b6856fee8a5dcf1feec66ef7daeb45.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/pumpkin_inner.png b/assets/textures/pumpkin_inner.png new file mode 100644 index 0000000..8bd12ad Binary files /dev/null and b/assets/textures/pumpkin_inner.png differ diff --git a/assets/textures/pumpkin_inner.png.import b/assets/textures/pumpkin_inner.png.import new file mode 100644 index 0000000..1d3d23a --- /dev/null +++ b/assets/textures/pumpkin_inner.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cb8q0hsocixew" +path="res://.godot/imported/pumpkin_inner.png-09a1a9c2eccf0bfd935208992baba1e9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/pumpkin_inner.png" +dest_files=["res://.godot/imported/pumpkin_inner.png-09a1a9c2eccf0bfd935208992baba1e9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/pumpkin_outer.png b/assets/textures/pumpkin_outer.png new file mode 100644 index 0000000..e8e1e14 Binary files /dev/null and b/assets/textures/pumpkin_outer.png differ diff --git a/assets/textures/pumpkin_outer.png.import b/assets/textures/pumpkin_outer.png.import new file mode 100644 index 0000000..98a4123 --- /dev/null +++ b/assets/textures/pumpkin_outer.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dk62sk18o0jhp" +path="res://.godot/imported/pumpkin_outer.png-b381283070c32cbe06882a52feb92ecc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/pumpkin_outer.png" +dest_files=["res://.godot/imported/pumpkin_outer.png-b381283070c32cbe06882a52feb92ecc.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/tilemaps/grass_tilemap.png b/assets/textures/tilemaps/grass_tilemap.png index 2bbaff8..319ee1b 100644 Binary files a/assets/textures/tilemaps/grass_tilemap.png and b/assets/textures/tilemaps/grass_tilemap.png differ diff --git a/project.godot b/project.godot index 8218eea..8cadbae 100644 --- a/project.godot +++ b/project.godot @@ -36,6 +36,7 @@ window/size/window_width_override=1152 window/size/window_height_override=640 window/stretch/mode="viewport" display_server/driver.linuxbsd="wayland" +mouse_cursor/custom_image="uid://bdd7wo7tepih2" window/size/mode.release=4 [editor_plugins] diff --git a/scenes/autoloads/event_manager.tscn b/scenes/autoloads/event_manager.tscn index cacbf67..ecd3517 100644 --- a/scenes/autoloads/event_manager.tscn +++ b/scenes/autoloads/event_manager.tscn @@ -2,6 +2,21 @@ [ext_resource type="Script" uid="uid://b08q3lqbuoolb" path="res://scripts/autoloads/nodes/event_manager.gd" id="1_xplee"] +[sub_resource type="Animation" id="Animation_swnhv"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:self_modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 0)] +} + [sub_resource type="Animation" id="Animation_xplee"] resource_name = "transition" length = 0.5 @@ -18,21 +33,6 @@ tracks/0/keys = { "values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] } -[sub_resource type="Animation" id="Animation_swnhv"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("ColorRect:self_modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Color(1, 1, 1, 0)] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_gml0k"] _data = { &"RESET": SubResource("Animation_swnhv"), diff --git a/scenes/levels/home.tscn b/scenes/levels/home.tscn index c928a3d..0c81552 100644 --- a/scenes/levels/home.tscn +++ b/scenes/levels/home.tscn @@ -9,6 +9,10 @@ script/source = "extends Node2D func _ready() -> void: + if EventManager.current_event == EventManager.Events.PUMPKIN_CARVE: + var chair: StaticBody2D = $Chair + var player: Player = $Player + chair._on_interacted(player) RenderingServer.set_default_clear_color(\"#0d0805\") " diff --git a/scenes/menus/pumpkin_carve.tscn b/scenes/menus/pumpkin_carve.tscn new file mode 100644 index 0000000..bb1e5ac --- /dev/null +++ b/scenes/menus/pumpkin_carve.tscn @@ -0,0 +1,70 @@ +[gd_scene load_steps=5 format=3 uid="uid://dh8wt018qxj2y"] + +[ext_resource type="Script" uid="uid://b5c8ov4lhocb8" path="res://scripts/menus/pumpkin_carve.gd" id="1_vvdcc"] +[ext_resource type="Texture2D" uid="uid://cb8q0hsocixew" path="res://assets/textures/pumpkin_inner.png" id="2_fcp78"] +[ext_resource type="Texture2D" uid="uid://dk62sk18o0jhp" path="res://assets/textures/pumpkin_outer.png" id="3_0qx04"] + +[sub_resource type="ImageTexture" id="ImageTexture_vvdcc"] + +[node name="PumpkinCarve" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_vvdcc") + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 0.2784314) + +[node name="Background" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -80.0 +offset_top = -80.0 +offset_right = 80.0 +offset_bottom = 80.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_fcp78") + +[node name="DrawTexture" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -80.0 +offset_top = -80.0 +offset_right = 80.0 +offset_bottom = 80.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("ImageTexture_vvdcc") + +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -80.0 +offset_top = -80.0 +offset_right = 80.0 +offset_bottom = 80.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_0qx04") diff --git a/scripts/autoloads/nodes/event_manager.gd b/scripts/autoloads/nodes/event_manager.gd index a7e539a..f9d7eb6 100644 --- a/scripts/autoloads/nodes/event_manager.gd +++ b/scripts/autoloads/nodes/event_manager.gd @@ -9,13 +9,10 @@ enum Events { NONE, PUMPKIN_CARVE, OUTSIDE_NORMAL } var current_event: Events = Events.NONE func transition_start() -> void: - player_free = false animation_player.play("transition") func transition_end() -> void: animation_player.play_backwards("transition") - await animation_player.animation_finished - player_free = true func run_event(event: Events, player_postion: Vector2 = Vector2.ZERO): current_event = event @@ -24,9 +21,9 @@ func run_event(event: Events, player_postion: Vector2 = 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 - await get_tree().scene_changed - player.animated_sprite.animation = "sit" # should be replaced with chair interaction trigger + transition_end() func transition_scene_file(scene: String) -> void: diff --git a/scripts/autoloads/windowman.gd b/scripts/autoloads/windowman.gd index 67e2648..ad6582c 100644 --- a/scripts/autoloads/windowman.gd +++ b/scripts/autoloads/windowman.gd @@ -16,12 +16,6 @@ func _notification(what: int) -> void: if what == Window.NOTIFICATION_APPLICATION_FOCUS_OUT: Input.mouse_mode = Input.MOUSE_MODE_VISIBLE -func _unhandled_input(event: InputEvent) -> void: - if event is InputEventMouse: - Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - elif !event.is_action("escape"): - Input.mouse_mode = Input.MOUSE_MODE_HIDDEN - func toggle_fullscreen() -> void: if config.fullscreen: if OS.get_name() == "Windows": diff --git a/scripts/interactables/chair.gd b/scripts/interactables/chair.gd index b1dd0b0..b5c0157 100644 --- a/scripts/interactables/chair.gd +++ b/scripts/interactables/chair.gd @@ -44,7 +44,7 @@ func _on_interacted(p_player: Player) -> void: func _process(_delta: float) -> void: - if player: + if !Engine.is_editor_hint() && EventManager.player_free && player: move_input = Input.get_vector("move_left","move_right","move_up","move_down") if move_input.length() == 0: input_released = true diff --git a/scripts/menus/pumpkin_carve.gd b/scripts/menus/pumpkin_carve.gd new file mode 100644 index 0000000..8f12dc9 --- /dev/null +++ b/scripts/menus/pumpkin_carve.gd @@ -0,0 +1,74 @@ +extends Control + +var image: Image +var dtexture: TextureRect +var bgtexture: TextureRect + +var drawing: bool = false +var erasing: bool = false +var undo_stack: Array[Image] = [] +var bgimage: Image + +func _ready() -> void: + image = Image.create_empty(32, 32, false, Image.FORMAT_RGBA8) + dtexture = $DrawTexture + bgtexture = $Background + bgimage = bgtexture.texture.get_image() + update_texture() + +func update_texture() -> void: + var texture: ImageTexture = ImageTexture.create_from_image(image) + dtexture.texture = texture + +func push_undo_state() -> void: + var copy: Image = image.duplicate() + undo_stack.append(copy) + if undo_stack.size() > 20: + undo_stack.pop_front() + +func pixel(pposition: Vector2i, color: Color) -> void: + if pposition.x >= 0 and pposition.x < image.get_width() and pposition.y >= 0 and pposition.y < image.get_height(): + var bgcol: Color = bgimage.get_pixel(pposition.x, pposition.y) + if bgcol.a > 0.01: + image.set_pixel(pposition.x, pposition.y, color) + +func draw_at_mouse() -> void: + var lpos: Vector2 = dtexture.get_local_mouse_position() + var tex_size: Vector2 = Vector2(image.get_width(), image.get_height()) + var dscale: Vector2 = dtexture.get_size() / tex_size + var pixel_pos: Vector2i = (lpos / dscale).floor() + var color: Color = Color.BLACK if not erasing else Color(0, 0, 0, 0) + pixel(pixel_pos, color) + update_texture() + +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.button_index == MOUSE_BUTTON_LEFT: + if event.pressed: + push_undo_state() + drawing = true + erasing = false + draw_at_mouse() + else: + drawing = false + elif event.button_index == MOUSE_BUTTON_RIGHT: + if event.pressed: + push_undo_state() + erasing = true + drawing = true + draw_at_mouse() + else: + erasing = false + drawing = false + elif event is InputEventMouseMotion and drawing: + draw_at_mouse() + +func undo() -> void: + if undo_stack.size() > 0: + image = undo_stack.pop_back() + update_texture() diff --git a/scripts/menus/pumpkin_carve.gd.uid b/scripts/menus/pumpkin_carve.gd.uid new file mode 100644 index 0000000..c4d8f47 --- /dev/null +++ b/scripts/menus/pumpkin_carve.gd.uid @@ -0,0 +1 @@ +uid://b5c8ov4lhocb8 diff --git a/scripts/player.gd b/scripts/player.gd index d355706..28f6f55 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -35,12 +35,12 @@ func _ready() -> void: ) func _process(_delta: float) -> void: - if Input.is_action_just_pressed("interact") && raycast.is_colliding() && raycast.get_collider() is Interactable: + if EventManager.player_free && !EventManager.animation_player.is_playing() && Input.is_action_just_pressed("interact") && raycast.is_colliding() && raycast.get_collider() is Interactable: var interactable: Interactable = raycast.get_collider() interactable.interact(self) func _physics_process(delta: float) -> void: - if !STILL_POSITIONS.has(animated_sprite.animation) && EventManager.player_free: + if !STILL_POSITIONS.has(animated_sprite.animation) && EventManager.player_free && !EventManager.animation_player.is_playing(): var input := Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized() var raycast_input := Vector2.ZERO @@ -68,3 +68,9 @@ func _physics_process(delta: float) -> void: animated_sprite.animation = "down" else: animated_sprite.stop() + +func _unhandled_input(event: InputEvent) -> void: + if event is InputEventMouse: + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + elif !event.is_action("escape"): + Input.mouse_mode = Input.MOUSE_MODE_HIDDEN