The moving platform in level 1 wnow moves up and down. I finished level one.
This commit is contained in:
+14
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user