From 21b96bc68721c810a925cebf9cd4130c07eaba05 Mon Sep 17 00:00:00 2001 From: Marvin Dalheimer Date: Sat, 27 Jan 2024 17:32:41 +0100 Subject: [PATCH] Rotate the bottles --- godot/scenes/objects/bottle.gd | 23 ++++++++++++----------- godot/scenes/objects/bottle.tscn | 2 +- godot/scenes/stage.tscn | 12 +++++++++++- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/godot/scenes/objects/bottle.gd b/godot/scenes/objects/bottle.gd index dff987c..970a86c 100644 --- a/godot/scenes/objects/bottle.gd +++ b/godot/scenes/objects/bottle.gd @@ -7,25 +7,26 @@ var is_hidding: bool # Called when the node enters the scene tree for the first time. func _ready(): - tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position + tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - var t = create_tween() - t.tween_property(self, "global_position", tim_global_position, 3.0) - t.tween_callback(remove_bottle) + 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) func _on_bottle_area_entered(area): - is_hidding = true + is_hidding = true func _on_bottle_area_exited(area): - is_hidding = false + is_hidding = false func _on_growth_timer_timeout(): - var t = create_tween() - t.tween_property(self, "scale", self.scale + Vector2(0.01, 0.01), 0.02) + var t = create_tween() + t.tween_property(self, "scale", self.scale + Vector2(0.01, 0.01), 0.02) func remove_bottle(): - if is_hidding: - print("Ouch") - queue_free() + if is_hidding: + print("Ouch") + queue_free() diff --git a/godot/scenes/objects/bottle.tscn b/godot/scenes/objects/bottle.tscn index 3945282..95f9b01 100644 --- a/godot/scenes/objects/bottle.tscn +++ b/godot/scenes/objects/bottle.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://c5f5v1wtottyp"] [ext_resource type="Script" path="res://scenes/objects/bottle.gd" id="1_87ktq"] -[ext_resource type="Texture2D" uid="uid://bavsg3hu7pccy" path="res://sprites/room/bottle.svg" id="1_uea7l"] +[ext_resource type="Texture2D" uid="uid://cow4dd0hlxrgr" path="res://sprites/room/bottle.svg" id="1_uea7l"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_p8qcj"] radius = 22.4893 diff --git a/godot/scenes/stage.tscn b/godot/scenes/stage.tscn index 9b4979d..af28fbb 100644 --- a/godot/scenes/stage.tscn +++ b/godot/scenes/stage.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://cicyfp5xjvvu4"] +[gd_scene load_steps=8 format=3 uid="uid://cicyfp5xjvvu4"] [ext_resource type="Script" path="res://scenes/Tim.gd" id="1_g3k2b"] [ext_resource type="Texture2D" uid="uid://kq63ictuirhc" path="res://sprites/tim_side.png" id="1_saxit"] @@ -8,6 +8,9 @@ [sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_3hx6l"] size = Vector2(600, 200) +[sub_resource type="CircleShape2D" id="CircleShape2D_jfw8v"] +radius = 23.0217 + [sub_resource type="RectangleShape2D" id="RectangleShape2D_wmfel"] size = Vector2(250, 10000) @@ -26,6 +29,13 @@ boundary = NodePath("../Boundary") tim_sprite = NodePath("Sprite2D") transmitter_area = NodePath("Joke Transmitter/Area2D") +[node name="ThrowPoint" type="Area2D" parent="Tim"] +position = Vector2(0, -153) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Tim/ThrowPoint"] +position = Vector2(0, 1) +shape = SubResource("CircleShape2D_jfw8v") + [node name="Sprite2D" type="Sprite2D" parent="Tim"] z_index = 110 position = Vector2(-12, -142)