Tough_Crowd/godot/scenes/objects/bottle.gd

33 lines
963 B
GDScript3
Raw Normal View History

2024-01-27 14:50:20 +00:00
extends Sprite2D
@export var bottle_speed: float = 120;
var tim_global_position: Vector2
var is_hidding: bool
# Called when the node enters the scene tree for the first time.
func _ready():
2024-01-27 16:32:41 +00:00
tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position
2024-01-27 14:50:20 +00:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
2024-01-27 16:32:41 +00:00
var t = create_tween().set_parallel()
t.tween_property(self, "global_position", tim_global_position, 3.0)
t.tween_property(self, "rotation_degrees", rotation_degrees + 270, 3.0)
t.tween_callback(remove_bottle).set_delay(3.05)
2024-01-27 14:50:20 +00:00
func _on_bottle_area_entered(area):
2024-01-27 16:32:41 +00:00
is_hidding = true
2024-01-27 14:50:20 +00:00
func _on_bottle_area_exited(area):
2024-01-27 16:32:41 +00:00
is_hidding = false
2024-01-27 14:50:20 +00:00
func _on_growth_timer_timeout():
2024-01-27 16:32:41 +00:00
var t = create_tween()
t.tween_property(self, "scale", self.scale + Vector2(0.01, 0.01), 0.02)
2024-01-27 14:50:20 +00:00
func remove_bottle():
2024-01-27 16:32:41 +00:00
if is_hidding:
print("Ouch")
queue_free()