added jump animation
This commit is contained in:
parent
a245ebc135
commit
579397cd8b
BIN
assets/graphics/player/jump/player jump 48x48.png
Normal file
BIN
assets/graphics/player/jump/player jump 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1021 B |
40
assets/graphics/player/jump/player jump 48x48.png.import
Normal file
40
assets/graphics/player/jump/player jump 48x48.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://d2e455oxjbsf5"
|
||||||
|
path="res://.godot/imported/player jump 48x48.png-1ccba0c36041038682bf917e1f6cf991.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/player/jump/player jump 48x48.png"
|
||||||
|
dest_files=["res://.godot/imported/player jump 48x48.png-1ccba0c36041038682bf917e1f6cf991.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
|
||||||
@ -1,11 +1,20 @@
|
|||||||
[gd_scene format=3 uid="uid://bhsvqyhsemekq"]
|
[gd_scene format=3 uid="uid://bhsvqyhsemekq"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dlmf1p0vfitcx" path="res://scripts/player.gd" id="1_3vyb7"]
|
[ext_resource type="Script" uid="uid://dlmf1p0vfitcx" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d2e455oxjbsf5" path="res://assets/graphics/player/jump/player jump 48x48.png" id="2_dqkch"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dio2ufnpnihce" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
[ext_resource type="Texture2D" uid="uid://dio2ufnpnihce" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bl7p2n2kgw2qx" path="res://assets/graphics/player/idle/player run 48x48.png" id="3_qhqgy"]
|
[ext_resource type="Texture2D" uid="uid://bl7p2n2kgw2qx" path="res://assets/graphics/player/idle/player run 48x48.png" id="3_qhqgy"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_elsnr"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_elsnr"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4ni07"]
|
||||||
|
atlas = ExtResource("2_dqkch")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_i4ail"]
|
||||||
|
atlas = ExtResource("2_dqkch")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
||||||
atlas = ExtResource("2_g2els")
|
atlas = ExtResource("2_g2els")
|
||||||
region = Rect2(0, 0, 48, 48)
|
region = Rect2(0, 0, 48, 48)
|
||||||
@ -46,6 +55,10 @@ region = Rect2(384, 0, 48, 48)
|
|||||||
atlas = ExtResource("2_g2els")
|
atlas = ExtResource("2_g2els")
|
||||||
region = Rect2(432, 0, 48, 48)
|
region = Rect2(432, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a38lo"]
|
||||||
|
atlas = ExtResource("2_dqkch")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jej6c"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_jej6c"]
|
||||||
atlas = ExtResource("3_qhqgy")
|
atlas = ExtResource("3_qhqgy")
|
||||||
region = Rect2(0, 0, 48, 48)
|
region = Rect2(0, 0, 48, 48)
|
||||||
@ -82,6 +95,22 @@ region = Rect2(336, 0, 48, 48)
|
|||||||
animations = [{
|
animations = [{
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_4ni07")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"apex",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_i4ail")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"fall",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_qhqgy")
|
"texture": SubResource("AtlasTexture_qhqgy")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@ -117,6 +146,14 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_a38lo")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"jump",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_jej6c")
|
"texture": SubResource("AtlasTexture_jej6c")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@ -169,6 +206,7 @@ position = Vector2(-10, -12)
|
|||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
position = Vector2(0, -1)
|
position = Vector2(0, -1)
|
||||||
sprite_frames = SubResource("SpriteFrames_jej6c")
|
sprite_frames = SubResource("SpriteFrames_jej6c")
|
||||||
animation = &"run"
|
animation = &"apex"
|
||||||
autoplay = "idle"
|
autoplay = "idle"
|
||||||
frame_progress = 0.8670586
|
|
||||||
|
[connection signal="animation_finished" from="graphic" to="." method="_on_graphic_animation_finished"]
|
||||||
|
|||||||
@ -12,8 +12,9 @@ var direction : float = 0
|
|||||||
enum FaceDirection { LEFT, RIGHT }
|
enum FaceDirection { LEFT, RIGHT }
|
||||||
var facing: FaceDirection = FaceDirection.LEFT
|
var facing: FaceDirection = FaceDirection.LEFT
|
||||||
var shove_target: RigidBody2D
|
var shove_target: RigidBody2D
|
||||||
enum State { IDLE, RUNNING }
|
enum State { IDLE, RUN, JUMP, APEX, FALL }
|
||||||
var state: State = State.IDLE
|
var state: State = State.IDLE
|
||||||
|
var up_jump:bool = false
|
||||||
|
|
||||||
func _physics_process(delta: float):
|
func _physics_process(delta: float):
|
||||||
handle_input()
|
handle_input()
|
||||||
@ -73,13 +74,34 @@ func handle_collisions():
|
|||||||
func handle_state():
|
func handle_state():
|
||||||
match state:
|
match state:
|
||||||
State.IDLE when velocity.x != 0:
|
State.IDLE when velocity.x != 0:
|
||||||
state = State.RUNNING
|
state = State.RUN
|
||||||
State.RUNNING when velocity.x == 0:
|
State.RUN when velocity.x == 0:
|
||||||
|
state = State.IDLE
|
||||||
|
State.RUN when velocity.y < 0:
|
||||||
|
state = State.JUMP
|
||||||
|
State.IDLE when velocity.y < 0:
|
||||||
|
state = State.JUMP
|
||||||
|
State.JUMP when velocity.y > 0:
|
||||||
|
state = State.APEX
|
||||||
|
# from APEX to FALL is handled when apex animation finishes
|
||||||
|
State.FALL when velocity.y == 0:
|
||||||
state = State.IDLE
|
state = State.IDLE
|
||||||
|
|
||||||
func handle_animation():
|
func handle_animation():
|
||||||
match state:
|
match state:
|
||||||
State.IDLE:
|
State.IDLE:
|
||||||
graphic.play("idle")
|
graphic.play("idle")
|
||||||
State.RUNNING:
|
State.RUN:
|
||||||
graphic.play("run")
|
graphic.play("run")
|
||||||
|
State.JUMP:
|
||||||
|
graphic.play("jump")
|
||||||
|
State.APEX:
|
||||||
|
graphic.play("apex")
|
||||||
|
State.FALL:
|
||||||
|
graphic.play("fall")
|
||||||
|
|
||||||
|
func _on_graphic_animation_finished() -> void:
|
||||||
|
# switch state from apex to fall
|
||||||
|
match state:
|
||||||
|
State.APEX:
|
||||||
|
state = State.FALL
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user