diff options
author | Zoey Kitt <zoey.kitt@outlook.com> | 2024-11-15 19:31:11 -0600 |
---|---|---|
committer | Zoey Kitt <zoey.kitt@outlook.com> | 2024-11-15 19:31:11 -0600 |
commit | b62bbaac0dd22ba130832292f9248de2e9aa4662 (patch) | |
tree | 9de465780a60a637169f5b090226fac87d4529f2 /scenes | |
parent | cdc892590b112dff319aa29337114cf076fb5cc2 (diff) |
Randomize window position
Diffstat (limited to 'scenes')
-rw-r--r-- | scenes/main.gd | 7 | ||||
-rw-r--r-- | scenes/main.tscn | 5 | ||||
-rw-r--r-- | scenes/microgames/microgame_window.tscn | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/scenes/main.gd b/scenes/main.gd index 642ec39..5214f25 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -14,9 +14,16 @@ func _process(delta: float) -> void: func _on_microgame_spawn_timer_timeout() -> void: print("WAAAHAHAHA MICROGAMES") + # Spawn a microgame window var window_scene = preload("res://scenes/microgames/microgame_window.tscn") var window_instance = window_scene.instantiate() add_child(window_instance) var microgame_scene = preload("res://scenes/microgames/window_mvp.tscn") var microgame_instance = microgame_scene.instantiate() window_instance.add_child(microgame_instance) + + # Randomize window position + var screen_size = DisplayServer.screen_get_size() + var window_x = randi_range(0, screen_size.x - window_instance.size.x) + var window_y = randi_range(0, screen_size.y - window_instance.size.y) + window_instance.position = Vector2(window_x, window_y) diff --git a/scenes/main.tscn b/scenes/main.tscn index 6db30b0..09d1a86 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=4 format=3 uid="uid://d06d1vihf2oqp"] +[gd_scene load_steps=3 format=3 uid="uid://d06d1vihf2oqp"] [ext_resource type="Texture2D" uid="uid://b03ygtrwha22g" path="res://taytay/IMG_5199.jpeg" id="1_o2s48"] [ext_resource type="Script" path="res://scenes/main.gd" id="1_y7a0r"] -[ext_resource type="PackedScene" uid="uid://b2awdq32lxnef" path="res://scenes/microgames/microgame_window.tscn" id="3_ehgys"] [node name="Node2D" type="Node2D"] script = ExtResource("1_y7a0r") @@ -12,8 +11,6 @@ position = Vector2(636.307, 381.672) scale = Vector2(0.293995, 0.217148) texture = ExtResource("1_o2s48") -[node name="Window" parent="." instance=ExtResource("3_ehgys")] - [node name="Score" type="Label" parent="."] offset_top = 2.0 offset_right = 83.0 diff --git a/scenes/microgames/microgame_window.tscn b/scenes/microgames/microgame_window.tscn index 170e4c7..17f30aa 100644 --- a/scenes/microgames/microgame_window.tscn +++ b/scenes/microgames/microgame_window.tscn @@ -1,18 +1,14 @@ -[gd_scene load_steps=3 format=3 uid="uid://b2awdq32lxnef"] +[gd_scene load_steps=2 format=3 uid="uid://b2awdq32lxnef"] [ext_resource type="Script" path="res://scenes/microgames/microgame_window.gd" id="1_8ce8l"] -[ext_resource type="PackedScene" uid="uid://baukkysebggup" path="res://scenes/microgames/window_mvp.tscn" id="2_asfd5"] [node name="Window" type="Window"] auto_translate_mode = 1 title = "hiiiii" -position = Vector2i(1710, 1112) size = Vector2i(1280, 720) content_scale_size = Vector2i(1280, 720) content_scale_mode = 1 content_scale_aspect = 1 script = ExtResource("1_8ce8l") -[node name="WindowMvp" parent="." instance=ExtResource("2_asfd5")] - [connection signal="close_requested" from="." to="." method="_on_close_requested"] |