Dead simple, but it's a start

This commit is contained in:
2026-01-19 19:59:58 +11:00
commit df7b9e0714
22 changed files with 446 additions and 0 deletions

36
boxboy/boxboy.gd Normal file
View File

@@ -0,0 +1,36 @@
extends CharacterBody2D
@onready var _sprite = $AnimatedSprite2D
const GRAVITY: Vector2 = Vector2(0, 9.8)
const MAX_SPEED: int = 500
const IMPULSE: int = 80
const JUMP: int = -400 #TODO: proper jump arch
func _ready():
_sprite.play("idle", 1)
#physics and controls
func _physics_process(_delta) -> void:
#falling or jumping
if is_on_floor() and Input.is_action_just_pressed("input_jump"):
velocity.y = JUMP
velocity += GRAVITY
var direction = Input.get_axis("input_left", "input_right")
if direction:
velocity.x += IMPULSE * direction
if abs(velocity.x) > MAX_SPEED:
velocity.x = MAX_SPEED * sign(velocity.x)
elif velocity.x != 0:
velocity.x = log(abs(velocity.x)) * sign(velocity.x)
move_and_slide()
#animation stuff
func _on_animation_finished() -> void:
if randf() < 0.2:
_sprite.play("idle_glance", 2)
else:
_sprite.play("idle", 2)