Only show particle when ball is top speed

This commit is contained in:
Rain Clark 2022-04-23 00:56:03 -04:00
parent 5747a036c3
commit 84f9fef897

View File

@ -1,6 +1,7 @@
extends Actor
export var top_speed: = 1000
onready var particles: Particles2D = $Particles2D
func _ready() -> void:
randomize()
@ -15,8 +16,12 @@ func _on_BounceCheck_body_entered(body: PhysicsBody2D) -> void:
bounce(body)
func bounce(object: PhysicsBody2D) -> void:
if speed.x <= top_speed:
if speed.x >= top_speed:
speed.x = top_speed
particles.visible = true
else:
speed.x *= 1.1
if object is Actor:
_direction.x = -_direction.x
$"SFX/BounceSound-2".play()