diff --git a/graphics/particles/bubble.png b/graphics/particles/bubble.png index 5048573..56ed7d8 100644 Binary files a/graphics/particles/bubble.png and b/graphics/particles/bubble.png differ diff --git a/objects/environment/bubble/bubble.gd b/objects/environment/bubble/bubble.gd new file mode 100644 index 0000000..2e6a1d4 --- /dev/null +++ b/objects/environment/bubble/bubble.gd @@ -0,0 +1,22 @@ +extends Area2D + +export var speed = 16.0 + +onready var sprite = $Sprite + +var lifetime = 0.0 + +func _ready(): + sprite.frame_coords.x = randi() % sprite.hframes + +func _physics_process(delta): + lifetime += delta + if speed > 0.0: + sprite.position.x = sin(lifetime * 4.0) * 4.0 + position.y -= speed * delta + +func _on_area_entered(area): + if area.is_in_group("player") or area.is_in_group("arrow"): + sprite.frame_coords.y = 1 + speed = 0.0 + get_tree().create_timer(0.5, false).connect("timeout", self, "queue_free") diff --git a/objects/environment/bubble/bubble.tscn b/objects/environment/bubble/bubble.tscn new file mode 100644 index 0000000..e9ea331 --- /dev/null +++ b/objects/environment/bubble/bubble.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://graphics/particles/bubble.png" type="Texture" id=1] +[ext_resource path="res://objects/environment/bubble/bubble.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 2, 2 ) + +[node name="Bubble" type="Area2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) +hframes = 4 +vframes = 2 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) + +[connection signal="area_entered" from="." to="." method="_on_area_entered"]