added main memu

This commit is contained in:
Ultrablob 2024-04-17 15:00:20 -04:00
parent e446938ba7
commit ae936275b7
10 changed files with 224 additions and 8 deletions

View file

@ -6,6 +6,8 @@ func _ready():
velocity = Vector2(speed, speed) velocity = Vector2(speed, speed)
func _physics_process(delta): func _physics_process(delta):
if get_tree().paused:
return
if get_last_slide_collision(): if get_last_slide_collision():
var collision: KinematicCollision2D = get_last_slide_collision() var collision: KinematicCollision2D = get_last_slide_collision()
if collision.get_collider(): if collision.get_collider():

View file

@ -2,14 +2,16 @@ extends Label
@export var stopwatch: Stopwatch @export var stopwatch: Stopwatch
const API_BASE = "https://flask-hello-world-nine-psi.vercel.app"
func get_scores(): func get_scores():
$HTTPRequest.request("https://flask-hello-world-nine-psi.vercel.app/leaderboard") $HTTPRequest.request(API_BASE + "/leaderboard")
func submit_score(): func submit_score():
var encrypted_score = "EGH" + Marshalls.utf8_to_base64(str(stopwatch.time_elapsed)) var encrypted_score = "EGH" + Marshalls.utf8_to_base64(str(stopwatch.time_elapsed))
print(encrypted_score) print(encrypted_score)
$HTTPRequest.request_completed.connect(_on_request_completed) $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): func _on_request_completed(result, response_code, headers, body):
if body.get_string_from_utf8() == "OK": if body.get_string_from_utf8() == "OK":

13
MainMenu.gd Normal file
View file

@ -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")

View file

@ -8,6 +8,7 @@ var exagon = preload("res://exagon.tscn")
var num_quares = 0 var num_quares = 0
var max_quares = 3 var max_quares = 3
var exagons = 1 var exagons = 1
var absolute_movement = false
func _ready(): func _ready():
update_display() update_display()
@ -16,11 +17,16 @@ func _physics_process(delta):
look_at(get_global_mouse_position()) look_at(get_global_mouse_position())
var move_input = Input.get_axis("down", "up") var move_input = Input.get_axis("down", "up")
var side_input = Input.get_axis("right", "left") 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): func _input(event):
if event.is_action_pressed("jump"): if event.is_action_pressed("jump"):
global_position = get_global_mouse_position() global_position = get_global_mouse_position()
if event.is_action_pressed("switch_input"):
absolute_movement = true
if event.is_action_pressed("quare"): if event.is_action_pressed("quare"):
if num_quares >= max_quares: if num_quares >= max_quares:
notifier.notify("All Quares in Use!") notifier.notify("All Quares in Use!")

View file

@ -8,8 +8,8 @@ func destroy():
if health <= 0: if health <= 0:
if not is_queued_for_deletion(): if not is_queued_for_deletion():
$"../../Player".aquire_exagon()
$"..".queue_free() $"..".queue_free()
$"../../Player".aquire_exagon()
modulate = Color(Color.CYAN, 0.7 - lerp(0.7, 0.1, health / max_health)) modulate = Color(Color.CYAN, 0.7 - lerp(0.7, 0.1, health / max_health))

View file

@ -4,6 +4,8 @@ extends Marker2D
@export var random_on_screen = false @export var random_on_screen = false
func spawn(): func spawn():
if get_tree().paused:
return
for i in range(10): for i in range(10):
var test_pos = Vector2(randf(), randf()) * Vector2(1920, 1080) var test_pos = Vector2(randf(), randf()) * Vector2(1920, 1080)
if not $"../CollisionCheck".is_clear(test_pos): if not $"../CollisionCheck".is_clear(test_pos):

8
ToggleableControl.gd Normal file
View file

@ -0,0 +1,8 @@
extends Label
func show():
show()
visible = true
func hide():
visible = false

View file

@ -28,7 +28,7 @@ colors = PackedColorArray(0.0509804, 0.0509804, 0.0509804, 1)
gradient = SubResource("Gradient_bi1rk") gradient = SubResource("Gradient_bi1rk")
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7w8g6"] [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"] [sub_resource type="GradientTexture1D" id="GradientTexture1D_vrv6v"]
gradient = ExtResource("4_yk0bb") gradient = ExtResource("4_yk0bb")
@ -46,7 +46,7 @@ normal = Vector2(1, 2.08165e-12)
normal = Vector2(-1, 2.08165e-12) normal = Vector2(-1, 2.08165e-12)
[sub_resource type="CircleShape2D" id="CircleShape2D_bmvvy"] [sub_resource type="CircleShape2D" id="CircleShape2D_bmvvy"]
radius = 50.0 radius = 100.0
[sub_resource type="Gradient" id="Gradient_or5lt"] [sub_resource type="Gradient" id="Gradient_or5lt"]
colors = PackedColorArray(1, 0, 0, 1, 1, 0, 0, 1) colors = PackedColorArray(1, 0, 0, 1, 1, 0, 0, 1)
@ -105,7 +105,7 @@ motion_mode = 1
script = ExtResource("5_7po8n") script = ExtResource("5_7po8n")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Clock"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Clock"]
position = Vector2(207, 192) position = Vector2(194.438, 192)
scale = Vector2(0.75, 0.75) scale = Vector2(0.75, 0.75)
shape = SubResource("RectangleShape2D_7w8g6") shape = SubResource("RectangleShape2D_7w8g6")
script = ExtResource("1_hy18x") script = ExtResource("1_hy18x")

178
main_menu.tscn Normal file
View file

@ -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"]

View file

@ -11,7 +11,7 @@ config_version=5
[application] [application]
config/name="Countdown" config/name="Countdown"
run/main_scene="res://main.tscn" run/main_scene="res://main_menu.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility") config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg" 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) "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] [rendering]