added game

This commit is contained in:
ivy 2025-04-17 21:35:23 +02:00
commit 85d53bd89b
25 changed files with 522 additions and 0 deletions

41
scripts/player.gd Normal file
View file

@ -0,0 +1,41 @@
extends CharacterBody2D
const SPEED: int = 200
const JUMP_VELOCITY: int = -300
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("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
$boing.play()
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction: float = Input.get_axis("ui_left", "ui_right")
velocity.x = direction * SPEED
if $death.playing:
velocity = Vector2(0, 0)
move_and_slide()
for i in get_slide_collision_count():
if get_slide_collision(i).get_collider() == $"../TileMapLayer2" and not $death.playing:
$death.play()
func _on_player_entered(body: Node2D) -> void:
if body == self:
$rice.play()
await $rice.finished
get_tree().quit()
func _on_death_finished() -> void:
get_tree().reload_current_scene()