diff --git a/buildings/building.gdshader b/buildings/building.gdshader index 4463040..4c7f0f6 100644 --- a/buildings/building.gdshader +++ b/buildings/building.gdshader @@ -14,7 +14,7 @@ void vertex() location = ivec2(128. * COLOR.xy); dimension = ivec2(128. * COLOR.zw); - vec2 myloc = vec2(location) + UV * (vec2(dimension) + vec2(0., .5)); + vec2 myloc = vec2(location) + UV * (vec2(dimension) + vec2(0., .7)) - vec2(0, .2); float angle = float(myloc.x) * TAU / 60.; float height = float(myloc.y) * cell_height + ground_height; VERTEX = vec2(cos(angle), sin(angle)) * height; diff --git a/items/heal_item.tscn b/items/heal_item.tscn index 5eb8954..ed70383 100644 --- a/items/heal_item.tscn +++ b/items/heal_item.tscn @@ -1,13 +1,16 @@ -[gd_scene load_steps=4 format=3 uid="uid://b00185vygcka1"] +[gd_scene load_steps=5 format=3 uid="uid://b00185vygcka1"] [ext_resource type="Script" uid="uid://b43fudwi47qfd" path="res://items/heal_item.gd" id="1_3vbv8"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_48lih"] +[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="2_evqwq"] [sub_resource type="CircleShape2D" id="CircleShape2D_hvhjo"] [node name="HealItem" type="Area2D"] script = ExtResource("1_3vbv8") +[node name="EarthAligner" parent="." instance=ExtResource("2_evqwq")] + [node name="CollisionShape2D" type="CollisionShape2D" parent="."] scale = Vector2(7, 7) shape = SubResource("CircleShape2D_hvhjo") diff --git a/items/item_spawn.gd b/items/item_spawn.gd index 2a8aadd..af9d37a 100644 --- a/items/item_spawn.gd +++ b/items/item_spawn.gd @@ -34,5 +34,5 @@ func _ready(): pool.remove_at(index) var object = packed_scene.instantiate() add_child.call_deferred(object) - object.reparent(get_parent()) + object.reparent.call_deferred(get_parent()) diff --git a/utils/earth_aligner.gd b/utils/earth_aligner.gd index 547efde..94cb1e0 100644 --- a/utils/earth_aligner.gd +++ b/utils/earth_aligner.gd @@ -6,8 +6,12 @@ var angle = 0 func _ready() -> void: parent = get_parent() + align() func _physics_process(_delta: float) -> void: + align() + +func align(): angle = -(parent.position - center).angle_to(Vector2.UP) parent.rotation = angle; diff --git a/utils/earth_aligner.tscn b/utils/earth_aligner.tscn index 57687e9..bc5a15d 100644 --- a/utils/earth_aligner.tscn +++ b/utils/earth_aligner.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://chs0u61f45nau"] -[ext_resource type="Script" uid="uid://ciehyjlxjvrvb" path="res://earth_aligner.gd" id="1_sx2xq"] +[ext_resource type="Script" uid="uid://ciehyjlxjvrvb" path="res://utils/earth_aligner.gd" id="1_sx2xq"] [node name="EarthAligner" type="Node2D"] script = ExtResource("1_sx2xq")