diff options
Diffstat (limited to 'game/microgames/heart_break/spiky.gd')
-rw-r--r-- | game/microgames/heart_break/spiky.gd | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/game/microgames/heart_break/spiky.gd b/game/microgames/heart_break/spiky.gd index 3fa5983..df4414b 100644 --- a/game/microgames/heart_break/spiky.gd +++ b/game/microgames/heart_break/spiky.gd @@ -1,11 +1,22 @@ -extends RigidBody2D +extends CharacterBody2D class_name Spiky +var dir:Vector2 = Vector2.UP +var speed = 200 + # Called when the node enters the scene tree for the first time. func _ready(): - pass # Replace with function body. + dir = dir.rotated(2*PI*randf()) + #apply_central_force(dir*250) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - pass + velocity = dir * speed + var collided = move_and_slide() + if(collided): + dir = dir.rotated(2*PI*randf()) + var collider = get_last_slide_collision().get_collider() + if(collider is Node and collider.name == "PlayerHeart"): + collider.body_entered.emit(self) + |