The moving platform in level 1 wnow moves up and down. I finished level one.

This commit is contained in:
2026-06-22 16:50:07 -06:00
parent bdd99c1c78
commit a975d466e6
5 changed files with 56 additions and 18 deletions
+14 -6
View File
@@ -4,19 +4,27 @@ var moving_up :bool = true
var speed :float = 50.0
var distance_moved :float = 0.0
var moving = false
var movement = speed
var moving_down :bool = false
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if moving:
var movement = speed * delta
var delta_movement = movement * delta
if moving_up:
position.y -= movement
distance_moved += movement
position.y -= delta_movement
distance_moved += delta_movement
if distance_moved >= 479.7:
moving_up = false
else:
position.y += delta_movement
distance_moved -= delta_movement
if distance_moved <= 0:
moving_up = true
func _on_platform_body_entered(body: Node2D) -> void:
print(body)
moving = true
if body.name == "player":
moving = true