fix file location

This commit is contained in:
2025-09-27 21:25:55 +02:00
parent d4ae904c32
commit c9b9e7d637
9 changed files with 393 additions and 6 deletions

6
assets/score.tres Normal file
View File

@@ -0,0 +1,6 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://ck6b4fwyamkgd"]
[ext_resource type="Script" uid="uid://bc77vj158k2e" path="res://script/score.gd" id="1_p2k1x"]
[resource]
script = ExtResource("1_p2k1x")

250
assets/theme.tres Normal file
View File

@@ -0,0 +1,250 @@
[gd_resource type="Theme" load_steps=15 format=3 uid="uid://b46gto6k33wqr"]
[ext_resource type="FontFile" uid="uid://ck2l6kevep7uq" path="res://assets/Perfect DOS VGA 437.ttf" id="1_e1x85"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hqigj"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 1)
border_color = Color(1, 1, 1, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
expand_margin_left = 12.0
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yin2u"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0)
border_width_left = 4
border_width_top = 4
border_width_right = 4
border_width_bottom = 4
border_color = Color(1, 1, 1, 1)
corner_detail = 5
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fsxoa"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0.969137, 0.969137, 0.969137, 0.6)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ybu1x"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_535ge"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(1, 1, 1, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cjfk0"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(1, 1, 1, 1)
draw_center = false
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
expand_margin_left = 2.0
expand_margin_top = 2.0
expand_margin_right = 2.0
expand_margin_bottom = 2.0
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vj6dk"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(1, 1, 1, 0.07)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_110ce"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(1, 1, 1, 0.4)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_05tig"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0)
border_width_left = 4
border_width_top = 4
border_width_right = 4
border_width_bottom = 4
border_color = Color(1, 1, 1, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5
expand_margin_left = 4.0
expand_margin_top = 4.0
expand_margin_right = 4.0
expand_margin_bottom = 4.0
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1rmny"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 1)
border_width_left = 4
border_width_top = 4
border_width_right = 4
border_width_bottom = 4
border_color = Color(1, 1, 1, 1)
corner_detail = 5
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mihib"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0)
border_width_left = 4
border_width_top = 4
border_width_right = 4
border_width_bottom = 4
border_color = Color(1, 1, 1, 1)
corner_detail = 5
expand_margin_left = 8.0
expand_margin_top = 8.0
expand_margin_right = 8.0
expand_margin_bottom = 8.0
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e1x85"]
bg_color = Color(0, 0, 0, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(1, 1, 1, 1)
expand_margin_left = 2.0
expand_margin_top = 2.0
expand_margin_right = 2.0
expand_margin_bottom = 2.0
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_wvktn"]
content_margin_left = 0.0
content_margin_top = 0.0
content_margin_right = 0.0
content_margin_bottom = 0.0
bg_color = Color(0, 0, 0, 1)
corner_detail = 5
anti_aliasing = false
[resource]
Button/colors/font_color = Color(1, 1, 1, 1)
Button/colors/font_disabled_color = Color(0.875, 0.875, 0.875, 0.5)
Button/colors/font_focus_color = Color(0.95, 0.95, 0.95, 1)
Button/colors/font_hover_color = Color(0.95, 0.95, 0.95, 1)
Button/colors/font_hover_pressed_color = Color(1, 1, 1, 1)
Button/colors/font_outline_color = Color(0, 0, 0, 1)
Button/colors/font_pressed_color = Color(1, 1, 1, 1)
Button/colors/icon_disabled_color = Color(1, 1, 1, 0.4)
Button/colors/icon_focus_color = Color(1, 1, 1, 1)
Button/colors/icon_hover_color = Color(1, 1, 1, 1)
Button/colors/icon_hover_pressed_color = Color(1, 1, 1, 1)
Button/colors/icon_normal_color = Color(1, 1, 1, 1)
Button/colors/icon_pressed_color = Color(1, 1, 1, 1)
Button/constants/align_to_largest_stylebox = 0
Button/constants/h_separation = 4
Button/constants/icon_max_width = 0
Button/constants/outline_size = 0
Button/font_sizes/font_size = 32
Button/fonts/font = ExtResource("1_e1x85")
Button/styles/disabled = SubResource("StyleBoxFlat_hqigj")
Button/styles/focus = SubResource("StyleBoxFlat_yin2u")
Button/styles/hover = SubResource("StyleBoxFlat_fsxoa")
Button/styles/normal = SubResource("StyleBoxFlat_ybu1x")
Button/styles/pressed = SubResource("StyleBoxFlat_535ge")
ItemList/colors/font_color = Color(1, 1, 1, 1)
ItemList/colors/font_hovered_color = Color(0.95, 0.95, 0.95, 1)
ItemList/colors/font_hovered_selected_color = Color(1, 1, 1, 1)
ItemList/colors/font_outline_color = Color(0, 0, 0, 1)
ItemList/colors/font_selected_color = Color(1, 1, 1, 1)
ItemList/colors/guide_color = Color(0, 0, 0, 0)
ItemList/constants/h_separation = 8
ItemList/constants/icon_margin = 0
ItemList/constants/line_separation = 0
ItemList/constants/outline_size = 0
ItemList/constants/v_separation = 0
ItemList/font_sizes/font_size = 64
ItemList/fonts/font = ExtResource("1_e1x85")
ItemList/styles/cursor = SubResource("StyleBoxFlat_cjfk0")
ItemList/styles/cursor_unfocused = SubResource("StyleBoxFlat_cjfk0")
ItemList/styles/focus = SubResource("StyleBoxFlat_cjfk0")
ItemList/styles/hovered = SubResource("StyleBoxFlat_vj6dk")
ItemList/styles/hovered_selected = SubResource("StyleBoxFlat_110ce")
ItemList/styles/hovered_selected_focus = SubResource("StyleBoxFlat_05tig")
ItemList/styles/panel = SubResource("StyleBoxFlat_1rmny")
ItemList/styles/selected = SubResource("StyleBoxFlat_mihib")
ItemList/styles/selected_focus = SubResource("StyleBoxFlat_mihib")
Label/colors/font_color = Color(1, 1, 1, 1)
Label/colors/font_outline_color = Color(0, 0, 0, 1)
Label/colors/font_shadow_color = Color(0, 0, 0, 0)
Label/constants/line_spacing = 6
Label/constants/outline_size = 0
Label/constants/shadow_offset_x = 1
Label/constants/shadow_offset_y = 1
Label/constants/shadow_outline_size = 1
Label/font_sizes/font_size = 32
Label/fonts/font = ExtResource("1_e1x85")
Label/styles/normal = SubResource("StyleBoxFlat_e1x85")
PanelContainer/styles/panel = SubResource("StyleBoxFlat_wvktn")
ScrollContainer/styles/focus = SubResource("StyleBoxFlat_e1x85")
ScrollContainer/styles/panel = SubResource("StyleBoxFlat_e1x85")
VBoxContainer/constants/separation = 4

View File

@@ -12,7 +12,7 @@ config_version=5
config/name="asteroid"
run/main_scene="uid://jx8hrj6k1ju8"
config/features=PackedStringArray("4.4", "Forward Plus")
config/features=PackedStringArray("4.5", "Forward Plus")
boot_splash/bg_color=Color(0, 0, 0, 1)
boot_splash/use_filter=false
boot_splash/image="uid://bby053xsfn3cp"
@@ -20,7 +20,7 @@ config/icon="res://icon.svg"
[autoload]
GameController="*res://game_controller.gd"
GameController="*res://script/game_controller.gd"
[display]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=12 format=3 uid="uid://jx8hrj6k1ju8"]
[ext_resource type="PackedScene" uid="uid://d1ugwu6dqomtg" path="res://scene/wall.tscn" id="1_7iavl"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://theme.tres" id="3_7iavl"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://assets/theme.tres" id="3_7iavl"]
[ext_resource type="Script" uid="uid://dkolsh66l73k0" path="res://script/canvas_load.gd" id="3_pyuau"]
[ext_resource type="PackedScene" uid="uid://b6hqwxrexoa2n" path="res://scene/spawner.tscn" id="3_ruca2"]

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=6 format=3 uid="uid://hdekde5crm8g"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://theme.tres" id="1_g3ehp"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://assets/theme.tres" id="1_g3ehp"]
[ext_resource type="Script" uid="uid://5cghvv2m23uq" path="res://script/score_particles.gd" id="1_yb0l5"]
[sub_resource type="ViewportTexture" id="ViewportTexture_yb0l5"]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://cg11wahb2kyqs"]
[ext_resource type="Script" uid="uid://byok0e08rgu4l" path="res://script/score_saver.gd" id="1_3aw1o"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://theme.tres" id="1_sa1is"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://assets/theme.tres" id="1_sa1is"]
[sub_resource type="GDScript" id="GDScript_sa1is"]
script/source = "extends ItemList

View File

@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://b0oww62n1rvul" path="res://script/ui.gd" id="1_kee8w"]
[ext_resource type="Texture2D" uid="uid://b037piy3tkefs" path="res://assets/ship.png" id="1_onfsl"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://theme.tres" id="1_s2f8l"]
[ext_resource type="Theme" uid="uid://b46gto6k33wqr" path="res://assets/theme.tres" id="1_s2f8l"]
[ext_resource type="AudioStream" uid="uid://mlm2gi1vqj4b" path="res://audio/424911-impactshort78.wav" id="4_xh8xk"]
[node name="UI" type="CanvasLayer" node_paths=PackedStringArray("box_player1", "label_score")]

130
script/game_controller.gd Normal file
View File

@@ -0,0 +1,130 @@
extends Node
signal player_hit(bool)
signal start_game_one_player
signal start_game_two_player
signal go_to_menu(String)
signal point_gain(int, Vector2)
signal go_to_score_saver(int)
var is_multiplayer := false
var actual_score := 0
var score :Score
var delay_btw_input = 0.2
var current_ui = ""
var delay_input := 0.0
var music = AudioStreamPlayer.new()
func _music_finished():
music.play()
func _ready() -> void:
music.volume_db = -10
music.autoplay = true
music.play()
music.stream = load("res://audio/exodus.ogg")
music.connect("finished", _music_finished)
add_child(music)
connect("start_game_one_player",start_one_player)
connect("start_game_two_player",start_two_player)
connect("go_to_score_saver", start_score_saver)
connect("go_to_menu", start_menu)
if FileAccess.file_exists("user://Score.res"):
score = ResourceLoader.load("user://Score.res")
else:
score = Score.new()
func _input(event: InputEvent) -> void:
if event.is_action_pressed("quit"):
get_tree().quit()
elif event is InputEventJoypadMotion:
var array_ui = ["right", "left", "up", "down"]
var max := 0.0
var max_ui := ""
for ui in array_ui:
if max < Input.get_action_strength(ui):
max = Input.get_action_strength(ui)
max_ui = ui
if max < 0.5 :
delay_input = delay_btw_input
current_ui = ""
else:
current_ui = max_ui
func _process(delta: float) -> void:
if current_ui != "":
if delay_input < delay_btw_input:
delay_input += delta
else:
var uiEvent = InputEventAction.new()
uiEvent.action = "ui_" + current_ui
uiEvent.pressed = true
Input.parse_input_event(uiEvent)
delay_input = 0.0
func start_one_player()->void:
get_tree().change_scene_to_file("res://scene/main_game.tscn")
func start_two_player()->void:
is_multiplayer = true
get_tree().change_scene_to_file("res://scene/main_game_2_player.tscn")
func start_menu(user_name : String)->void:
if is_multiplayer:
var temp = score.score_multiplayer.get(user_name, -1.0)
if temp < actual_score:
score.score_multiplayer[user_name] = actual_score
else:
var temp = score.score_singleplayer.get(user_name, -1.0)
if temp < actual_score:
score.score_singleplayer[user_name] = actual_score
user_name = ""
actual_score = 0
is_multiplayer = false
score.save()
get_tree().call_deferred("change_scene_to_file", "res://scene/load_screen.tscn")
func start_score_saver(score: int)->void:
actual_score = score
get_tree().call_deferred("change_scene_to_file", "res://scene/score_saver.tscn")
func get_scoreboard_singleplayer(n_lignes: int = 0) -> String:
return _get_scoreboard(score.score_singleplayer, n_lignes)
func get_scoreboard_multiplayer(n_lignes: int = 0) -> String:
return _get_scoreboard(score.score_multiplayer, n_lignes)
func _get_scoreboard(dict: Dictionary, n_lignes: int) -> String:
var text = ""
var tableau_paires = []
for key in dict:
tableau_paires.append({"key": key, "value": dict[key]})
tableau_paires.sort_custom(func(a, b): return a["value"] > b["value"])
if n_lignes == 0:
n_lignes = clamp( tableau_paires.size(), 5, 1000)
for i in range(clamp(n_lignes, 0, tableau_paires.size())):
text += str(i+1) + ". " + tableau_paires[i]["key"] + " : " + display_score(tableau_paires[i]["value"])
if i < n_lignes-1:
text+="\n"
if tableau_paires.size() < n_lignes:
for i in range(n_lignes - tableau_paires.size()):
text += str(tableau_paires.size()+ i+1) + ". " + "---- : ----"
if i < n_lignes - tableau_paires.size() -1 :
text += "\n"
return text
func display_score(score: int) -> String:
var number_str = str(score)
var result = ""
var counter = 0
for i in range(number_str.length() - 1, -1, -1):
result = number_str[i] + result
counter += 1
if counter % 3 == 0 and i != 0:
result = "_" + result
return result

View File

@@ -0,0 +1 @@
uid://gvtqgujv723o