New player icon and animation logic to fit

master
Wynd 2024-09-22 12:58:04 +03:00
parent c5b441196b
commit f7d3ad7fa3
6 changed files with 266 additions and 48 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://384kxu6h01cg"
path="res://.godot/imported/player.png-139ba3f081436b64d7138d89f31a95e2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/assets/player.png"
dest_files=["res://.godot/imported/player.png-139ba3f081436b64d7138d89f31a95e2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

@ -2,7 +2,7 @@ class_name Player
extends CharacterBody2D
@onready var raycast: RayCast2D = $RayCast2D
@onready var sprite: Sprite2D = $Sprite2D
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var map: MainLevel = get_tree().root.get_child(0).get_node("TileMap")
@onready var tile_map: TileMapLayer = get_tree().root.get_child(0).get_node("TileMap/TileMapLayer")
@onready var camera: Camera2D = $Sprite2D/Camera2D
@ -23,6 +23,7 @@ var can_teleport := true
var rng := RandomNumberGenerator.new()
var camera_shake: float = 0.0
var camera_shake_fade: float = 0.0
var attack_frame := 0
func _ready():
_respawn()
@ -43,6 +44,8 @@ func _physics_process(delta):
_try_move(delta)
func _respawn():
sprite.stop()
sprite.frame = 0
if checkpoints.size() > 0 and checkpoints[current_checkpoint]:
position = checkpoints[current_checkpoint].position
else:
@ -66,8 +69,18 @@ func _try_get_input():
elif Input.is_action_pressed("move_left"):
input_dir = Vector2.LEFT
should_move = true
_change_sprite()
if attack_frame > 0:
attack_frame -= 1
if not should_move and not is_moving and attack_frame <= 0:
sprite.frame = 0
sprite.stop()
if should_move and not is_moving:
sprite.play()
raycast.target_position = input_dir * 8
raycast.force_raycast_update()
@ -90,6 +103,19 @@ func _try_get_input():
is_moving = true
sprite.global_position = tile_map.map_to_local(current_tile)
func _change_sprite():
var is_attacking = attack_frame > 0
if not is_attacking:
if input_dir == Vector2.UP:
sprite.animation = &"move_up"
elif input_dir == Vector2.RIGHT:
sprite.animation = &"move_right"
sprite.flip_h = false
elif input_dir == Vector2.DOWN:
sprite.animation = &"move_down"
elif input_dir == Vector2.LEFT:
sprite.animation = &"move_right"
sprite.flip_h = true
func _try_move(delta: int):
if not is_moving or is_dead:
@ -113,13 +139,13 @@ func apply_camera_shake(strength: float = 10.0, fade: float = 5.0):
func _try_interact():
raycast.target_position = input_dir * 8
raycast.force_raycast_update()
var collider = raycast.get_collider()
if Input.is_action_just_pressed("attack") and collider:
if collider is PuzzleElement:
if Input.is_action_just_pressed("attack"):
sprite.play(&"spin")
attack_frame = 50
var collider = raycast.get_collider()
if collider and collider is PuzzleElement:
(collider as PuzzleElement).interact(self)
pass
pass
func teleport(pos: Vector2i):
global_position = pos

View File

@ -1,39 +1,198 @@
[gd_scene load_steps=8 format=3 uid="uid://dpn82ibpmpb6u"]
[gd_scene load_steps=29 format=3 uid="uid://dpn82ibpmpb6u"]
[ext_resource type="Script" path="res://entities/player/player.gd" id="1_jrd75"]
[ext_resource type="Texture2D" uid="uid://dxkxa6e6ue1b6" path="res://entities/assets/bat.png" id="1_qfnf0"]
[ext_resource type="Texture2D" uid="uid://384kxu6h01cg" path="res://entities/assets/player.png" id="2_la6m6"]
[sub_resource type="AtlasTexture" id="AtlasTexture_7830n"]
atlas = ExtResource("2_la6m6")
region = Rect2(0, 16, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_hxarw"]
atlas = ExtResource("2_la6m6")
region = Rect2(8, 16, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_ldeja"]
atlas = ExtResource("2_la6m6")
region = Rect2(16, 16, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_okcjq"]
atlas = ExtResource("2_la6m6")
region = Rect2(24, 16, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_uckr3"]
atlas = ExtResource("2_la6m6")
region = Rect2(0, 0, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_l6ht8"]
atlas = ExtResource("2_la6m6")
region = Rect2(8, 0, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_f5bxb"]
atlas = ExtResource("2_la6m6")
region = Rect2(16, 0, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_580lu"]
atlas = ExtResource("2_la6m6")
region = Rect2(24, 0, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_m6w0l"]
atlas = ExtResource("2_la6m6")
region = Rect2(0, 8, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_xoslx"]
atlas = ExtResource("2_la6m6")
region = Rect2(8, 8, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_efl5l"]
atlas = ExtResource("2_la6m6")
region = Rect2(16, 8, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_xuq2e"]
atlas = ExtResource("2_la6m6")
region = Rect2(24, 8, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_vr7nv"]
atlas = ExtResource("2_la6m6")
region = Rect2(0, 32, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_sxg7e"]
atlas = ExtResource("2_la6m6")
region = Rect2(8, 32, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_npc0u"]
atlas = ExtResource("2_la6m6")
region = Rect2(16, 32, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_uruo7"]
atlas = ExtResource("2_la6m6")
region = Rect2(24, 32, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_uc5kf"]
atlas = ExtResource("2_la6m6")
region = Rect2(0, 24, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_m5dpf"]
atlas = ExtResource("2_la6m6")
region = Rect2(8, 24, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_5ihc5"]
atlas = ExtResource("2_la6m6")
region = Rect2(16, 24, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_c1p0s"]
atlas = ExtResource("2_la6m6")
region = Rect2(24, 24, 8, 8)
[sub_resource type="SpriteFrames" id="SpriteFrames_icodh"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_7830n")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hxarw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ldeja")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_okcjq")
}],
"loop": false,
"name": &"move_down",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_uckr3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_l6ht8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_f5bxb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_580lu")
}],
"loop": false,
"name": &"move_right",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_m6w0l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xoslx")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_efl5l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xuq2e")
}],
"loop": false,
"name": &"move_up",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_vr7nv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sxg7e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_npc0u")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uruo7")
}],
"loop": false,
"name": &"punch",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_uc5kf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m5dpf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5ihc5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_c1p0s")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uc5kf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m5dpf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5ihc5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_c1p0s")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uc5kf")
}],
"loop": false,
"name": &"spin",
"speed": 12.0
}]
[sub_resource type="Animation" id="Animation_ve5nf"]
resource_name = "RESET"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
[sub_resource type="Animation" id="Animation_ab576"]
resource_name = "move"
length = 0.5
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.25),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [0, 1]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_dx4e7"]
_data = {
@ -52,12 +211,11 @@ z_index = 10
collision_mask = 15
script = ExtResource("1_jrd75")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_qfnf0")
hframes = 2
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_icodh")
animation = &"move_up"
[node name="Camera2D" type="Camera2D" parent="Sprite2D"]
[node name="Camera2D" type="Camera2D" parent="AnimatedSprite2D"]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
@ -66,6 +224,7 @@ libraries = {
autoplay = "move"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
shape = SubResource("RectangleShape2D_l7fhd")
[node name="RayCast2D" type="RayCast2D" parent="."]
@ -73,6 +232,7 @@ target_position = Vector2(0, 8)
collision_mask = 3
[node name="Area2D" type="Area2D" parent="."]
visible = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("RectangleShape2D_x0fgp")

View File

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="GBJAM12"
config/tags=PackedStringArray("gamejam", "tilemap")
config/tags=PackedStringArray("2d", "gamejam", "tilemap")
run/main_scene="res://scenes/main.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility")

View File

@ -75,7 +75,6 @@ position = Vector2(-180, 284)
[node name="Player" parent="." node_paths=PackedStringArray("checkpoints") instance=ExtResource("2_w5xov")]
position = Vector2(220, 60)
checkpoints = [NodePath("../Start"), NodePath("../Checkpoints/Hallway"), NodePath("../Checkpoints/Garden"), NodePath("../Checkpoints/BallCourse"), NodePath("../Checkpoints/PostBallCourse")]
current_checkpoint = 1
[node name="Checkpoints" type="Node2D" parent="."]
@ -372,32 +371,32 @@ script = ExtResource("8_sr3y5")
graves = [NodePath("Grave"), NodePath("Grave3"), NodePath("Grave2"), NodePath("Grave5"), NodePath("Grave4"), NodePath("Grave6")]
[node name="Grave" parent="GardenManager/GravesPuzzle" node_paths=PackedStringArray("pair") instance=ExtResource("2_fe1sr")]
position = Vector2(-8, -16)
position = Vector2(-24, -16)
pair = NodePath("../Grave3")
jingle = ExtResource("3_v8h4p")
[node name="Grave3" parent="GardenManager/GravesPuzzle" node_paths=PackedStringArray("pair") instance=ExtResource("2_fe1sr")]
position = Vector2(16, -24)
position = Vector2(16, -16)
pair = NodePath("../Grave")
jingle = ExtResource("3_v8h4p")
[node name="Grave2" parent="GardenManager/GravesPuzzle" node_paths=PackedStringArray("pair") instance=ExtResource("2_fe1sr")]
position = Vector2(24, -8)
position = Vector2(32, -40)
pair = NodePath("../Grave5")
jingle = ExtResource("4_xmwgp")
[node name="Grave5" parent="GardenManager/GravesPuzzle" node_paths=PackedStringArray("pair") instance=ExtResource("2_fe1sr")]
position = Vector2(32, -48)
position = Vector2(0, -64)
pair = NodePath("../Grave2")
jingle = ExtResource("4_xmwgp")
[node name="Grave4" parent="GardenManager/GravesPuzzle" node_paths=PackedStringArray("pair") instance=ExtResource("2_fe1sr")]
position = Vector2(-16, -40)
position = Vector2(-16, -48)
pair = NodePath("../Grave6")
jingle = ExtResource("17_02jvj")
[node name="Grave6" parent="GardenManager/GravesPuzzle" node_paths=PackedStringArray("pair") instance=ExtResource("2_fe1sr")]
position = Vector2(0, -64)
position = Vector2(24, -64)
pair = NodePath("../Grave4")
jingle = ExtResource("17_02jvj")
@ -833,7 +832,6 @@ position = Vector2(0, -16)
shape = SubResource("RectangleShape2D_c5an3")
[node name="VoidLayer" type="TileMapLayer" parent="BallCourseManager/BallPuzzle"]
visible = false
z_index = 10
position = Vector2(4, 4)
tile_map_data = PackedByteArray("AAAOAPb/AAAAAAAAAAAOAPf/AAAAAAAAAAAOAPj/AAAAAAAAAAAOAPn/AAAAAAAAAAAOAPr/AAAAAAAAAAAOAPv/AAAAAAAAAAAOAPz/AAAAAAAAAAAOAP3/AAAAAAAAAAAOAP7/AAAAAAAAAAAOAP//AAAAAAAAAAAOAAAAAAAAAAAAAAAOAAEAAAAAAAAAAAAOAAIAAAAAAAAAAAAOAAMAAAAAAAAAAAAOAAQAAAAAAAAAAAAOAAUAAAAAAAAAAAAOAAYAAAAAAAAAAAAOAAcAAAAAAAAAAAAOAAgAAAAAAAAAAAAPAPb/AAAAAAAAAAAPAPf/AAAAAAAAAAAPAPj/AAAAAAAAAAAPAPn/AAAAAAAAAAAPAPr/AAAAAAAAAAAPAPv/AAAAAAAAAAAPAPz/AAAAAAAAAAAPAP3/AAAAAAAAAAAPAP7/AAAAAAAAAAAPAP//AAAAAAAAAA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