better animations

This commit is contained in:
2025-10-28 03:54:41 +01:00
parent f6fe381551
commit 527be3ee5d
14 changed files with 266 additions and 115 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 341 B

After

Width:  |  Height:  |  Size: 341 B

View File

@@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://c12v1hnrbfjr4"
path="res://.godot/imported/hood_player.png-6c2f9e5710e5416c4bf1853ba3b50627.ctex"
uid="uid://5pbgeg3yx6cd"
path="res://.godot/imported/heart.png-0efefdd245172a860e354a0c110700fc.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/spritesheets/hood_player.png"
dest_files=["res://.godot/imported/hood_player.png-6c2f9e5710e5416c4bf1853ba3b50627.ctex"]
source_file="res://assets/textures/heart.png"
dest_files=["res://.godot/imported/heart.png-0efefdd245172a860e354a0c110700fc.ctex"]
[params]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d06cv484ev2n3"
path="res://.godot/imported/normal_player.png-10c614975074abda4b71ba9e3b00e8a5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/spritesheets/normal_player.png"
dest_files=["res://.godot/imported/normal_player.png-10c614975074abda4b71ba9e3b00e8a5.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

View File

Before

Width:  |  Height:  |  Size: 832 B

After

Width:  |  Height:  |  Size: 832 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dcnjviy00bral"
path="res://.godot/imported/ui.png-672916795adc5b950ad76092e3ec29b8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/ui.png"
dest_files=["res://.godot/imported/ui.png-672916795adc5b950ad76092e3ec29b8.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

View File

@@ -13,7 +13,7 @@ func _ready() -> void:
if EventManager.current_event == EventManager.Events.PUMPKIN_CARVE:
var chair: StaticBody2D = $Chair
var player: Player = $Player
chair._on_interacted(player)
chair.mount_player(player)
RenderingServer.set_default_clear_color(\"#0d0805\")
"
@@ -104,9 +104,9 @@ texture_region_size = Vector2i(32, 32)
0:0/0 = 0
1:0/0 = 0
0:1/0 = 0
0:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-12, -4, 16, -4, 16, 16, -12, 16)
0:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-12, 5.5, 16, 5.5, 16, 16, -12, 16)
1:1/0 = 0
1:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -4, 12, -4, 12, 16, -16, 16)
1:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 5.5, 12, 5.5, 12, 16, -16, 16)
0:2/0 = 0
0:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-11.5, -16, 16, -16, 16, -7, -2, -7, -2, 7, -8, 7)
1:2/0 = 0
@@ -125,6 +125,7 @@ y_sort_enabled = true
script = SubResource("GDScript_2vl8h")
[node name="TileMapLayer" type="TileMapLayer" parent="."]
z_index = -1
tile_map_data = PackedByteArray("AAAHAAYAAQABAAEAAAAHAAUAAQABAAEAAAAHAAQAAQABAAEAAAAHAAMAAQABAAEAAAAGAAYAAQABAAEAAAAGAAUAAQABAAEAAAAGAAQAAQABAAEAAAAGAAMAAQABAAEAAAAFAAYAAQABAAEAAAAFAAUAAQABAAEAAAAFAAQAAQABAAEAAAAFAAMAAQABAAEAAAAEAAYAAQABAAEAAAAEAAUAAQABAAEAAAAEAAQAAQABAAEAAAAEAAMAAQABAAEAAAADAAYAAQABAAEAAAADAAUAAQABAAEAAAADAAQAAQABAAEAAAADAAMAAQABAAEAAAACAAQAAQAAAAEAAAACAAMAAQAAAAEAAAACAAIAAQAAAAAAAAADAAIAAQABAAAAAAAEAAIAAQABAAAAAAACAAUAAQAAAAEAAAACAAYAAQAAAAEAAAAEAAcAAQABAAIAAAADAAcAAQABAAIAAAACAAcAAQAAAAIAAAAFAAIAAQAAAAMAAAAGAAIAAQABAAAAAAAGAAcAAQABAAIAAAAHAAIAAQABAAAAAAAHAAcAAQABAAIAAAAIAAMAAQACAAEAAAAIAAQAAQACAAEAAAAIAAIAAQACAAAAAAAIAAUAAQACAAEAAAAIAAYAAQACAAEAAAAIAAcAAQACAAIAAAAFAAcAAQABAAEAAAA=")
tile_set = SubResource("TileSet_ikf4c")
@@ -156,9 +157,6 @@ y_sort_enabled = true
position = Vector2(176, 235)
tilemap = NodePath("../TileMapLayer")
[node name="AnimatedSprite2D" parent="Player" index="0"]
animation = &"up"
[node name="InteractSceneswitch" parent="." instance=ExtResource("4_snitx")]
position = Vector2(176, 268)
scene = "res://scenes/levels/hood.tscn"

View File

@@ -1,52 +1,163 @@
[gd_scene load_steps=15 format=3 uid="uid://dfbomt0l6b1o4"]
[gd_scene load_steps=22 format=3 uid="uid://dfbomt0l6b1o4"]
[ext_resource type="Script" uid="uid://dxvslwwnnlosy" path="res://scripts/player.gd" id="1_3vyb7"]
[ext_resource type="Texture2D" uid="uid://c12v1hnrbfjr4" path="res://assets/textures/spritesheets/hood_player.png" id="2_g2els"]
[sub_resource type="AtlasTexture" id="AtlasTexture_g2els"]
atlas = ExtResource("2_g2els")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
atlas = ExtResource("2_g2els")
region = Rect2(32, 0, 32, 32)
[ext_resource type="Texture2D" uid="uid://d06cv484ev2n3" path="res://assets/textures/spritesheets/normal_player.png" id="2_qhqgy"]
[sub_resource type="AtlasTexture" id="AtlasTexture_dqkch"]
atlas = ExtResource("2_g2els")
region = Rect2(64, 0, 32, 32)
atlas = ExtResource("2_qhqgy")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
atlas = ExtResource("2_g2els")
region = Rect2(0, 32, 32, 32)
atlas = ExtResource("2_qhqgy")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
atlas = ExtResource("2_g2els")
region = Rect2(32, 32, 32, 32)
atlas = ExtResource("2_qhqgy")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
atlas = ExtResource("2_g2els")
region = Rect2(64, 32, 32, 32)
atlas = ExtResource("2_qhqgy")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
atlas = ExtResource("2_g2els")
[sub_resource type="AtlasTexture" id="AtlasTexture_3v2ag"]
atlas = ExtResource("2_qhqgy")
region = Rect2(96, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_jej6c"]
atlas = ExtResource("2_qhqgy")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"]
atlas = ExtResource("2_qhqgy")
region = Rect2(0, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
atlas = ExtResource("2_g2els")
region = Rect2(0, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_oprun"]
atlas = ExtResource("2_qhqgy")
region = Rect2(64, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_y4r1p"]
atlas = ExtResource("2_g2els")
[sub_resource type="AtlasTexture" id="AtlasTexture_a8ls1"]
atlas = ExtResource("2_qhqgy")
region = Rect2(32, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qfm1y"]
atlas = ExtResource("2_qhqgy")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_fulsm"]
atlas = ExtResource("2_qhqgy")
region = Rect2(0, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_4r5pv"]
atlas = ExtResource("2_qhqgy")
region = Rect2(32, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_60mlk"]
atlas = ExtResource("2_qhqgy")
region = Rect2(32, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"]
atlas = ExtResource("2_g2els")
[sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
atlas = ExtResource("2_qhqgy")
region = Rect2(64, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_g2els"]
atlas = ExtResource("2_qhqgy")
region = Rect2(64, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
atlas = ExtResource("2_qhqgy")
region = Rect2(96, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
atlas = ExtResource("2_qhqgy")
region = Rect2(0, 64, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_qhqgy"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_dqkch")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qlg0r")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dqkch")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tuyoq")
}],
"loop": true,
"name": &"down",
"speed": 6.5
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fjrip")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3v2ag")
}],
"loop": true,
"name": &"hand_down",
"speed": 3.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_jej6c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_f1ej7")
}],
"loop": true,
"name": &"hand_side",
"speed": 3.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_oprun")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_a8ls1")
}],
"loop": true,
"name": &"hand_up",
"speed": 3.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qfm1y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fulsm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qfm1y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4r5pv")
}],
"loop": true,
"name": &"side",
"speed": 6.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_60mlk")
}],
"loop": true,
"name": &"sit_down",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_smehm")
}],
"loop": true,
"name": &"sit_side",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_g2els")
}, {
"duration": 1.0,
@@ -56,49 +167,7 @@ animations = [{
"texture": SubResource("AtlasTexture_g2els")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dqkch")
}],
"loop": true,
"name": &"down",
"speed": 6.5
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qlg0r")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tuyoq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qlg0r")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fjrip")
}],
"loop": true,
"name": &"side",
"speed": 6.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_smehm")
}],
"loop": true,
"name": &"sit",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ur7pv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y4r1p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ur7pv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_d2wvv")
}],
"loop": true,
"name": &"up",

View File

@@ -4,63 +4,67 @@ extends StaticBody2D
enum Direction { LEFT, RIGHT, FRONT }
@onready var sprite: Sprite2D = $Sprite2D
const SEAT_HEIGHT_OFFSET := 8
@onready var collision_shape: CollisionShape2D = $CollisionShape2D
var seat_height_offset = 8
var player: Player
var input_released: bool = true
var move_input: Vector2 = Vector2.ZERO
var input_released = true
var move_input = Vector2.ZERO
@export var direction: Direction = Direction.RIGHT:
set(value):
direction = value
flip_chair()
update_chair_visuals()
func _ready() -> void:
flip_chair()
update_chair_visuals()
func flip_chair() -> void:
if !sprite:
func update_chair_visuals() -> void:
if not sprite:
return
var atlas_tex := sprite.texture as AtlasTexture
match direction:
Direction.LEFT:
atlas_tex.region.position.x = 32
sprite.flip_h = true
Direction.RIGHT:
atlas_tex.region.position.x = 32
sprite.flip_h = false
Direction.FRONT:
atlas_tex.region.position.x = -3
sprite.flip_h = false
var atlas_tex = sprite.texture as AtlasTexture
if direction == Direction.FRONT:
atlas_tex.region.position.x = -3
seat_height_offset = -5
sprite.flip_h = false
else:
atlas_tex.region.position.x = 32
seat_height_offset = 8
sprite.flip_h = direction == Direction.LEFT
func _on_interacted(p_player: Player) -> void:
if player:
unmount()
unmount_player()
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
player.position = Vector2(position.x, position.y - SEAT_HEIGHT_OFFSET)
mount_player(p_player)
func mount_player(p_player: Player) -> void:
collision_shape.disabled = true
y_sort_enabled = false
z_index = -1
player = p_player
input_released = move_input.length() == 0
player.animated_sprite.flip_h = direction == Direction.LEFT
player.position = Vector2(position.x, position.y - seat_height_offset)
player.animated_sprite.animation = "sit_down" if direction == Direction.FRONT else "sit_side"
func _process(_delta: float) -> void:
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
elif input_released:
unmount()
if Engine.is_editor_hint() || !EventManager.player_free || !player:
return
move_input = Input.get_vector("move_left", "move_right", "move_up", "move_down")
if move_input.length() == 0:
input_released = true
elif input_released:
unmount_player()
func unmount() -> void:
func unmount_player() -> void:
if direction == Direction.FRONT:
player.position = Vector2(position.x -16, position.y)
player.position = Vector2(position.x - 16, position.y)
else:
player.position = Vector2(position.x, position.y + 8)
player.animated_sprite.animation = "down"
player.z_index = 0
z_index = 0
player = null
input_released = true
y_sort_enabled = true
collision_shape.disabled = false