Table of Contents
src / main.tscn
Diagram
Overridden virtual functions
_ready
$World/Player
func _ready() -> void:
playable = true
turn_right()
if not owner: return
if last_owner_name == owner.name:
position = restart_position
else:
restart_position = position
last_owner_name = owner.name
$FirstStepsBGMPlayable
func _ready() -> void:
BGM.first_steps()
_physics_process
$World/Player
func _physics_process(delta: float) -> void:
var dx := Input.get_axis(&'move_left', &'move_right')
var dy := Input.get_axis(&'move_up', &'move_down')
var direction := Vector2(dx, dy)
var last_state := state
state = compute_state(delta, direction)
match state:
State.CLIMBING:
dx = 0
velocity.y = dy * CLIMBING_SPEED
State.DASHED:
velocity = direction.normalized() * DASH_SPEED
State.DASHING:
velocity *= DASH_ATTENUATION * delta
State.EXHAUSTED:
dx = 0
State.FAILED:
velocity.x = lerp(velocity.x, 0.0, 0.2)
velocity.y = lerp(velocity.y, 0.0, 0.2)
State.FALLING:
if last_state == State.CLIMBING \
and dy < 0:
velocity.y = JUMP_VELOCITY * 0.8
else:
var move_x := dx * SPEED * 0.8
if velocity.x * dx < 0: move_x *= 0.1
velocity.x = lerp(velocity.x, move_x, 0.2)
if velocity.y < JUMP_VELOCITY * 0.85:
velocity.y += GRAVITY * 1.15 * delta
else:
velocity.y += GRAVITY * delta
State.JUMPED:
velocity.y = JUMP_VELOCITY
State.KICKED:
velocity.y = JUMP_VELOCITY * 0.9
velocity.x = get_wall_normal().x * DASH_SPEED * 0.4
State.LOCKED:
dx = 0
velocity = Vector2(0, 0)
_: pass
if not playable: dx = 0
if not (state == State.DASHED \
or state == State.DASHING \
or state == State.FALLING \
or state == State.KICKED
):
if dx: velocity.x = dx * SPEED
else: velocity.x = move_toward(velocity.x, 0, SPEED*0.2)
if state == State.JUMPED:
velocity += jump_boost
jump_boost = Vector2(0, 0)
animate(playable)
move_and_slide()
Instantiators
|
Caution
|
No other scene instantiate this scene. |
Scene Tree
-
Main Control
-
ColorRect ColorRect
-
World Node2D
-
StaticBody2D StaticBody2D
-
ColorRect ColorRect
-
CollisionShape2D CollisionShape2D
-
-
Player res://src/player/player.tscn
-
-
FirstStepsBGMPlayable res://src/mixins/first_steps_bgm_playable/first_steps_bgm_playable.tscn
-
Signal Connections
|
Note
|
No signal connections. |
Properties
| Name | Value |
|---|---|
layout_mode |
|
anchors_preset |
|
anchor_right |
|
anchor_bottom |
|
grow_horizontal |
|
grow_vertical |
|
| Name | Value |
|---|---|
layout_mode |
|
anchors_preset |
|
anchor_right |
|
anchor_bottom |
|
grow_horizontal |
|
grow_vertical |
|
| Name | Value |
|---|---|
offset_top |
|
offset_right |
|
offset_bottom |
|
color |
|
| Name | Value |
|---|---|
position |
|
shape |
|
| Name | Value |
|---|---|
unique_name_in_owner |
|
position |
|