pumpkin carving
This commit is contained in:
BIN
aseprite/knife.aseprite
Normal file
BIN
aseprite/knife.aseprite
Normal file
Binary file not shown.
BIN
aseprite/pumpkin.aseprite
Normal file
BIN
aseprite/pumpkin.aseprite
Normal file
Binary file not shown.
BIN
aseprite/pumpkin_inner.aseprite
Normal file
BIN
aseprite/pumpkin_inner.aseprite
Normal file
Binary file not shown.
BIN
aseprite/pumpkin_outer.aseprite
Normal file
BIN
aseprite/pumpkin_outer.aseprite
Normal file
Binary file not shown.
Binary file not shown.
BIN
assets/textures/knife.png
Normal file
BIN
assets/textures/knife.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 274 B |
40
assets/textures/knife.png.import
Normal file
40
assets/textures/knife.png.import
Normal file
@@ -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
|
||||
BIN
assets/textures/pumpkin_inner.png
Normal file
BIN
assets/textures/pumpkin_inner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 302 B |
40
assets/textures/pumpkin_inner.png.import
Normal file
40
assets/textures/pumpkin_inner.png.import
Normal file
@@ -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
|
||||
BIN
assets/textures/pumpkin_outer.png
Normal file
BIN
assets/textures/pumpkin_outer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 291 B |
40
assets/textures/pumpkin_outer.png.import
Normal file
40
assets/textures/pumpkin_outer.png.import
Normal file
@@ -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
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -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]
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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\")
|
||||
"
|
||||
|
||||
|
||||
70
scenes/menus/pumpkin_carve.tscn
Normal file
70
scenes/menus/pumpkin_carve.tscn
Normal file
@@ -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")
|
||||
@@ -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:
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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
|
||||
|
||||
74
scripts/menus/pumpkin_carve.gd
Normal file
74
scripts/menus/pumpkin_carve.gd
Normal file
@@ -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()
|
||||
1
scripts/menus/pumpkin_carve.gd.uid
Normal file
1
scripts/menus/pumpkin_carve.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b5c8ov4lhocb8
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user