first commit
This commit is contained in:
25
Droplet.gd
Normal file
25
Droplet.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends Area2D
|
||||
|
||||
@onready var sprite: Sprite2D = $sprite
|
||||
@onready var splash: CPUParticles2D = $splash
|
||||
var linear_velocity := Vector2.ZERO
|
||||
var _p0 := Vector2.ZERO
|
||||
|
||||
func _ready() -> void:
|
||||
_p0 = position
|
||||
rotation = linear_velocity.angle() - .5 * PI
|
||||
|
||||
func _physics_process(dt: float) -> void:
|
||||
linear_velocity.y += 1000.0 * dt
|
||||
rotation = linear_velocity.angle() - .5 * PI
|
||||
position += linear_velocity * dt
|
||||
if position.y > 2048:
|
||||
queue_free()
|
||||
|
||||
func _on_area_entered(_area: Area2D) -> void:
|
||||
linear_velocity = Vector2.ZERO
|
||||
set_physics_process(false)
|
||||
sprite.visible = false
|
||||
splash.amount = 2 + int(roundf(2.0 * randf()))
|
||||
splash.emitting = true
|
||||
get_tree().create_timer(splash.lifetime).timeout.connect(queue_free)
|
||||
Reference in New Issue
Block a user