This commit is contained in:
Torsten 2024-03-20 14:59:14 +01:00
parent 1fe0ac690c
commit 3436132866
7 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1 @@
![[Pasted image 20240320114003.png]]

View file

@ -0,0 +1,43 @@
````python
extends Area2D
var max_speed := 1200.0
var velocity := Vector2(0, 0)
var steering_factor := 3.0
var health := 10
func _ready() -> void:
area_entered.connect(_on_area_entered)
# This call updates the health bar to match the health variable when the
# game starts.
set_health(health)
func _process(delta: float) -> void:
var direction := Vector2(0, 0)
direction.x = Input.get_axis("move_left", "move_right")
direction.y = Input.get_axis("move_up", "move_down")
if direction.length() > 1.0:
direction = direction.normalized()
var desired_velocity := max_speed * direction
var steering := desired_velocity - velocity
velocity += steering * steering_factor * delta
position += velocity * delta
if velocity.length() > 0.0:
get_node("Sprite2D").rotation = velocity.angle()
func set_health(new_health: int) -> void:
health = new_health
get_node("UI/HealthBar").value = health
func _on_area_entered(area_that_entered: Area2D) -> void:
set_health(health + 10)
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,2 @@
docker-compose up -d
./shell.sh

View file

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Before After
Before After