save work and menu
This commit is contained in:
BIN
assets/Perfect DOS VGA 437.ttf
Normal file
BIN
assets/Perfect DOS VGA 437.ttf
Normal file
Binary file not shown.
35
assets/Perfect DOS VGA 437.ttf.import
Normal file
35
assets/Perfect DOS VGA 437.ttf.import
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://ck2l6kevep7uq"
|
||||||
|
path="res://.godot/imported/Perfect DOS VGA 437.ttf-e2747b3849ad74daa3c36d7a4600806b.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/Perfect DOS VGA 437.ttf"
|
||||||
|
dest_files=["res://.godot/imported/Perfect DOS VGA 437.ttf-e2747b3849ad74daa3c36d7a4600806b.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=4
|
||||||
|
keep_rounding_remainders=true
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=true
|
||||||
|
preload=[]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
||||||
BIN
assets/ship.png
LFS
BIN
assets/ship.png
LFS
Binary file not shown.
BIN
assets/ship.png~
LFS
Normal file
BIN
assets/ship.png~
LFS
Normal file
Binary file not shown.
48
game_controller.gd
Normal file
48
game_controller.gd
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
signal player_hit
|
||||||
|
|
||||||
|
signal start_game_one_player
|
||||||
|
signal start_game_two_player
|
||||||
|
signal go_to_menu(String)
|
||||||
|
signal point_gain(int)
|
||||||
|
signal go_to_score_saver(int)
|
||||||
|
|
||||||
|
var is_multiplayer := false
|
||||||
|
var actual_score := 0
|
||||||
|
var score :Score
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
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 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:
|
||||||
|
printt(user_name, actual_score)
|
||||||
|
if is_multiplayer:
|
||||||
|
score.score_multiplayer[user_name] = actual_score
|
||||||
|
else:
|
||||||
|
score.score_singleplayer[user_name] = actual_score
|
||||||
|
user_name = ""
|
||||||
|
actual_score = 0
|
||||||
|
is_multiplayer = false
|
||||||
|
print(score.score_singleplayer)
|
||||||
|
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")
|
||||||
1
game_controller.gd.uid
Normal file
1
game_controller.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://gvtqgujv723o
|
||||||
@@ -15,6 +15,10 @@ run/main_scene="uid://jx8hrj6k1ju8"
|
|||||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
GameController="*res://game_controller.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=640
|
window/size/viewport_width=640
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://dbingmvgsgvfv" path="res://assets/asteroidx1.png" id="1_u87q6"]
|
[ext_resource type="Texture2D" uid="uid://dbingmvgsgvfv" path="res://assets/asteroidx1.png" id="1_u87q6"]
|
||||||
|
|
||||||
[node name="asteroid" type="RigidBody2D"]
|
[node name="asteroid" type="RigidBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 3
|
||||||
collision_mask = 2
|
collision_mask = 3
|
||||||
mass = 5.0
|
mass = 5.0
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
max_contacts_reported = 4
|
max_contacts_reported = 4
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://bby053xsfn3cp" path="res://assets/asteroidx2.png" id="2_e2m2r"]
|
[ext_resource type="Texture2D" uid="uid://bby053xsfn3cp" path="res://assets/asteroidx2.png" id="2_e2m2r"]
|
||||||
|
|
||||||
[node name="asteroid" type="RigidBody2D"]
|
[node name="asteroid" type="RigidBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 3
|
||||||
collision_mask = 2
|
collision_mask = 3
|
||||||
mass = 10.0
|
mass = 10.0
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
max_contacts_reported = 4
|
max_contacts_reported = 4
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://dt08ism4ulfay" path="res://assets/asteroidx3.png" id="2_beklf"]
|
[ext_resource type="Texture2D" uid="uid://dt08ism4ulfay" path="res://assets/asteroidx3.png" id="2_beklf"]
|
||||||
|
|
||||||
[node name="asteroid" type="RigidBody2D"]
|
[node name="asteroid" type="RigidBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 3
|
||||||
collision_mask = 2
|
collision_mask = 3
|
||||||
mass = 20.0
|
mass = 20.0
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
max_contacts_reported = 4
|
max_contacts_reported = 4
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://bs836c8u5j3y6" path="res://assets/asteroidx4.png" id="2_gv6mu"]
|
[ext_resource type="Texture2D" uid="uid://bs836c8u5j3y6" path="res://assets/asteroidx4.png" id="2_gv6mu"]
|
||||||
|
|
||||||
[node name="asteroid" type="RigidBody2D"]
|
[node name="asteroid" type="RigidBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 3
|
||||||
collision_mask = 2
|
collision_mask = 3
|
||||||
mass = 40.0
|
mass = 40.0
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
max_contacts_reported = 4
|
max_contacts_reported = 4
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://jx8hrj6k1ju8"]
|
[gd_scene load_steps=9 format=3 uid="uid://jx8hrj6k1ju8"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://d1ugwu6dqomtg" path="res://scene/wall.tscn" id="1_7iavl"]
|
[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://theme.tres" id="3_7iavl"]
|
||||||
@@ -9,6 +9,19 @@ script/source = "extends Button
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
grab_focus()
|
grab_focus()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_pressed() -> void:
|
||||||
|
GameController.emit_signal(\"start_game_one_player\")
|
||||||
|
"
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_ruca2"]
|
||||||
|
script/source = "extends Button
|
||||||
|
|
||||||
|
|
||||||
|
func _on_pressed() -> void:
|
||||||
|
GameController.emit_signal(\"start_game_two_player\")
|
||||||
"
|
"
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_7iavl"]
|
[sub_resource type="GDScript" id="GDScript_7iavl"]
|
||||||
@@ -20,6 +33,34 @@ func _on_pressed() -> void:
|
|||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
"
|
"
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_dogtj"]
|
||||||
|
script/source = "extends Label
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
var tableau_paires = []
|
||||||
|
for key in GameController.score.score_singleplayer:
|
||||||
|
tableau_paires.append({\"key\": key, \"value\": GameController.score.score_singleplayer[key]})
|
||||||
|
|
||||||
|
# Trier par ordre alphabétique
|
||||||
|
tableau_paires.sort_custom(func(a, b): return a[\"value\"] > b[\"value\"])
|
||||||
|
for i in range(clamp(5, 0, tableau_paires.size())):
|
||||||
|
text += tableau_paires[i][\"key\"] + \" : \" + str(tableau_paires[i][\"value\"]) + \"\\n\"
|
||||||
|
"
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_u3kfb"]
|
||||||
|
script/source = "extends Label
|
||||||
|
func _ready() -> void:
|
||||||
|
var tableau_paires = []
|
||||||
|
for key in GameController.score.score_multiplayer:
|
||||||
|
print(key)
|
||||||
|
tableau_paires.append({\"key\": key, \"value\": GameController.score.score_multiplayer[key]})
|
||||||
|
|
||||||
|
# Trier par ordre alphabétique
|
||||||
|
tableau_paires.sort_custom(func(a, b): return a[\"value\"] < b[\"value\"])
|
||||||
|
for i in range(clamp(5, 0, tableau_paires.size())):
|
||||||
|
text += tableau_paires[i][\"key\"] + \" : \" + str(tableau_paires[i][\"value\"]) + \"\\n\"
|
||||||
|
"
|
||||||
|
|
||||||
[node name="load_screen" type="Node2D"]
|
[node name="load_screen" type="Node2D"]
|
||||||
|
|
||||||
[node name="wall" parent="." node_paths=PackedStringArray("spawner") instance=ExtResource("1_7iavl")]
|
[node name="wall" parent="." node_paths=PackedStringArray("spawner") instance=ExtResource("1_7iavl")]
|
||||||
@@ -29,7 +70,8 @@ spawner = NodePath("../spawner")
|
|||||||
|
|
||||||
[node name="spawner" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_ruca2")]
|
[node name="spawner" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_ruca2")]
|
||||||
player = NodePath("../CharacterBody2D")
|
player = NodePath("../CharacterBody2D")
|
||||||
delay_spawn = 1.0
|
distance = 500.0
|
||||||
|
delay_spawn = 0.5
|
||||||
load_screen = true
|
load_screen = true
|
||||||
|
|
||||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||||
@@ -57,6 +99,7 @@ offset_right = 75.5
|
|||||||
offset_bottom = 55.0
|
offset_bottom = 55.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
theme_override_constants/separation = 64
|
||||||
|
|
||||||
[node name="buttons" type="VBoxContainer" parent="CanvasLayer/Control/HBoxContainer"]
|
[node name="buttons" type="VBoxContainer" parent="CanvasLayer/Control/HBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
@@ -77,8 +120,8 @@ size_flags_vertical = 0
|
|||||||
focus_next = NodePath("../exit")
|
focus_next = NodePath("../exit")
|
||||||
focus_previous = NodePath("../1")
|
focus_previous = NodePath("../1")
|
||||||
theme = ExtResource("3_7iavl")
|
theme = ExtResource("3_7iavl")
|
||||||
disabled = true
|
|
||||||
text = "2 Players"
|
text = "2 Players"
|
||||||
|
script = SubResource("GDScript_ruca2")
|
||||||
|
|
||||||
[node name="exit" type="Button" parent="CanvasLayer/Control/HBoxContainer/buttons"]
|
[node name="exit" type="Button" parent="CanvasLayer/Control/HBoxContainer/buttons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
@@ -92,11 +135,18 @@ script = SubResource("GDScript_7iavl")
|
|||||||
|
|
||||||
[node name="scores" type="VBoxContainer" parent="CanvasLayer/Control/HBoxContainer"]
|
[node name="scores" type="VBoxContainer" parent="CanvasLayer/Control/HBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 64
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="CanvasLayer/Control/HBoxContainer/scores"]
|
[node name="Label" type="Label" parent="CanvasLayer/Control/HBoxContainer/scores"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
theme = ExtResource("3_7iavl")
|
||||||
|
script = SubResource("GDScript_dogtj")
|
||||||
|
|
||||||
[node name="Label2" type="Label" parent="CanvasLayer/Control/HBoxContainer/scores"]
|
[node name="Label2" type="Label" parent="CanvasLayer/Control/HBoxContainer/scores"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
theme = ExtResource("3_7iavl")
|
||||||
|
script = SubResource("GDScript_u3kfb")
|
||||||
|
|
||||||
|
[connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/buttons/1" to="CanvasLayer/Control/HBoxContainer/buttons/1" method="_on_pressed"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/buttons/2" to="CanvasLayer/Control/HBoxContainer/buttons/2" method="_on_pressed"]
|
||||||
[connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/buttons/exit" to="CanvasLayer/Control/HBoxContainer/buttons/exit" method="_on_pressed"]
|
[connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/buttons/exit" to="CanvasLayer/Control/HBoxContainer/buttons/exit" method="_on_pressed"]
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://btcb75wp78ory"]
|
[gd_scene load_steps=5 format=3 uid="uid://btcb75wp78ory"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://d1ugwu6dqomtg" path="res://scene/wall.tscn" id="1_u115g"]
|
[ext_resource type="PackedScene" uid="uid://d1ugwu6dqomtg" path="res://scene/wall.tscn" id="1_u115g"]
|
||||||
[ext_resource type="PackedScene" uid="uid://36q833dx6dmq" path="res://scene/ship.tscn" id="2_02eqj"]
|
[ext_resource type="PackedScene" uid="uid://36q833dx6dmq" path="res://scene/ship.tscn" id="2_02eqj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b6hqwxrexoa2n" path="res://scene/spawner.tscn" id="3_50rem"]
|
[ext_resource type="PackedScene" uid="uid://b6hqwxrexoa2n" path="res://scene/spawner.tscn" id="3_50rem"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c6dtnhntsit8m" path="res://scene/ui.tscn" id="4_02eqj"]
|
||||||
|
|
||||||
[node name="main_game" type="Node2D"]
|
[node name="main_game" type="Node2D"]
|
||||||
|
|
||||||
@@ -10,9 +11,10 @@
|
|||||||
spawner = NodePath("../spawner")
|
spawner = NodePath("../spawner")
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
zoom = Vector2(0.375, 0.375)
|
|
||||||
|
|
||||||
[node name="CharacterBody2D" parent="." instance=ExtResource("2_02eqj")]
|
[node name="CharacterBody2D" parent="." instance=ExtResource("2_02eqj")]
|
||||||
|
|
||||||
[node name="spawner" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_50rem")]
|
[node name="spawner" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_50rem")]
|
||||||
player = NodePath("../CharacterBody2D")
|
player = NodePath("../CharacterBody2D")
|
||||||
|
|
||||||
|
[node name="UI" parent="." instance=ExtResource("4_02eqj")]
|
||||||
|
|||||||
26
scene/main_game_2_player.tscn
Normal file
26
scene/main_game_2_player.tscn
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://diofotlwedch3"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://d1ugwu6dqomtg" path="res://scene/wall.tscn" id="1_xu8ia"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://36q833dx6dmq" path="res://scene/ship.tscn" id="2_xilri"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b6hqwxrexoa2n" path="res://scene/spawner.tscn" id="3_hepd6"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c6dtnhntsit8m" path="res://scene/ui.tscn" id="4_xilri"]
|
||||||
|
|
||||||
|
[node name="main_game_2_player" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="wall" parent="." node_paths=PackedStringArray("spawner") instance=ExtResource("1_xu8ia")]
|
||||||
|
spawner = NodePath("../spawner")
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CharacterBody2D" parent="." instance=ExtResource("2_xilri")]
|
||||||
|
position = Vector2(-141, -33)
|
||||||
|
rotation = -1.5708
|
||||||
|
|
||||||
|
[node name="CharacterBody2D2" parent="." instance=ExtResource("2_xilri")]
|
||||||
|
position = Vector2(115, -33)
|
||||||
|
rotation = -1.5708
|
||||||
|
|
||||||
|
[node name="spawner" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_hepd6")]
|
||||||
|
player = NodePath("../CharacterBody2D")
|
||||||
|
|
||||||
|
[node name="UI" parent="." instance=ExtResource("4_xilri")]
|
||||||
92
scene/score_saver.tscn
Normal file
92
scene/score_saver.tscn
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
[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"]
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_sa1is"]
|
||||||
|
script/source = "extends ItemList
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
grab_focus()
|
||||||
|
"
|
||||||
|
|
||||||
|
[node name="score_saver" type="Node2D" node_paths=PackedStringArray("keyboard", "label_name")]
|
||||||
|
script = ExtResource("1_3aw1o")
|
||||||
|
keyboard = NodePath("Control/ItemList")
|
||||||
|
label_name = NodePath("Control/Label")
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
custom_minimum_size = Vector2(640, 640)
|
||||||
|
offset_right = 640.0
|
||||||
|
offset_bottom = 640.0
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="."]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="ItemList" type="ItemList" parent="Control"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_top = 425.0
|
||||||
|
offset_right = 641.0
|
||||||
|
offset_bottom = 640.0
|
||||||
|
theme = ExtResource("1_sa1is")
|
||||||
|
auto_width = true
|
||||||
|
item_count = 32
|
||||||
|
max_columns = 11
|
||||||
|
item_0/text = "A"
|
||||||
|
item_1/text = "B"
|
||||||
|
item_2/text = "C"
|
||||||
|
item_3/text = "D"
|
||||||
|
item_4/text = "E"
|
||||||
|
item_5/text = "F"
|
||||||
|
item_6/text = "G"
|
||||||
|
item_7/text = "H"
|
||||||
|
item_8/text = " "
|
||||||
|
item_8/selectable = false
|
||||||
|
item_8/disabled = true
|
||||||
|
item_9/text = "Back"
|
||||||
|
item_10/text = " "
|
||||||
|
item_10/selectable = false
|
||||||
|
item_10/disabled = true
|
||||||
|
item_11/text = "I"
|
||||||
|
item_12/text = "J"
|
||||||
|
item_13/text = "K"
|
||||||
|
item_14/text = "L"
|
||||||
|
item_15/text = "M"
|
||||||
|
item_16/text = "N"
|
||||||
|
item_17/text = "O"
|
||||||
|
item_18/text = "P"
|
||||||
|
item_19/text = " "
|
||||||
|
item_19/selectable = false
|
||||||
|
item_19/disabled = true
|
||||||
|
item_20/text = "Enter"
|
||||||
|
item_21/text = " "
|
||||||
|
item_21/selectable = false
|
||||||
|
item_21/disabled = true
|
||||||
|
item_22/text = "Q"
|
||||||
|
item_23/text = "R"
|
||||||
|
item_24/text = "S"
|
||||||
|
item_25/text = "T"
|
||||||
|
item_26/text = "U"
|
||||||
|
item_27/text = "V"
|
||||||
|
item_28/text = "W"
|
||||||
|
item_29/text = "X"
|
||||||
|
item_30/text = "Y"
|
||||||
|
item_31/text = "Z"
|
||||||
|
script = SubResource("GDScript_sa1is")
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
offset_right = 463.0
|
||||||
|
offset_bottom = 160.0
|
||||||
|
theme = ExtResource("1_sa1is")
|
||||||
|
theme_override_font_sizes/font_size = 64
|
||||||
|
text = "Player Name 0/15:"
|
||||||
|
|
||||||
|
[connection signal="item_activated" from="Control/ItemList" to="." method="_on_item_list_item_activated"]
|
||||||
|
[connection signal="item_selected" from="Control/ItemList" to="." method="_on_item_list_item_selected"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://36q833dx6dmq"]
|
[gd_scene load_steps=8 format=3 uid="uid://36q833dx6dmq"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c3i2bhlectmoo" path="res://script/ship.gd" id="1_4cq66"]
|
[ext_resource type="Script" uid="uid://c3i2bhlectmoo" path="res://script/ship.gd" id="1_4cq66"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b037piy3tkefs" path="res://assets/ship.png" id="1_l3rv8"]
|
[ext_resource type="Texture2D" uid="uid://b037piy3tkefs" path="res://assets/ship.png" id="1_l3rv8"]
|
||||||
@@ -6,11 +6,48 @@
|
|||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4cq66"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4cq66"]
|
||||||
|
|
||||||
[node name="CharacterBody2D" type="CharacterBody2D"]
|
[sub_resource type="Animation" id="Animation_bf7x5"]
|
||||||
collision_layer = 3
|
resource_name = "blink"
|
||||||
collision_mask = 3
|
length = 2.0
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Ship:modulate")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.2, 0.4, 0.601246, 0.801246, 1, 1.20781, 1.40781, 1.60781, 1.80906, 2),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_fbih1"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Ship:modulate")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_l7n8u"]
|
||||||
|
_data = {
|
||||||
|
&"RESET": SubResource("Animation_fbih1"),
|
||||||
|
&"blink": SubResource("Animation_bf7x5")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="CharacterBody2D" type="CharacterBody2D" node_paths=PackedStringArray("animation")]
|
||||||
script = ExtResource("1_4cq66")
|
script = ExtResource("1_4cq66")
|
||||||
SHOOT_NODE = ExtResource("2_v4325")
|
SHOOT_NODE = ExtResource("2_v4325")
|
||||||
|
TIME_INVUL = 2.0
|
||||||
|
animation = NodePath("AnimationPlayer")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
@@ -20,3 +57,8 @@ shape = SubResource("RectangleShape2D_4cq66")
|
|||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
texture = ExtResource("1_l3rv8")
|
texture = ExtResource("1_l3rv8")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
&"": SubResource("AnimationLibrary_l7n8u")
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,3 +20,5 @@ texture = ExtResource("1_ttj7r")
|
|||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("CircleShape2D_yt1ub")
|
shape = SubResource("CircleShape2D_yt1ub")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
|||||||
71
scene/ui.tscn
Normal file
71
scene/ui.tscn
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://c6dtnhntsit8m"]
|
||||||
|
|
||||||
|
[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"]
|
||||||
|
|
||||||
|
[node name="UI" type="CanvasLayer" node_paths=PackedStringArray("box_player1", "label_score")]
|
||||||
|
script = ExtResource("1_kee8w")
|
||||||
|
box_player1 = NodePath("Control/player1")
|
||||||
|
label_score = NodePath("Control/Label")
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="."]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="player1" type="HBoxContainer" parent="Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 2
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -32.0
|
||||||
|
offset_right = 96.0
|
||||||
|
grow_vertical = 0
|
||||||
|
theme_override_constants/separation = 0
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="Control/player1"]
|
||||||
|
custom_minimum_size = Vector2(32, 32)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("1_s2f8l")
|
||||||
|
|
||||||
|
[node name="Ship" type="Sprite2D" parent="Control/player1/PanelContainer"]
|
||||||
|
texture = ExtResource("1_onfsl")
|
||||||
|
centered = false
|
||||||
|
|
||||||
|
[node name="PanelContainer2" type="PanelContainer" parent="Control/player1"]
|
||||||
|
custom_minimum_size = Vector2(32, 32)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("1_s2f8l")
|
||||||
|
|
||||||
|
[node name="Ship" type="Sprite2D" parent="Control/player1/PanelContainer2"]
|
||||||
|
texture = ExtResource("1_onfsl")
|
||||||
|
centered = false
|
||||||
|
|
||||||
|
[node name="PanelContainer3" type="PanelContainer" parent="Control/player1"]
|
||||||
|
custom_minimum_size = Vector2(32, 32)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("1_s2f8l")
|
||||||
|
|
||||||
|
[node name="Ship" type="Sprite2D" parent="Control/player1/PanelContainer3"]
|
||||||
|
texture = ExtResource("1_onfsl")
|
||||||
|
centered = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 3
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -40.0
|
||||||
|
offset_top = -23.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 0
|
||||||
|
theme = ExtResource("1_s2f8l")
|
||||||
|
text = "0"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
vertical_alignment = 1
|
||||||
6
score.tres
Normal file
6
score.tres
Normal 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")
|
||||||
@@ -15,7 +15,7 @@ var delay_dup := 0.0
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_to_group("asteroid")
|
add_to_group("asteroid")
|
||||||
SPEED = randf() / 50 +50
|
|
||||||
rotation = randf_range(0.0, 360.0)
|
rotation = randf_range(0.0, 360.0)
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
@@ -47,8 +47,8 @@ func split():
|
|||||||
second.direction = direction
|
second.direction = direction
|
||||||
first.global_position = position + (2**type * nor)
|
first.global_position = position + (2**type * nor)
|
||||||
first.type = type-1
|
first.type = type-1
|
||||||
first.set_collision_layer(3)
|
first.SPEED = SPEED
|
||||||
second.set_collision_layer(3)
|
second.SPEED = SPEED
|
||||||
second.global_position = position - (2**type * nor)
|
second.global_position = position - (2**type * nor)
|
||||||
second.type = type-1
|
second.type = type-1
|
||||||
var parent = get_parent()
|
var parent = get_parent()
|
||||||
@@ -65,4 +65,7 @@ func _on_body_entered(body: Node) -> void:
|
|||||||
elif body.is_in_group("shoot"):
|
elif body.is_in_group("shoot"):
|
||||||
body.destroy = true
|
body.destroy = true
|
||||||
body.queue_free()
|
body.queue_free()
|
||||||
|
GameController.emit_signal("point_gain", type)
|
||||||
split()
|
split()
|
||||||
|
elif body is Ship and !body.is_inv():
|
||||||
|
GameController.emit_signal("player_hit")
|
||||||
|
|||||||
9
script/score.gd
Normal file
9
script/score.gd
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class_name Score
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
@export var score_singleplayer : Dictionary[String, int]
|
||||||
|
@export var score_multiplayer: Dictionary[String, int]
|
||||||
|
|
||||||
|
|
||||||
|
func save():
|
||||||
|
ResourceSaver.save(self, "user://Score.res")
|
||||||
1
script/score.gd.uid
Normal file
1
script/score.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bc77vj158k2e
|
||||||
23
script/score_saver.gd
Normal file
23
script/score_saver.gd
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
var player_name := ""
|
||||||
|
@export var keyboard := ItemList
|
||||||
|
@export var label_name := Label
|
||||||
|
|
||||||
|
|
||||||
|
func _on_item_list_item_selected(index: int) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _on_item_list_item_activated(index: int) -> void:
|
||||||
|
var temp = $Control/ItemList.get_item_text(index)
|
||||||
|
print(temp)
|
||||||
|
var nbr = player_name.length()
|
||||||
|
if temp == "Back":
|
||||||
|
player_name[-1] = ""
|
||||||
|
elif temp == "Enter":
|
||||||
|
GameController.emit_signal("go_to_menu", player_name)
|
||||||
|
elif nbr < 10:
|
||||||
|
player_name += temp
|
||||||
|
nbr = player_name.length()
|
||||||
|
label_name.text = "Player Name " + str(nbr) +"/10:\n" + player_name
|
||||||
1
script/score_saver.gd.uid
Normal file
1
script/score_saver.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://byok0e08rgu4l
|
||||||
@@ -4,6 +4,8 @@ class_name Ship
|
|||||||
|
|
||||||
@export var MAX_SPEED: float = 200
|
@export var MAX_SPEED: float = 200
|
||||||
@export var SHOOT_NODE: PackedScene
|
@export var SHOOT_NODE: PackedScene
|
||||||
|
@export var TIME_INVUL := 1.0
|
||||||
|
@export var animation : AnimationPlayer
|
||||||
|
|
||||||
const SPEED = 25.0
|
const SPEED = 25.0
|
||||||
const JUMP_VELOCITY = -400.0
|
const JUMP_VELOCITY = -400.0
|
||||||
@@ -14,19 +16,22 @@ var vertical : float
|
|||||||
var rota_temp: float
|
var rota_temp: float
|
||||||
var delay := 0.0
|
var delay := 0.0
|
||||||
var is_in = true
|
var is_in = true
|
||||||
|
var delay_inv := 0.0
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
pass
|
pass
|
||||||
if event is InputEventMouseMotion:
|
|
||||||
mouse_position = event.position
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
delay_inv = TIME_INVUL +1
|
||||||
|
GameController.connect("player_hit", start_inv)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
delay += delta
|
delay += delta
|
||||||
if Input.is_action_pressed("ui_accept") and delay >= 0.5:
|
if is_inv():
|
||||||
shoot()
|
delay_inv += delta
|
||||||
delay = 0
|
animation.play("blink")
|
||||||
|
else:
|
||||||
|
animation.play("RESET")
|
||||||
|
|
||||||
horizontal = Input.get_axis("ui_up", "ui_down")
|
horizontal = Input.get_axis("ui_up", "ui_down")
|
||||||
vertical = Input.get_axis("ui_left", "ui_right")
|
vertical = Input.get_axis("ui_left", "ui_right")
|
||||||
@@ -41,8 +46,12 @@ func _physics_process(delta: float) -> void:
|
|||||||
velocity.y = move_toward(velocity.y, 0, SPEED)
|
velocity.y = move_toward(velocity.y, 0, SPEED)
|
||||||
|
|
||||||
if horizontal != 0 or vertical != 0:
|
if horizontal != 0 or vertical != 0:
|
||||||
direction = velocity
|
direction = Vector2(vertical, horizontal)
|
||||||
rotation = atan2(horizontal, vertical)
|
rotation = atan2(horizontal, vertical)
|
||||||
|
|
||||||
|
if Input.is_action_pressed("ui_accept") and delay >= 0.5:
|
||||||
|
shoot()
|
||||||
|
delay = 0
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
@@ -52,3 +61,10 @@ func shoot()->void:
|
|||||||
new.direction = direction
|
new.direction = direction
|
||||||
new.position = position + (32 * direction.normalized())
|
new.position = position + (32 * direction.normalized())
|
||||||
get_parent().add_child(new)
|
get_parent().add_child(new)
|
||||||
|
|
||||||
|
|
||||||
|
func is_inv() -> bool:
|
||||||
|
return delay_inv <= TIME_INVUL
|
||||||
|
|
||||||
|
func start_inv()->void:
|
||||||
|
delay_inv = 0.0
|
||||||
|
|||||||
@@ -18,3 +18,8 @@ func _process(delta: float) -> void:
|
|||||||
time += delta
|
time += delta
|
||||||
if time >= 2:
|
if time >= 2:
|
||||||
self.queue_free()
|
self.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node) -> void:
|
||||||
|
if body is Shoot:
|
||||||
|
self.queue_free()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class_name Spawner
|
|||||||
@export var load_screen:= false
|
@export var load_screen:= false
|
||||||
|
|
||||||
var current_time := 0.0
|
var current_time := 0.0
|
||||||
|
var global_time := 0.0
|
||||||
signal add_collision
|
signal add_collision
|
||||||
|
|
||||||
var list_of_collision_1 : Array[Node]
|
var list_of_collision_1 : Array[Node]
|
||||||
@@ -34,7 +34,8 @@ func _process(delta: float) -> void:
|
|||||||
list_of_collision_1 = []
|
list_of_collision_1 = []
|
||||||
list_of_collision_2 = []
|
list_of_collision_2 = []
|
||||||
current_time += delta
|
current_time += delta
|
||||||
if current_time >= delay_spawn and ((load_screen and get_children().size() < 10) or not load_screen):
|
global_time += delta
|
||||||
|
if current_time >= clampf(delay_spawn * (1- (global_time / 200)), 0.5, 100) and ((load_screen and get_children().size() < 10) or not load_screen):
|
||||||
current_time = 0
|
current_time = 0
|
||||||
spawn()
|
spawn()
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ func spawn_duplicate(asteroid: Node2D):
|
|||||||
dup.type = asteroid.type
|
dup.type = asteroid.type
|
||||||
dup.is_in = false
|
dup.is_in = false
|
||||||
var new_pos = (asteroid.position ).rotated(PI)
|
var new_pos = (asteroid.position ).rotated(PI)
|
||||||
|
dup.SPEED = asteroid.SPEED
|
||||||
dup.position = new_pos
|
dup.position = new_pos
|
||||||
dup.rotation = asteroid.rotation
|
dup.rotation = asteroid.rotation
|
||||||
dup.direction = asteroid.direction
|
dup.direction = asteroid.direction
|
||||||
@@ -66,6 +68,7 @@ func spawn():
|
|||||||
var new_global_position = Vector2(distance,0).rotated(randf_range(0.0, 360))
|
var new_global_position = Vector2(distance,0).rotated(randf_range(0.0, 360))
|
||||||
new.global_position = new_global_position
|
new.global_position = new_global_position
|
||||||
new.direction = (player.global_position - new_global_position).normalized()
|
new.direction = (player.global_position - new_global_position).normalized()
|
||||||
|
new.SPEED = randf() * 50 + 50 * ( 1 + (global_time / 200))
|
||||||
add_child(new)
|
add_child(new)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
25
script/ui.gd
Normal file
25
script/ui.gd
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
extends CanvasLayer
|
||||||
|
|
||||||
|
@export var box_player1: HBoxContainer
|
||||||
|
@export var label_score: Label
|
||||||
|
var player_life:= 3
|
||||||
|
var score := 0
|
||||||
|
var time := 0.0
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
GameController.connect("player_hit", update_player)
|
||||||
|
GameController.connect("point_gain", update_score)
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
time += delta
|
||||||
|
|
||||||
|
func update_score(add : int)->void:
|
||||||
|
score += 2 ** (5-add) * (1 + (time / 100))
|
||||||
|
label_score.text = str(score)
|
||||||
|
|
||||||
|
func update_player() -> void:
|
||||||
|
player_life -= 1
|
||||||
|
if player_life < 0:
|
||||||
|
GameController.emit_signal("go_to_score_saver", score)
|
||||||
|
box_player1.get_children(false)[player_life].visible = false
|
||||||
1
script/ui.gd.uid
Normal file
1
script/ui.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://b0oww62n1rvul
|
||||||
@@ -38,6 +38,7 @@ func _is_in_false(body: Node2D) -> void:
|
|||||||
new_shoot.rotation = body.rotation
|
new_shoot.rotation = body.rotation
|
||||||
new_shoot.time = body.time
|
new_shoot.time = body.time
|
||||||
get_parent().call_deferred("add_child",new_shoot)
|
get_parent().call_deferred("add_child",new_shoot)
|
||||||
|
body.queue_free()
|
||||||
|
|
||||||
|
|
||||||
func _on_wall_destroy_body_entered(body: Node2D) -> void:
|
func _on_wall_destroy_body_entered(body: Node2D) -> void:
|
||||||
|
|||||||
4832
theme.tres
4832
theme.tres
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user