From ae936275b78fa908b5493912de12d8e9c4969331 Mon Sep 17 00:00:00 2001 From: Ultrablob Date: Wed, 17 Apr 2024 15:00:20 -0400 Subject: [PATCH] added main memu --- Clock.gd | 2 + Leaderboard.gd | 6 +- MainMenu.gd | 13 ++++ Player.gd | 8 +- Shield.gd | 2 +- Spawner.gd | 2 + ToggleableControl.gd | 8 ++ main.tscn | 6 +- main_menu.tscn | 178 +++++++++++++++++++++++++++++++++++++++++++ project.godot | 7 +- 10 files changed, 224 insertions(+), 8 deletions(-) create mode 100644 MainMenu.gd create mode 100644 ToggleableControl.gd create mode 100644 main_menu.tscn diff --git a/Clock.gd b/Clock.gd index c269bc5..bbaec1a 100644 --- a/Clock.gd +++ b/Clock.gd @@ -6,6 +6,8 @@ func _ready(): velocity = Vector2(speed, speed) func _physics_process(delta): + if get_tree().paused: + return if get_last_slide_collision(): var collision: KinematicCollision2D = get_last_slide_collision() if collision.get_collider(): diff --git a/Leaderboard.gd b/Leaderboard.gd index a8217c5..aa40422 100644 --- a/Leaderboard.gd +++ b/Leaderboard.gd @@ -2,14 +2,16 @@ extends Label @export var stopwatch: Stopwatch +const API_BASE = "https://flask-hello-world-nine-psi.vercel.app" + func get_scores(): - $HTTPRequest.request("https://flask-hello-world-nine-psi.vercel.app/leaderboard") + $HTTPRequest.request(API_BASE + "/leaderboard") func submit_score(): var encrypted_score = "EGH" + Marshalls.utf8_to_base64(str(stopwatch.time_elapsed)) print(encrypted_score) $HTTPRequest.request_completed.connect(_on_request_completed) - $HTTPRequest.request("https://flask-hello-world-nine-psi.vercel.app/leaderboard?score=%s" % encrypted_score, [], HTTPClient.METHOD_POST) + $HTTPRequest.request(API_BASE + "https://flask-hello-world-nine-psi.vercel.app/leaderboard?score=%s" % encrypted_score, [], HTTPClient.METHOD_POST) func _on_request_completed(result, response_code, headers, body): if body.get_string_from_utf8() == "OK": diff --git a/MainMenu.gd b/MainMenu.gd new file mode 100644 index 0000000..5513e11 --- /dev/null +++ b/MainMenu.gd @@ -0,0 +1,13 @@ +extends Control + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func play(): + get_tree().change_scene_to_file("res://main.tscn") diff --git a/Player.gd b/Player.gd index c88f9f5..0fb3593 100644 --- a/Player.gd +++ b/Player.gd @@ -8,6 +8,7 @@ var exagon = preload("res://exagon.tscn") var num_quares = 0 var max_quares = 3 var exagons = 1 +var absolute_movement = false func _ready(): update_display() @@ -16,11 +17,16 @@ func _physics_process(delta): look_at(get_global_mouse_position()) var move_input = Input.get_axis("down", "up") var side_input = Input.get_axis("right", "left") - apply_central_force(transform.y * side_input * speed / 2 + transform.x * move_input * speed) + if absolute_movement: + apply_central_force(Vector2(side_input * speed, move_input * speed) * -1) + else: + apply_central_force(transform.y * side_input * speed / 2 + transform.x * move_input * speed) func _input(event): if event.is_action_pressed("jump"): global_position = get_global_mouse_position() + if event.is_action_pressed("switch_input"): + absolute_movement = true if event.is_action_pressed("quare"): if num_quares >= max_quares: notifier.notify("All Quares in Use!") diff --git a/Shield.gd b/Shield.gd index ac6f6a0..9f3805a 100644 --- a/Shield.gd +++ b/Shield.gd @@ -8,8 +8,8 @@ func destroy(): if health <= 0: if not is_queued_for_deletion(): - $"../../Player".aquire_exagon() $"..".queue_free() + $"../../Player".aquire_exagon() modulate = Color(Color.CYAN, 0.7 - lerp(0.7, 0.1, health / max_health)) diff --git a/Spawner.gd b/Spawner.gd index 69c1643..326e189 100644 --- a/Spawner.gd +++ b/Spawner.gd @@ -4,6 +4,8 @@ extends Marker2D @export var random_on_screen = false func spawn(): + if get_tree().paused: + return for i in range(10): var test_pos = Vector2(randf(), randf()) * Vector2(1920, 1080) if not $"../CollisionCheck".is_clear(test_pos): diff --git a/ToggleableControl.gd b/ToggleableControl.gd new file mode 100644 index 0000000..04a7a30 --- /dev/null +++ b/ToggleableControl.gd @@ -0,0 +1,8 @@ +extends Label + +func show(): + show() + visible = true + +func hide(): + visible = false diff --git a/main.tscn b/main.tscn index 1f6ddfb..ebbe398 100644 --- a/main.tscn +++ b/main.tscn @@ -28,7 +28,7 @@ colors = PackedColorArray(0.0509804, 0.0509804, 0.0509804, 1) gradient = SubResource("Gradient_bi1rk") [sub_resource type="RectangleShape2D" id="RectangleShape2D_7w8g6"] -size = Vector2(605, 225.5) +size = Vector2(638.5, 225.5) [sub_resource type="GradientTexture1D" id="GradientTexture1D_vrv6v"] gradient = ExtResource("4_yk0bb") @@ -46,7 +46,7 @@ normal = Vector2(1, 2.08165e-12) normal = Vector2(-1, 2.08165e-12) [sub_resource type="CircleShape2D" id="CircleShape2D_bmvvy"] -radius = 50.0 +radius = 100.0 [sub_resource type="Gradient" id="Gradient_or5lt"] colors = PackedColorArray(1, 0, 0, 1, 1, 0, 0, 1) @@ -105,7 +105,7 @@ motion_mode = 1 script = ExtResource("5_7po8n") [node name="CollisionShape2D" type="CollisionShape2D" parent="Clock"] -position = Vector2(207, 192) +position = Vector2(194.438, 192) scale = Vector2(0.75, 0.75) shape = SubResource("RectangleShape2D_7w8g6") script = ExtResource("1_hy18x") diff --git a/main_menu.tscn b/main_menu.tscn new file mode 100644 index 0000000..ac0faed --- /dev/null +++ b/main_menu.tscn @@ -0,0 +1,178 @@ +[gd_scene load_steps=6 format=3 uid="uid://ck1db6d8whbac"] + +[ext_resource type="Script" path="res://MainMenu.gd" id="1_omrmt"] +[ext_resource type="Gradient" uid="uid://c41berdx2rqpw" path="res://gradient.tres" id="2_fq3us"] +[ext_resource type="Script" path="res://InfiniteGradient.gd" id="3_7u2sq"] +[ext_resource type="FontFile" uid="uid://dsw5w316y4v54" path="res://Preahvihear/Preahvihear-Regular.ttf" id="3_swfwl"] + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_jya8r"] +gradient = ExtResource("2_fq3us") +width = 16384 + +[node name="MainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_omrmt") + +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -152.0 +offset_right = 14312.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture1D_jya8r") +stretch_mode = 1 +script = ExtResource("3_7u2sq") +speed = 100 + +[node name="Title" type="Label" parent="."] +layout_mode = 1 +anchors_preset = 14 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_top = -539.0 +offset_bottom = 4.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 200 +text = "Quare Game" +horizontal_alignment = 1 + +[node name="Settings" type="Button" parent="."] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -934.0 +offset_top = -326.0 +offset_right = -414.0 +offset_bottom = -136.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 100 +text = "CONFIG" +flat = true + +[node name="Tutorial" type="Button" parent="."] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = 353.0 +offset_top = -327.0 +offset_right = 873.0 +offset_bottom = -137.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 100 +text = "TUTORIAL" +flat = true + +[node name="Play" type="Button" parent="."] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -173.0 +offset_top = -326.0 +offset_right = 173.0 +offset_bottom = -136.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 100 +text = " PLAY " +flat = true + +[node name="Settings Panel" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 0.619608) + +[node name="GridContainer" type="GridContainer" parent="Settings Panel"] +layout_mode = 1 +anchors_preset = 13 +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -351.0 +offset_top = 170.0 +offset_right = 351.0 +offset_bottom = -170.0 +grow_horizontal = 2 +grow_vertical = 2 +columns = 2 + +[node name="Label" type="Label" parent="Settings Panel/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_font_sizes/font_size = 80 +text = "Balls" + +[node name="TextEdit" type="TextEdit" parent="Settings Panel/GridContainer"] +custom_minimum_size = Vector2(400, 2.08165e-12) +layout_mode = 2 +theme_override_font_sizes/font_size = 60 +placeholder_text = "kill you self" + +[node name="Tutorial Text" type="Label" parent="."] +visible = false +z_index = 2 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 64 +text = "You are gaming +kill you're self" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="ColorRect" type="ColorRect" parent="Tutorial Text"] +z_index = -1 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 0.654902) + +[node name="Button" type="Button" parent="Tutorial Text"] +layout_mode = 1 +offset_left = 24.0 +offset_top = 6.0 +offset_right = 63.0 +offset_bottom = 106.0 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 50 +text = "X" +flat = true + +[connection signal="pressed" from="Tutorial" to="Tutorial Text" method="show"] +[connection signal="pressed" from="Play" to="." method="play"] +[connection signal="pressed" from="Tutorial Text/Button" to="Tutorial Text" method="hide"] diff --git a/project.godot b/project.godot index cf22180..411a916 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Countdown" -run/main_scene="res://main.tscn" +run/main_scene="res://main_menu.tscn" config/features=PackedStringArray("4.2", "GL Compatibility") config/icon="res://icon.svg" @@ -72,6 +72,11 @@ exagon={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null) ] } +switch_input={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":77,"key_label":0,"unicode":109,"echo":false,"script":null) +] +} [rendering]