First Version

This commit is contained in:
dubs
2025-12-01 12:58:12 +00:00
commit 70b6482b84
53 changed files with 1405 additions and 0 deletions

5
scripts/coin.gd Normal file
View File

@@ -0,0 +1,5 @@
extends Area2D
func _on_body_entered(body: Node2D) -> void:
print("+1 Coin")
queue_free()

1
scripts/coin.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://cycn1o2u7d1lc

33
scripts/player.gd Normal file
View File

@@ -0,0 +1,33 @@
extends CharacterBody2D
const SPEED = 130.0
const JUMP_VELOCITY = -300.0
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction : -1, 0, 1
var direction := Input.get_axis("move_left", "move_right")
#Flip the sprite
if direction > 0:
animated_sprite.flip_h = false
elif direction < 0:
animated_sprite.flip_h = true
# Apply movement
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()

1
scripts/player.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://bntyoqyhci34e

19
scripts/slime.gd Normal file
View File

@@ -0,0 +1,19 @@
extends Node2D
const SPEED = 60
var direction = 1
@onready var ray_cast_right: RayCast2D = $RayCastRight
@onready var ray_cast_left: RayCast2D = $RayCastLeft
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if ray_cast_right.is_colliding():
direction = -1
animated_sprite.flip_h = true
if ray_cast_left.is_colliding():
direction = 1
animated_sprite.flip_h = false
position.x += direction * SPEED * delta

1
scripts/slime.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://ctoiihii0atb8