fixed loading bug

This commit is contained in:
Ultrablob 2024-04-23 14:38:44 -04:00
parent 4750befdfb
commit 5708cf5ea2
14 changed files with 421 additions and 98 deletions

BIN
.DS_Store vendored

Binary file not shown.

1
Gun.gd
View file

@ -7,5 +7,4 @@ func shoot():
var node = bullet.instantiate() var node = bullet.instantiate()
node.global_position = global_position node.global_position = global_position
node.linear_velocity = Vector2(500, 0).rotated(global_rotation) node.linear_velocity = Vector2(500, 0).rotated(global_rotation)
print(node.linear_velocity)
$/root/Node2D.add_child(node) $/root/Node2D.add_child(node)

View file

@ -2,9 +2,8 @@ extends RichTextLabel
@export var stopwatch: Stopwatch @export var stopwatch: Stopwatch
var config = ConfigFile.new() var config = ConfigFile.new()
const DEV = true
var API_BASE = "https://flask-hello-world-nine-psi.vercel.app" if not DEV else "http://127.0.0.1:5001" var API_BASE = "https://flask-hello-world-nine-psi.vercel.app"
func make_urlsafe(data: String): func make_urlsafe(data: String):
return data.replace("+", "-").replace("/", "_") return data.replace("+", "-").replace("/", "_")

View file

@ -1,20 +1,41 @@
extends Control extends Control
const MAIN_SCENE_PATH = "res://main.tscn" const MAIN_SCENE_PATH = "res://main.tscn"
var tip_level = 1
var config = ConfigFile.new()
# Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
$Layout/Play.disabled = true if config.load("user://settings.cfg") == OK:
ResourceLoader.load_threaded_request(MAIN_SCENE_PATH) if config.get_value("hidden", "tip_level") == null:
tip_level = 1
config.set_value("hidden", "tip_level", tip_level)
else:
tip_level = config.get_value("hidden", "tip_level")
if randi_range(0, 20) == 5: # small chance to get more and more insane tips as you keep playing
tip_level += 1
config.set_value("hidden", "tip_level", tip_level)
# Called every frame. 'delta' is the elapsed time since the previous frame. func pick(l):
func _process(delta): return l[randi_range(0, len(l)-1)]
var progress = ResourceLoader.load_threaded_get_status(MAIN_SCENE_PATH)
if progress == ResourceLoader.THREAD_LOAD_LOADED: func sort_tips():
$Layout/Play.disabled = false var tips = FileAccess.open("res://tips.txt", FileAccess.READ).get_as_text().strip_edges().split("\n")
$Layout/Play.text = "Play" var tips_by_level = {1: [], 2: [], 3: []}
for tip in tips:
var level = int(tip.split(" | ")[0])
var text = tip.split(" | ")[1]
tips_by_level[level].append(text)
return tips_by_level
func play(): func play():
var game = ResourceLoader.load_threaded_get(MAIN_SCENE_PATH) $"LoadingScreen".show()
get_tree().change_scene_to_packed(game) var tip_options = []
for i in range(1, tip_level+1):
tip_options += sort_tips()[i]
var tip = pick(tip_options)
$LoadingScreen/Tip.text = "Tip: %s" % tip
await get_tree().create_timer(0.2).timeout
#var game = ResourceLoader.load_threaded_get(MAIN_SCENE_PATH)
get_tree().change_scene_to_file(MAIN_SCENE_PATH)

View file

@ -6,20 +6,56 @@ var portal = preload("res://portal.tscn")
@export var random_off_screen = false @export var random_off_screen = false
@export var radius = 100 @export var radius = 100
func project_ray_to_screen_edge(player_position: Vector2) -> Vector2:
var screen_size = get_viewport().size
# Generate a random point on the screen
var random_point = Vector2(randf_range(0, screen_size.x), randf_range(0, screen_size.y))
# Calculate the direction vector from the player to the random point
var direction = (random_point - player_position).normalized()
# Calculate the intersection points with the screen edges
var intersection_points = []
# Check intersection with the left edge
var left_intersection = Vector2(0, player_position.y + direction.y * (0 - player_position.x) / direction.x)
if left_intersection.y >= 0 and left_intersection.y <= screen_size.y:
intersection_points.append(left_intersection)
# Check intersection with the right edge
var right_intersection = Vector2(screen_size.x, player_position.y + direction.y * (screen_size.x - player_position.x) / direction.x)
if right_intersection.y >= 0 and right_intersection.y <= screen_size.y:
intersection_points.append(right_intersection)
# Check intersection with the top edge
var top_intersection = Vector2(player_position.x + direction.x * (0 - player_position.y) / direction.y, 0)
if top_intersection.x >= 0 and top_intersection.x <= screen_size.x:
intersection_points.append(top_intersection)
# Check intersection with the bottom edge
var bottom_intersection = Vector2(player_position.x + direction.x * (screen_size.y - player_position.y) / direction.y, screen_size.y)
if bottom_intersection.x >= 0 and bottom_intersection.x <= screen_size.x:
intersection_points.append(bottom_intersection)
# Find the closest intersection point to the player
var closest_intersection = intersection_points[0]
var min_distance = player_position.distance_to(closest_intersection)
for point in intersection_points:
var distance = player_position.distance_to(point)
if distance < min_distance:
closest_intersection = point
min_distance = distance
return closest_intersection
func spawn(): func spawn():
if get_tree().paused: if get_tree().paused:
return return
var spawn_loc = Vector2.ZERO var spawn_loc = Vector2.ZERO
if random_off_screen: if random_off_screen:
var random = randi_range(1, 4) spawn_loc = project_ray_to_screen_edge($"../Player".global_position)
if random == 1: #print(spawn_loc)
spawn_loc = Vector2(-50, 1080 * randf())
elif random == 2:
spawn_loc = Vector2(1950, 1080 * randf())
elif random == 3:
spawn_loc = Vector2(1920 * randf(), -50)
elif random == 4:
spawn_loc = Vector2(1920 * randf(), 1080 + 50)
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, radius): if not $"../CollisionCheck".is_clear(test_pos, radius):
@ -28,12 +64,13 @@ func spawn():
break break
var portal_effect = portal.instantiate() if spawn_loc != Vector2.ZERO:
portal_effect.global_position = spawn_loc var portal_effect = portal.instantiate()
portal_effect.sprite_frames = portal_texture portal_effect.global_position = spawn_loc
$/root/Node2D.add_child(portal_effect) portal_effect.sprite_frames = portal_texture
await get_tree().create_timer(0.6).timeout $/root/Node2D.add_child(portal_effect)
var node = item.instantiate() await get_tree().create_timer(0.6).timeout
node.global_position = spawn_loc var node = item.instantiate()
node.rotation_degrees = 360 * randf() node.global_position = spawn_loc
$/root/Node2D.add_child(node) node.rotation_degrees = 360 * randf()
$/root/Node2D.add_child(node)

BIN
entagon portal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

34
entagon portal.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://byn1o4jm6dn4y"
path="res://.godot/imported/entagon portal.png-cf624790cf37be853e6691c0f34164da.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entagon portal.png"
dest_files=["res://.godot/imported/entagon portal.png-cf624790cf37be853e6691c0f34164da.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
loading_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://regt4psf4pxw" uid="uid://bdg4mycyxr8hw"
path="res://.godot/imported/quare.png-ab0056528a499e647ebe4838bd31ba15.ctex" path="res://.godot/imported/loading_bg.png-6e2f91c129751f2d4fc2240582b46e54.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://quare.png" source_file="res://loading_bg.png"
dest_files=["res://.godot/imported/quare.png-ab0056528a499e647ebe4838bd31ba15.ctex"] dest_files=["res://.godot/imported/loading_bg.png-6e2f91c129751f2d4fc2240582b46e54.ctex"]
[params] [params]

190
main.tscn

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://ck1db6d8whbac"] [gd_scene load_steps=7 format=3 uid="uid://ck1db6d8whbac"]
[ext_resource type="Script" path="res://MainMenu.gd" id="1_omrmt"] [ext_resource type="Script" path="res://MainMenu.gd" id="1_omrmt"]
[ext_resource type="Texture2D" uid="uid://bfuxwsctqat2v" path="res://main_menu.png" id="2_vrg41"] [ext_resource type="Texture2D" uid="uid://bfuxwsctqat2v" path="res://main_menu.png" id="2_vrg41"]
[ext_resource type="FontFile" uid="uid://bnguin7bsyx6e" path="res://Kenney Future.ttf" id="4_ybv7t"] [ext_resource type="FontFile" uid="uid://bnguin7bsyx6e" path="res://Kenney Future.ttf" id="4_ybv7t"]
[ext_resource type="Script" path="res://Settings.gd" id="5_sarwv"] [ext_resource type="Script" path="res://Settings.gd" id="5_sarwv"]
[ext_resource type="Texture2D" uid="uid://bdg4mycyxr8hw" path="res://loading_bg.png" id="6_fwqfu"]
[ext_resource type="Script" path="res://EmojiValidator.gd" id="6_ojb71"] [ext_resource type="Script" path="res://EmojiValidator.gd" id="6_ojb71"]
[node name="MainMenu" type="Control"] [node name="MainMenu" type="Control"]
@ -37,7 +38,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme_override_fonts/font = ExtResource("4_ybv7t") theme_override_fonts/font = ExtResource("4_ybv7t")
theme_override_font_sizes/font_size = 200 theme_override_font_sizes/font_size = 200
text = "Quare Game" text = "APE AME"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="Layout" type="VBoxContainer" parent="."] [node name="Layout" type="VBoxContainer" parent="."]
@ -194,6 +195,50 @@ theme_override_font_sizes/font_size = 50
text = "X" text = "X"
flat = true flat = true
[node name="LoadingScreen" type="TextureRect" parent="."]
visible = false
texture_filter = 1
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("6_fwqfu")
[node name="Tip" type="Label" parent="LoadingScreen"]
layout_mode = 1
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_top = -544.0
offset_bottom = -264.0
grow_horizontal = 2
grow_vertical = 2
theme_override_fonts/font = ExtResource("4_ybv7t")
theme_override_font_sizes/font_size = 60
text = "TIP: THE BULLETS OF A RIANGLE ALWAYS SHOOT FROM THE POINTS"
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[node name="Title" type="Label" parent="LoadingScreen"]
layout_mode = 1
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_top = 255.0
offset_bottom = 535.0
grow_horizontal = 2
grow_vertical = 2
theme_override_fonts/font = ExtResource("4_ybv7t")
theme_override_font_sizes/font_size = 200
text = "LOADING..."
horizontal_alignment = 1
vertical_alignment = 1
[connection signal="pressed" from="Layout/Play" to="." method="play"] [connection signal="pressed" from="Layout/Play" to="." method="play"]
[connection signal="pressed" from="Layout/Settings" to="Settings Panel" method="show"] [connection signal="pressed" from="Layout/Settings" to="Settings Panel" method="show"]
[connection signal="pressed" from="Layout/Tutorial" to="Tutorial Text" method="show"] [connection signal="pressed" from="Layout/Tutorial" to="Tutorial Text" method="show"]

BIN
quare.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

102
riangle_portal.tscn.tres Normal file
View file

@ -0,0 +1,102 @@
[gd_resource type="SpriteFrames" load_steps=15 format=3 uid="uid://tu8xwjkn0wrj"]
[ext_resource type="Texture2D" uid="uid://bu70lwr6f3igy" path="res://riangle-portal.png" id="1_feams"]
[sub_resource type="AtlasTexture" id="AtlasTexture_thlf3"]
atlas = ExtResource("1_feams")
region = Rect2(0, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_k8fir"]
atlas = ExtResource("1_feams")
region = Rect2(64, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_ef8n0"]
atlas = ExtResource("1_feams")
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_b4r12"]
atlas = ExtResource("1_feams")
region = Rect2(192, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_m80wu"]
atlas = ExtResource("1_feams")
region = Rect2(256, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_bgag0"]
atlas = ExtResource("1_feams")
region = Rect2(320, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_x8g3t"]
atlas = ExtResource("1_feams")
region = Rect2(384, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_bc75a"]
atlas = ExtResource("1_feams")
region = Rect2(448, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_7mie0"]
atlas = ExtResource("1_feams")
region = Rect2(512, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_lny5u"]
atlas = ExtResource("1_feams")
region = Rect2(576, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_oc8gy"]
atlas = ExtResource("1_feams")
region = Rect2(640, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_dy0eq"]
atlas = ExtResource("1_feams")
region = Rect2(704, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_hgt5f"]
atlas = ExtResource("1_feams")
region = Rect2(768, 0, 64, 64)
[resource]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_thlf3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_k8fir")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ef8n0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_b4r12")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m80wu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bgag0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x8g3t")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bc75a")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_7mie0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lny5u")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oc8gy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dy0eq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hgt5f")
}],
"loop": true,
"name": &"default",
"speed": 10.0
}]

14
tips.txt Normal file
View file

@ -0,0 +1,14 @@
2 | All shapes in this game do not have their first letter, because the first letter of shapes doesn't deserve to exist.
2 | To get a new high score, don't die.
1 | Ircles have 3 stages: aiming, locking on, and shooting.
1 | Press Q or E to place a quare or an exagon!
1 | There is a sound effect that plays when your exagon is at 1 hit left!
3 | You don't deserve to be alive. Everyone hates you. You can't change yourself.
2 | Absolute movement is absolutely better! You can aim your mouse without changing direction.
2 | Use the escape key to teleport! Teleportation only works after at least 2 minutes.
1 | This game was originally a countdown. It is no longer a countdown.
2 | If you want a bug to be fixed you can probably message the creator - but he won't respond because he wants to have a server and pretend its a real game
3 | Zach.
1 | You can control where the ectangle moves with your quares!
1 | Use your exagon if you are in danger!
1 | The bullets of a riangle always shoot from the points!