player.tscn: scholar of the first bullet casings

This commit is contained in:
Haze Weathers 2023-05-08 01:00:38 -04:00
parent 79cbd62a69
commit bc57ba4171
45 changed files with 1429 additions and 113 deletions

View file

@ -359,7 +359,7 @@ func die():
time_tween.tween_property(Engine, "time_scale", 0.1, 0.3)
Audio.ac_music.stream_paused = true
yield(time_tween, "finished") #Resume from freeze frame
yield(get_tree().create_timer(1.0 * 0.1), "timeout")
yield(get_tree().create_timer, "timeout")
Game.call_deferred("restart_level")
else:
#Die

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=2]
[gd_scene load_steps=34 format=2]
[ext_resource path="res://objects/player/player.gd" type="Script" id=1]
[ext_resource path="res://graphics/player/sg_walk.png" type="Texture" id=2]
@ -14,7 +14,7 @@
[ext_resource path="res://graphics/player/sg_shoot_air.png" type="Texture" id=12]
[ext_resource path="res://shaders/recolor.tres" type="Shader" id=13]
[ext_resource path="res://graphics/player/sg_doublejump.png" type="Texture" id=14]
[ext_resource path="res://graphics/particles/blood.png" type="Texture" id=15]
[ext_resource path="res://objects/player/player_death_particles.tscn" type="PackedScene" id=15]
[ext_resource path="res://graphics/particles/dust.png" type="Texture" id=16]
[ext_resource path="res://scripts/snap_sprite.gd" type="Script" id=17]
@ -644,9 +644,6 @@ tracks/4/keys = {
[sub_resource type="RectangleShape2D" id=34]
extents = Vector2( 6, 7 )
[sub_resource type="Curve" id=41]
_data = [ Vector2( 0, 1 ), 0.0, -0.113537, 0, 0, Vector2( 1, 0 ), -3.35032, 0.0, 0, 0 ]
[sub_resource type="Curve" id=43]
_data = [ Vector2( 0, 1 ), 0.0, -0.0636948, 0, 0, Vector2( 1, 0 ), -3.43886, 0.0, 0, 0 ]
@ -719,28 +716,7 @@ position = Vector2( 0, 3 )
shape = SubResource( 34 )
disabled = true
[node name="DeathSplatter" type="CPUParticles2D" parent="."]
pause_mode = 2
emitting = false
amount = 16
lifetime = 0.3
one_shot = true
explosiveness = 0.9
local_coords = false
texture = ExtResource( 15 )
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 50 )
initial_velocity = 60.0
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount = 0.5
scale_amount_random = 1.0
scale_amount_curve = SubResource( 41 )
[node name="DeathSplatter" parent="." instance=ExtResource( 15 )]
[node name="DustParticles" type="CPUParticles2D" parent="."]
position = Vector2( 0, 12 )

View file

@ -0,0 +1,29 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://graphics/particles/blood.png" type="Texture" id=1]
[sub_resource type="Curve" id=41]
_data = [ Vector2( 0, 1 ), 0.0, -0.113537, 0, 0, Vector2( 1, 0 ), -3.35032, 0.0, 0, 0 ]
[node name="DeathSplatter" type="CPUParticles2D"]
pause_mode = 2
emitting = false
amount = 16
lifetime = 0.3
one_shot = true
explosiveness = 0.9
local_coords = false
texture = ExtResource( 1 )
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 50 )
initial_velocity = 60.0
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount = 0.5
scale_amount_random = 1.0
scale_amount_curve = SubResource( 41 )

View file

@ -0,0 +1,265 @@
extends KinematicBody2D
# SIGNALS #
signal died()
# CONSTANTS #
const ArrowProjectile = preload("res://objects/player/arrow_projectile.tscn")
const DeathSplatter = preload("res://objects/player/player_death_particles.tscn")
# EXPORTS #
## horizontal movement speed
export var walk_speed: float = 50.0
## climbing speed
export var climb_speed: float = 39.0
## gravity force
export var gravity: float = 720.0
## SG's terminal velocity
export var max_fall_speed: float = 255.0
## upward added by jump
export var jump_force: float = 150.0
## proportion of remaining force retained when jump is released
export var jump_release_force: float = 0.25
## impulse added when double jumping
export var double_jump_force: float = 122.0
# velocity
var velocity: Vector2 = Vector2.ZERO
# snap vector
var snap: Vector2 = Vector2.ZERO
# ladder currently attached to
var _attached_ladder: Node2D = null
# NODE REFERENCES #
onready var state_chart: StateChart = $StateChart
onready var animation_player: AnimationPlayer = $AnimationPlayer
onready var graphics: Node2D = $Graphics
onready var sprite: Sprite = $"%Sprite"
onready var arrow_position: Position2D = $"%ArrowPosition"
onready var dust_particles: CPUParticles2D = $"%DustParticles"
onready var grounded_shape: CollisionShape2D = $"%GroundedShape"
onready var airborne_shape: CollisionShape2D = $"%AirborneShape"
onready var ladder_detector: RayCast2D = $"%LadderDetector"
onready var death_splatter_position: Position2D = $"%DeathSplatterPosition"
# OVERRIDES #
func _ready() -> void:
Game.respawn_point = global_position
connect("died", Game, "_on_player_died")
move_and_slide(Vector2(0.0, 1.0), Vector2.UP)
state_chart.initialize()
state_chart.set_guard_property("can_respawn", true)
$StateDebugLayer/StateChartDebug.target = state_chart
func _physics_process(delta: float) -> void:
# update transition guard properties
# whether player can currently shoot an arrow
var can_shoot = Game.arrows > 0 and get_tree().get_nodes_in_group("player_arrow").size() == 0
state_chart.set_guard_property("can_shoot", can_shoot)
# check for and propagate input events
if Input.is_action_just_pressed("jump"): # jumping
state_chart.send_event("jump")
if Input.is_action_just_pressed("shoot"): # shooting
state_chart.send_event("shoot")
# send relevant events
if is_on_floor(): # check on floor status
state_chart.send_event("grounded")
else:
state_chart.send_event("airborne")
# check if in contact with ladder
if ladder_detector.is_colliding():
state_chart.send_event("ladder_touched")
# HELPER FUNCTIONS #
## spawns an arrow
func spawn_arrow() -> void:
var arrow = ArrowProjectile.instance()
arrow.global_position = arrow_position.global_position
arrow.direction = sign(arrow_position.global_position.x - global_position.x)
arrow.add_to_group("player_arrow")
get_parent().add_child(arrow)
Audio.play_sound(Audio.a_shoot, Audio.ac_jump)
func die() -> void:
state_chart.send_event("hurt")
# STATE ENTERS/EXITS #
func _on_Grounded_state_entered() -> void:
# still jump if pressed frame hit ground
if Input.is_action_just_pressed("jump"):
print("BOING")
state_chart.send_event("jump")
# toggle hurtbox shapes
grounded_shape.disabled = false
airborne_shape.disabled = true
snap.y = 2.5 # snap when in grounded state
velocity.y = 1.0
func _on_Airborne_state_entered() -> void:
grounded_shape.disabled = true
airborne_shape.disabled = false
snap.y = 0.0 # do not snap when in air
velocity.y = 0.0
func _on_NormalJump_state_entered() -> void:
velocity.y = -jump_force
Audio.play_sound(Audio.a_jump, Audio.ac_jump)
animation_player.play("jump")
dust_particles.restart()
func _on_NormalJump_state_exited() -> void:
# add bit of force proportional to how much of the jump is left
if Input.is_action_just_released("jump"):
var factor = inverse_lerp(0.0, -jump_force, velocity.y)
velocity.y = -jump_force * factor * jump_release_force
func _on_LadderJump_state_entered() -> void:
velocity.y = -jump_force
Audio.play_sound(Audio.a_jump, Audio.ac_jump)
animation_player.play("jump")
func _on_DoubleJump_state_entered() -> void:
velocity.y = -double_jump_force
Audio.play_sound(Audio.a_doublejump, Audio.ac_jump)
animation_player.play("double_jump")
func _on_CoyoteFalling_state_entered() -> void:
velocity.x = 0.0
animation_player.play("fall")
func _on_NormalFalling_state_entered() -> void:
animation_player.play("fall")
func _on_ScaredFalling_state_entered() -> void:
velocity.x = 0.0
animation_player.play("fall_scared")
func _on_Shooting_state_entered() -> void:
velocity.x = 0.0
animation_player.play("shoot_grounded")
func _on_AirShooting_state_entered() -> void:
spawn_arrow()
animation_player.play("shoot_airborne")
func _on_Climbing_state_entered() -> void:
if ladder_detector.get_collider().is_in_group("ladder"):
_attached_ladder = ladder_detector.get_collider()
velocity = Vector2.ZERO
snap = Vector2.ZERO
if global_position.x < _attached_ladder.middle:
global_position.x = _attached_ladder.left_snap
graphics.scale.x = 1.0
else:
global_position.x = _attached_ladder.right_snap
graphics.scale.x = -1.0
animation_player.play("climb")
func _on_Climbing_state_exited() -> void:
_attached_ladder = null
animation_player.playback_speed = 1.0 # restore playback speed
# all the stuff that happens when they DIE
func _on_Dead_state_entered() -> void:
# send signals
emit_signal("died")
state_chart.send_event("died")
# spawn death particles
var particles = DeathSplatter.instance()
particles.global_position = death_splatter_position.global_position
particles.emitting = true
get_parent().add_child(particles)
# fade into the ether
graphics.visible = false
state_chart.send_event("respawn")
func _on_Respawn_state_entered() -> void:
global_position = Game.respawn_point
graphics.visible = true
state_chart.call_deferred("send_event", "get_real")
# STATE PROCESSING #
## when on ground
func _process_grounded(delta: float) -> void:
# make sure is_on_floor detected still
velocity.y = 1.0
## called when player can move left and rightpass # Repass # Rpass # Replace with function body.eplace with function body.place with function body.
func _process_horizontal_movement(delta: float) -> void:
var input_dir = sign(Input.get_axis("ui_left", "ui_right")) # sign() to normalize
velocity.x = input_dir * walk_speed
if input_dir != 0.0:
graphics.scale.x = input_dir
## walk/idle state
func _process_can_walk(delta: float) -> void:
if sign(Input.get_axis("ui_left", "ui_right")) != 0.0:
animation_player.play("walk")
else:
animation_player.play("idle")
## climbing on ladders
func _process_climbing(delta: float) -> void:
# climbing movement
var input_dir = sign(Input.get_axis("ui_up", "ui_down"))
velocity.y = input_dir * climb_speed # move in input direction
animation_player.playback_speed = abs(input_dir) # play/pause animation
# # switching sides of ladder
# if global_position.x < _attached_ladder.middle and Input.is_action_just_pressed("ui_right"):
# global_position.x = _attached_ladder.right_snap
# graphics.scale.x = -1SimCity.0SimCitySimCity
# elif Input.is_action_just_pressed("ui_left"):
# global_position.x = _attached_ladder.left_snap
# graphics.scale.x = 1.0
if Input.is_action_just_pressed("jump"):
global_position.x -= graphics.scale.x * 3.0
state_chart.send_event("jump")
if Input.is_action_just_pressed("shoot"):
global_position.x -= graphics.scale.x * 3.0
state_chart.send_event("ladder_detach")
# check if still on ladder
if ladder_detector.get_collider() != _attached_ladder:
if input_dir == -1.0:
state_chart.send_event("jump")
else:
state_chart.send_event("ladder_detach")
func _process_jump(delta: float) -> void:
if velocity.y >= 0.0:
state_chart.send_event("jump_peak")
if not Input.is_action_pressed("jump"):
state_chart.send_event("jump_released")
## called by states SG will fall during
func _process_gravity(delta: float) -> void:
velocity.y = min(velocity.y + gravity * delta, max_fall_speed)
## called after all other physics things
func _process_movement(delta: float) -> void:
# apply velocity and react to collisions
velocity = move_and_slide_with_snap(velocity, snap, Vector2.UP)
# deal with that STUPID landing exactly on corner bug
var col = get_last_slide_collision()
if col != null:
if col.remainder.y >= 1.0 and col.normal.y == 0.0:
position.x += col.normal.x * 0.001
# COLLISION CALLBACKS #
func _on_Hitbox_body_entered(body: Node) -> void:
if body.is_in_group("death"):
die()

View file

@ -0,0 +1,956 @@
[gd_scene load_steps=37 format=2]
[ext_resource path="res://objects/player/player_scholar.gd" type="Script" id=1]
[ext_resource path="res://graphics/player/pal_purplearmor.png" type="Texture" id=2]
[ext_resource path="res://shaders/recolor_border.shader" type="Shader" id=3]
[ext_resource path="res://graphics/player/sg_idle.png" type="Texture" id=4]
[ext_resource path="res://addons/godot_state_charts/parallel_state.gd" type="Script" id=5]
[ext_resource path="res://addons/godot_state_charts/state_chart.gd" type="Script" id=6]
[ext_resource path="res://ui/theme.tres" type="Theme" id=7]
[ext_resource path="res://addons/godot_state_charts/state_chart_debug.gd" type="Script" id=8]
[ext_resource path="res://addons/godot_state_charts/compound_state.gd" type="Script" id=9]
[ext_resource path="res://addons/godot_state_charts/transition.gd" type="Script" id=10]
[ext_resource path="res://addons/godot_state_charts/atomic_state.gd" type="Script" id=11]
[ext_resource path="res://graphics/player/sg_walk.png" type="Texture" id=12]
[ext_resource path="res://graphics/player/sg_jump.png" type="Texture" id=13]
[ext_resource path="res://graphics/player/sg_climb.png" type="Texture" id=14]
[ext_resource path="res://graphics/player/sg_shoot_grounded.png" type="Texture" id=15]
[ext_resource path="res://graphics/player/sg_shoot_air.png" type="Texture" id=16]
[ext_resource path="res://graphics/player/sg_doublejump.png" type="Texture" id=17]
[ext_resource path="res://graphics/particles/dust.png" type="Texture" id=18]
[ext_resource path="res://graphics/player/sg_fall_scared.png" type="Texture" id=19]
[ext_resource path="res://graphics/player/sg_fall.png" type="Texture" id=20]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 3 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = true
shader_param/palette = ExtResource( 2 )
[sub_resource type="Curve" id=13]
_data = [ Vector2( 0, 1 ), 0.0, -0.0636948, 0, 0, Vector2( 1, 0 ), -3.43886, 0.0, 0, 0 ]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 2.5, 5 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 2.5, 5 )
[sub_resource type="RectangleShape2D" id=16]
extents = Vector2( 2.5, 2.5 )
[sub_resource type="Animation" id=5]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ ExtResource( 4 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 1 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=9]
resource_name = "climb"
length = 0.3
loop = true
step = 0.15
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 14 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 2 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.15 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ 0, 1 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=12]
resource_name = "double_jump"
length = 0.32
loop = true
step = 0.04
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 17 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 2 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.04, 0.08, 0.12, 0.16, 0.2, 0.24, 0.28 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 0, 1, 0, 1, 0, 1 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0, 0.08, 0.16, 0.24 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 0.0, 90.0, 180.0, 270.0 ]
}
[sub_resource type="Animation" id=15]
resource_name = "fall"
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 20 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 1 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=14]
resource_name = "fall_scared"
length = 0.2
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 19 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 2 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ 0, 1 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.00238396 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=6]
resource_name = "idle"
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 4 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 1 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=8]
resource_name = "jump"
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 13 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 1 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=11]
resource_name = "shoot_airborne"
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 16 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.001 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ 1, 1 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=10]
resource_name = "shoot_grounded"
length = 0.25
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 15 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 6 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.03, 0.06, 0.12, 0.15, 0.18 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 4, 5 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
tracks/4/type = "method"
tracks/4/path = NodePath(".")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/keys = {
"times": PoolRealArray( 0.12 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "spawn_arrow"
} ]
}
tracks/5/type = "method"
tracks/5/path = NodePath("StateChart")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/keys = {
"times": PoolRealArray( 0.25 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ "shoot_end" ],
"method": "send_event"
} ]
}
[sub_resource type="Animation" id=7]
resource_name = "walk"
length = 0.4
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Graphics/Sprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ ExtResource( 12 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Graphics/Sprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 4 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Graphics/Sprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="StyleBoxEmpty" id=4]
[node name="Player" type="KinematicBody2D" groups=["player"]]
collision_layer = 0
collision_mask = 7
script = ExtResource( 1 )
gravity = 700.0
jump_force = 140.0
double_jump_force = 124.0
[node name="Graphics" type="Node2D" parent="."]
[node name="Sprite" type="Sprite" parent="Graphics"]
unique_name_in_owner = true
material = SubResource( 1 )
position = Vector2( 0, -10 )
texture = ExtResource( 4 )
[node name="ArrowPosition" type="Position2D" parent="Graphics"]
unique_name_in_owner = true
position = Vector2( 5, -7 )
__meta__ = {
"_gizmo_extents_": 2.0
}
[node name="DeathSplatterPosition" type="Position2D" parent="Graphics"]
unique_name_in_owner = true
position = Vector2( 0, -10 )
__meta__ = {
"_gizmo_extents_": 2.0
}
[node name="DustParticles" type="CPUParticles2D" parent="Graphics"]
unique_name_in_owner = true
position = Vector2( 0, 2 )
z_index = 1
emitting = false
amount = 5
lifetime = 0.3
one_shot = true
explosiveness = 0.9
fract_delta = false
local_coords = false
texture = ExtResource( 18 )
emission_shape = 2
emission_rect_extents = Vector2( 5, 0 )
direction = Vector2( 0, -1 )
spread = 60.0
gravity = Vector2( 0, 0 )
initial_velocity = 10.0
initial_velocity_random = 0.8
angle = 720.0
angle_random = 1.0
scale_amount = 0.25
scale_amount_random = 0.5
scale_amount_curve = SubResource( 13 )
[node name="BodyShape" type="CollisionShape2D" parent="."]
position = Vector2( 0.5, -5 )
shape = SubResource( 2 )
[node name="Hitbox" type="Area2D" parent="." groups=["player_hitbox"]]
collision_layer = 11
collision_mask = 32
[node name="GroundedShape" type="CollisionShape2D" parent="Hitbox"]
unique_name_in_owner = true
position = Vector2( 0.5, -5 )
shape = SubResource( 3 )
[node name="AirborneShape" type="CollisionShape2D" parent="Hitbox"]
unique_name_in_owner = true
position = Vector2( 0.5, -7.5 )
shape = SubResource( 16 )
[node name="LadderDetector" type="RayCast2D" parent="."]
unique_name_in_owner = true
position = Vector2( 0.5, 0 )
enabled = true
cast_to = Vector2( 0, -10 )
collision_mask = 64
collide_with_areas = true
collide_with_bodies = false
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 5 )
anims/climb = SubResource( 9 )
anims/double_jump = SubResource( 12 )
anims/fall = SubResource( 15 )
anims/fall_scared = SubResource( 14 )
anims/idle = SubResource( 6 )
anims/jump = SubResource( 8 )
anims/shoot_airborne = SubResource( 11 )
anims/shoot_grounded = SubResource( 10 )
anims/walk = SubResource( 7 )
[node name="StateChart" type="Node" parent="."]
script = ExtResource( 6 )
auto_initialize = false
[node name="Root" type="Node" parent="StateChart"]
script = ExtResource( 5 )
__meta__ = {
"_editor_description_": ""
}
[node name="Movement" type="Node" parent="StateChart/Root"]
process_priority = 10
script = ExtResource( 9 )
__meta__ = {
"_editor_description_": "higher process priority so it can do move_and_slide after everything else"
}
initial_state = NodePath("Grounded")
[node name="On Died" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource( 10 )
to = NodePath("../Inactive")
event = "died"
[node name="Grounded" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource( 9 )
__meta__ = {
"_editor_description_": "is on the ground"
}
initial_state = NodePath("CanWalk")
[node name="On Airborne" type="Node" parent="StateChart/Root/Movement/Grounded"]
script = ExtResource( 10 )
to = NodePath("../../Airborne/Falling/CoyoteFalling")
event = "airborne"
[node name="On Jump" type="Node" parent="StateChart/Root/Movement/Grounded"]
script = ExtResource( 10 )
__meta__ = {
"_editor_description_": "enter jump state when the jump button is pressed"
}
to = NodePath("../../Airborne/Jump/NormalJump")
event = "jump"
[node name="On LadderTouched" type="Node" parent="StateChart/Root/Movement/Grounded"]
script = ExtResource( 10 )
to = NodePath("../../Climbing")
event = "ladder_touched"
[node name="CanWalk" type="Node" parent="StateChart/Root/Movement/Grounded"]
script = ExtResource( 11 )
__meta__ = {
"_editor_description_": "can walk by moving left and right"
}
[node name="On Shoot" type="Node" parent="StateChart/Root/Movement/Grounded/CanWalk"]
script = ExtResource( 10 )
to = NodePath("../../Shooting")
event = "shoot"
guard_expression = "can_shoot"
[node name="Shooting" type="Node" parent="StateChart/Root/Movement/Grounded"]
script = ExtResource( 11 )
consumed_events = [ "jump" ]
[node name="On ShootEnd" type="Node" parent="StateChart/Root/Movement/Grounded/Shooting"]
script = ExtResource( 10 )
to = NodePath("../../CanWalk")
event = "shoot_end"
[node name="Pushing" type="Node" parent="StateChart/Root/Movement/Grounded"]
script = ExtResource( 11 )
[node name="Airborne" type="Node" parent="StateChart/Root/Movement"]
process_priority = 5
script = ExtResource( 9 )
__meta__ = {
"_editor_description_": "SG is in the air and falling DOWN, better think fast!"
}
initial_state = NodePath("Falling")
[node name="On Grounded" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource( 10 )
to = NodePath("../../Grounded")
event = "grounded"
[node name="On Shoot" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource( 10 )
to = NodePath("../AirShooting")
event = "shoot"
guard_expression = "can_shoot"
[node name="On LadderTouched" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource( 10 )
to = NodePath("../../Climbing")
event = "ladder_touched"
[node name="Jump" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource( 9 )
initial_state = NodePath("NormalJump")
[node name="On Jump" type="Node" parent="StateChart/Root/Movement/Airborne/Jump"]
script = ExtResource( 10 )
__meta__ = {
"_editor_description_": "enter double jump state when the jump button is pressed"
}
to = NodePath("../../DoubleJump")
event = "jump"
[node name="On JumpPeak" type="Node" parent="StateChart/Root/Movement/Airborne/Jump"]
script = ExtResource( 10 )
to = NodePath("../../Falling/NormalFalling")
event = "jump_peak"
[node name="NormalJump" type="Node" parent="StateChart/Root/Movement/Airborne/Jump"]
script = ExtResource( 11 )
[node name="On JumpReleased" type="Node" parent="StateChart/Root/Movement/Airborne/Jump/NormalJump"]
script = ExtResource( 10 )
__meta__ = {
"_editor_description_": ""
}
to = NodePath("../../../Falling/NormalFalling")
event = "jump_released"
[node name="LadderJump" type="Node" parent="StateChart/Root/Movement/Airborne/Jump"]
script = ExtResource( 11 )
[node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource( 9 )
initial_state = NodePath("NormalFalling")
[node name="On Jump" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
script = ExtResource( 10 )
__meta__ = {
"_editor_description_": "enter double jump state when the jump button is pressed"
}
to = NodePath("../../DoubleJump")
event = "jump"
[node name="CoyoteFalling" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
script = ExtResource( 11 )
[node name="On Jump" type="Node" parent="StateChart/Root/Movement/Airborne/Falling/CoyoteFalling"]
script = ExtResource( 10 )
__meta__ = {
"_editor_description_": "enter jump state when the jump button is pressed"
}
to = NodePath("../../../Jump/NormalJump")
event = "jump"
[node name="On CoyoteTimeout" type="Node" parent="StateChart/Root/Movement/Airborne/Falling/CoyoteFalling"]
script = ExtResource( 10 )
to = NodePath("../../ScaredFalling")
delay = 0.067
[node name="NormalFalling" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
script = ExtResource( 11 )
[node name="ScaredFalling" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
script = ExtResource( 11 )
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource( 11 )
[node name="AirShooting" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource( 11 )
[node name="Climbing" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource( 11 )
__meta__ = {
"_editor_description_": "stuck to ladder"
}
[node name="On Jump" type="Node" parent="StateChart/Root/Movement/Climbing"]
script = ExtResource( 10 )
to = NodePath("../../Airborne/Jump/LadderJump")
event = "jump"
[node name="On LadderDetach" type="Node" parent="StateChart/Root/Movement/Climbing"]
script = ExtResource( 10 )
to = NodePath("../../Airborne/Falling/NormalFalling")
event = "ladder_detach"
[node name="Inactive" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource( 11 )
__meta__ = {
"_editor_description_": "player can not move or do anything, immobile"
}
[node name="On Respawn" type="Node" parent="StateChart/Root/Movement/Inactive"]
script = ExtResource( 10 )
to = NodePath("../../Grounded")
event = "get_real"
[node name="Health" type="Node" parent="StateChart/Root"]
script = ExtResource( 9 )
initial_state = NodePath("Vulnerable")
[node name="Vulnerable" type="Node" parent="StateChart/Root/Health"]
script = ExtResource( 11 )
[node name="On Hurt" type="Node" parent="StateChart/Root/Health/Vulnerable"]
script = ExtResource( 10 )
to = NodePath("../../Dead")
event = "hurt"
[node name="Invulnerable" type="Node" parent="StateChart/Root/Health"]
script = ExtResource( 11 )
[node name="Respawn" type="Node" parent="StateChart/Root/Health"]
script = ExtResource( 11 )
[node name="On Timeout" type="Node" parent="StateChart/Root/Health/Respawn"]
script = ExtResource( 10 )
to = NodePath("../../Vulnerable")
[node name="Dead" type="Node" parent="StateChart/Root/Health"]
script = ExtResource( 11 )
[node name="On Respawn" type="Node" parent="StateChart/Root/Health/Dead"]
script = ExtResource( 10 )
to = NodePath("../../Respawn")
event = "respawn"
guard_expression = "can_respawn"
[node name="StateDebugLayer" type="CanvasLayer" parent="."]
layer = 128
[node name="StateChartDebug" type="Tree" parent="StateDebugLayer"]
visible = false
anchor_left = 1.0
anchor_right = 1.0
margin_left = -147.0
margin_bottom = 137.0
theme = ExtResource( 7 )
custom_styles/bg = SubResource( 4 )
script = ExtResource( 8 )
[connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement" to="." method="_process_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded" to="." method="_on_Grounded_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded" to="." method="_process_grounded"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_horizontal_movement"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/Shooting" to="." method="_on_Shooting_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="_on_Airborne_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne" to="." method="_process_gravity"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_jump"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_entered"]
[connection signal="state_exited" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_exited"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/LadderJump" to="." method="_on_LadderJump_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/CoyoteFalling" to="." method="_on_CoyoteFalling_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/NormalFalling" to="." method="_on_NormalFalling_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Falling/NormalFalling" to="." method="_process_horizontal_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/ScaredFalling" to="." method="_on_ScaredFalling_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_on_DoubleJump_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_process_horizontal_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/AirShooting" to="." method="_on_AirShooting_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/AirShooting" to="." method="_process_horizontal_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_entered"]
[connection signal="state_exited" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_exited"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Climbing" to="." method="_process_climbing"]
[connection signal="state_entered" from="StateChart/Root/Health/Respawn" to="." method="_on_Respawn_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Health/Dead" to="." method="_on_Dead_state_entered"]