22 lines
611 B
GDScript
22 lines
611 B
GDScript
extends CharacterBody2D
|
|
|
|
@export_enum("color", "red", "blue", "green", "black") var type : int = 3
|
|
|
|
func _ready() -> void:
|
|
velocity = Vector2.from_angle(randf() * PI * 2) * 25
|
|
match type:
|
|
0: modulate = Color.RED
|
|
1: modulate = Color.BLUE
|
|
2: modulate = Color.GREEN
|
|
|
|
func _process(delta: float) -> void:
|
|
var results = move_and_collide(velocity * delta, false)
|
|
if results != null:
|
|
velocity = velocity.reflect(Vector2.from_angle(results.get_angle()))
|
|
|
|
func vibrate() -> void:
|
|
$Sprite2D.offset = Vector2((randf() - .5) * 2, (randf() - .5) * 2) * 1
|
|
|
|
func remove() -> void:
|
|
get_tree().queue_delete(self)
|