diff --git a/GameManager.gd b/GameManager.gd index cfd9d93..09e02b6 100644 --- a/GameManager.gd +++ b/GameManager.gd @@ -4,12 +4,10 @@ extends Node2D func _ready(): process_mode = Node.PROCESS_MODE_ALWAYS - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - func _input(event): - if event.is_action_pressed("restart"): + if event.is_action_pressed("restart") and $Clock/Label/HTTPRequest.get_http_client_status() == HTTPClient.STATUS_DISCONNECTED: get_tree().paused = false get_tree().reload_current_scene() + if event.is_action_pressed("quit") and $Clock/Label/HTTPRequest.get_http_client_status() == HTTPClient.STATUS_DISCONNECTED: + get_tree().paused = false + get_tree().change_scene_to_file("res://main_menu.tscn") diff --git a/Gun.gd b/Gun.gd index 471e5b3..791b9d8 100644 --- a/Gun.gd +++ b/Gun.gd @@ -3,7 +3,7 @@ extends Marker2D @export var bullet: PackedScene func shoot(): - print("Shooting") + #print("Shooting") var node = bullet.instantiate() node.global_position = global_position node.linear_velocity = Vector2(500, 0).rotated(global_rotation) diff --git a/Leaderboard.gd b/Leaderboard.gd index aa40422..b2cd106 100644 --- a/Leaderboard.gd +++ b/Leaderboard.gd @@ -1,17 +1,24 @@ extends Label @export var stopwatch: Stopwatch +var config = ConfigFile.new() -const API_BASE = "https://flask-hello-world-nine-psi.vercel.app" +var API_BASE = "https://flask-hello-world-nine-psi.vercel.app" if not OS.is_debug_build() else "http://192.168.2.120:5001" + +func make_urlsafe(data: String): + return data.replace("+", "-").replace("/", "_") func get_scores(): $HTTPRequest.request(API_BASE + "/leaderboard") func submit_score(): - var encrypted_score = "EGH" + Marshalls.utf8_to_base64(str(stopwatch.time_elapsed)) + var err = config.load("user://settings.cfg") + if not (err == OK and config.has_section_key("config", "username")): + text = "Error: No Username!\nSet a username in settings to submit scores" + var encrypted_score = "EGH" + make_urlsafe(Marshalls.utf8_to_base64(str(stopwatch.time_elapsed))) + "eHa" + make_urlsafe(Marshalls.utf8_to_base64(config.get_value("config", "username"))) print(encrypted_score) $HTTPRequest.request_completed.connect(_on_request_completed) - $HTTPRequest.request(API_BASE + "https://flask-hello-world-nine-psi.vercel.app/leaderboard?score=%s" % encrypted_score, [], HTTPClient.METHOD_POST) + $HTTPRequest.request(API_BASE + "/leaderboard?score=%s" % encrypted_score, [], HTTPClient.METHOD_POST) func _on_request_completed(result, response_code, headers, body): if body.get_string_from_utf8() == "OK": @@ -20,12 +27,15 @@ func _on_request_completed(result, response_code, headers, body): var json = JSON.parse_string(body.get_string_from_utf8()) #print(json) if json and "scores" in json: - var scores = json["scores"] - #print(scores) + var scoredata = json["scores"] + var scores = [] + for score in scoredata: + scores.append(float(score[1])) + print(scores) var score = stopwatch.time_elapsed + print(score) var placement = closest(score, scores) print(placement) - print(len(scores)) if placement < 50: text = "You placed #%d\n" % [placement] @@ -33,7 +43,7 @@ func _on_request_completed(result, response_code, headers, body): text = "You placed top %d%%\n" % [(float(placement) / len(scores)) * 100] var n = 1 while n <= 5 and n <= len(scores): - text += "%d. %s\n" % [ n, seconds2mmss(scores[n-1]) ] + text += "%d. %s: %s\n" % [ n, scoredata[n-1][0], seconds2mmss(scores[n-1]) ] n += 1 func closest(my_number:int, my_array:Array)->int: @@ -44,7 +54,9 @@ func closest(my_number:int, my_array:Array)->int: var temp_delta:int = 0 # Loop through entire array for i in range(my_array.size()): - if my_array[i] == my_number: return my_array[i] # exact match found! + if my_array[i] == my_number: + print("Exact Match!") + return my_array[i] # exact match found! temp_delta = int(abs(my_array[i]-my_number)) if closest_delta == 0 or temp_delta < closest_delta: closest_num = my_array[i] diff --git a/Player.gd b/Player.gd index 0fb3593..62de29c 100644 --- a/Player.gd +++ b/Player.gd @@ -25,8 +25,6 @@ func _physics_process(delta): 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/Preahvihear/Preahvihear-Regular.ttf.import b/Preahvihear/Preahvihear-Regular.ttf.import index d2b30d4..9dc1367 100644 --- a/Preahvihear/Preahvihear-Regular.ttf.import +++ b/Preahvihear/Preahvihear-Regular.ttf.import @@ -24,7 +24,7 @@ hinting=1 subpixel_positioning=1 oversampling=0.0 Fallbacks=null -fallbacks=[] +fallbacks=[Resource("res://TwitterColorEmoji-SVGinOT-14.0.2/TwitterColorEmoji-SVGinOT.ttf")] Compress=null compress=true preload=[] diff --git a/main_menu.tscn b/main_menu.tscn index ac0faed..82c7b58 100644 --- a/main_menu.tscn +++ b/main_menu.tscn @@ -1,9 +1,12 @@ -[gd_scene load_steps=6 format=3 uid="uid://ck1db6d8whbac"] +[gd_scene load_steps=9 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"] +[ext_resource type="FontFile" uid="uid://tun7rjjlknsf" path="res://TwitterColorEmoji-SVGinOT-14.0.2/TwitterColorEmoji-SVGinOT.ttf" id="5_bjfro"] +[ext_resource type="Script" path="res://Settings.gd" id="5_sarwv"] +[ext_resource type="Script" path="res://EmojiValidator.gd" id="6_ojb71"] [sub_resource type="GradientTexture1D" id="GradientTexture1D_jya8r"] gradient = ExtResource("2_fq3us") @@ -102,6 +105,7 @@ text = " PLAY " flat = true [node name="Settings Panel" type="ColorRect" parent="."] +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -109,8 +113,27 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 color = Color(0, 0, 0, 0.619608) +script = ExtResource("5_sarwv") -[node name="GridContainer" type="GridContainer" parent="Settings Panel"] +[node name="Close" type="Button" parent="Settings Panel"] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -72.0 +offset_top = -159.0 +offset_right = 72.0 +offset_bottom = -59.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 50 +text = "SAVE" +flat = true + +[node name="Menu" type="GridContainer" parent="Settings Panel"] layout_mode = 1 anchors_preset = 13 anchor_left = 0.5 @@ -124,17 +147,38 @@ grow_horizontal = 2 grow_vertical = 2 columns = 2 -[node name="Label" type="Label" parent="Settings Panel/GridContainer"] +[node name="Label" type="Label" parent="Settings Panel/Menu"] layout_mode = 2 size_flags_horizontal = 0 theme_override_font_sizes/font_size = 80 -text = "Balls" +text = "Useremoji" -[node name="TextEdit" type="TextEdit" parent="Settings Panel/GridContainer"] -custom_minimum_size = Vector2(400, 2.08165e-12) +[node name="Username" type="LineEdit" parent="Settings Panel/Menu"] +custom_minimum_size = Vector2(100, 0) layout_mode = 2 -theme_override_font_sizes/font_size = 60 -placeholder_text = "kill you self" +size_flags_horizontal = 8 +theme_override_fonts/font = ExtResource("5_bjfro") +theme_override_font_sizes/font_size = 54 +alignment = 1 +script = ExtResource("6_ojb71") +pattern = "\\p{Emoji}" + +[node name="Label2" type="Label" parent="Settings Panel/Menu"] +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_font_sizes/font_size = 80 +text = "Movement " + +[node name="Controls" type="OptionButton" parent="Settings Panel/Menu"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("3_swfwl") +theme_override_font_sizes/font_size = 54 +item_count = 2 +selected = 0 +popup/item_0/text = "Relative" +popup/item_0/id = 0 +popup/item_1/text = "Absolute" +popup/item_1/id = 1 [node name="Tutorial Text" type="Label" parent="."] visible = false @@ -162,7 +206,7 @@ grow_horizontal = 2 grow_vertical = 2 color = Color(0, 0, 0, 0.654902) -[node name="Button" type="Button" parent="Tutorial Text"] +[node name="Close" type="Button" parent="Tutorial Text"] layout_mode = 1 offset_left = 24.0 offset_top = 6.0 @@ -173,6 +217,11 @@ theme_override_font_sizes/font_size = 50 text = "X" flat = true +[connection signal="pressed" from="Settings" to="Settings Panel" method="show"] [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"] +[connection signal="pressed" from="Settings Panel/Close" to="Settings Panel" method="save"] +[connection signal="pressed" from="Settings Panel/Close" to="Settings Panel" method="hide"] +[connection signal="text_changed" from="Settings Panel/Menu/Username" to="Settings Panel" method="check_valid"] +[connection signal="text_changed" from="Settings Panel/Menu/Username" to="Settings Panel/Menu/Username" method="check"] +[connection signal="pressed" from="Tutorial Text/Close" to="Tutorial Text" method="hide"] diff --git a/project.godot b/project.godot index 411a916..67cec26 100644 --- a/project.godot +++ b/project.godot @@ -72,9 +72,9 @@ 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={ +quit={ "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) +"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":4194305,"key_label":0,"unicode":0,"echo":false,"script":null) ] } @@ -82,3 +82,5 @@ switch_input={ renderer/rendering_method="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility" +anti_aliasing/screen_space_roughness_limiter/enabled=false +anti_aliasing/quality/screen_space_aa=1