Initial commit

This commit is contained in:
Matthew Barbour
2026-08-30 01:17:38 -05:00
parent f983ab64ce
commit 17cedb8bf1
68 changed files with 2035 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
[gd_scene format=3 uid="uid://cuc5q5cao3vjx"]
[ext_resource type="PackedScene" uid="uid://d3vp4xma2cse0" path="res://entities/lucca/lucca.tscn" id="1_4flbx"]
[ext_resource type="Script" uid="uid://syr14v0u22s7" path="res://player/scripts/player.gd" id="1_onrkg"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5t4nn"]
size = Vector2(46, 10)
[node name="Player" type="CharacterBody2D" unique_id=1952104269]
collision_layer = 32769
collision_mask = 32769
script = ExtResource("1_onrkg")
[node name="Sprite" parent="." unique_id=1658534661 instance=ExtResource("1_4flbx")]
position = Vector2(0, -1)
scale = Vector2(4, 4)
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=500589119]
position = Vector2(31, -6)
shape = SubResource("RectangleShape2D_5t4nn")
+74
View File
@@ -0,0 +1,74 @@
extends CharacterBody2D
# Movement speed in pixels per second
@export var speed: float = 600.0
var last_direction = Vector2.DOWN
var animation_playing =false;
var animation_start_time = 0;
var animation_duration = 0;
func _process(delta: float) -> void:
if animation_playing:
var elapsed = (Time.get_ticks_msec() - animation_start_time)
if elapsed > animation_duration:
animation_playing = false
reset_to_stand()
func _input(event):
if animation_playing==true:
return
if Input.is_action_just_pressed("move_left"):
$Sprite.play_animation("walk_east", true)
last_direction = Vector2.LEFT
elif Input.is_action_just_pressed("move_right"):
$Sprite.play_animation("walk_east", false)
last_direction = Vector2.RIGHT
elif Input.is_action_just_pressed("move_up"):
$Sprite.play_animation("walk_north", false)
last_direction = Vector2.UP
elif Input.is_action_just_pressed("move_down"):
$Sprite.play_animation("walk_south", false)
last_direction = Vector2.DOWN
if not Input.is_action_pressed("move_left") and not Input.is_action_pressed("move_right") and not Input.is_action_pressed("move_up") and not Input.is_action_pressed("move_down"):
reset_to_stand()
func _physics_process(_delta: float) -> void:
if animation_playing==true:
return
# 1. Get the direction vector based on our Input Map actions
var direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
# 2. Apply direction to velocity multiplied by our speed
if direction != Vector2.ZERO:
velocity = direction * speed
else:
# Smoothly slow down to a stop if no keys are pressed
velocity = velocity.move_toward(Vector2.ZERO, speed)
# 3. Move the character body and handle physical collisions automatically
move_and_slide()
func play_animation(name:StringName, duration):
animation_playing = true
animation_duration = duration
$Sprite.play_animation(name, false)
animation_start_time = Time.get_ticks_msec()
func reset_to_stand():
if last_direction==Vector2.UP:
$Sprite.play_animation("stand_north", false)
elif last_direction==Vector2.DOWN:
$Sprite.play_animation("stand_south", false)
elif last_direction==Vector2.LEFT:
$Sprite.play_animation("stand_east", true)
elif last_direction==Vector2.RIGHT:
$Sprite.play_animation("stand_east", false)
+1
View File
@@ -0,0 +1 @@
uid://syr14v0u22s7