-feat: implement working pause menu and controller.
This commit is contained in:
parent
1003acd32d
commit
ce5f0c9241
|
|
@ -1,14 +0,0 @@
|
||||||
shader_type canvas_item;
|
|
||||||
|
|
||||||
void vertex() {
|
|
||||||
// Called for every vertex the material is visible on.
|
|
||||||
}
|
|
||||||
|
|
||||||
void fragment() {
|
|
||||||
// Called for every pixel the material is visible on.
|
|
||||||
}
|
|
||||||
|
|
||||||
//void light() {
|
|
||||||
// Called for every pixel for every light affecting the CanvasItem.
|
|
||||||
// Uncomment to replace the default light processing function with this one.
|
|
||||||
//}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://cpiy3kiwt8pdi"]
|
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://soden53qtfxf" path="res://assets/Ships/Fighters/Enemy/enemyFighter.png" id="1_aomjn"]
|
|
||||||
[ext_resource type="Script" path="res://script/enemy_fighter.cs" id="1_rkm3y"]
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_6vq6f"]
|
|
||||||
radius = 41.0488
|
|
||||||
|
|
||||||
[node name="EnemyFighter" type="CharacterBody2D"]
|
|
||||||
script = ExtResource("1_rkm3y")
|
|
||||||
faction = 2
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
|
||||||
shape = SubResource("CircleShape2D_6vq6f")
|
|
||||||
|
|
||||||
[node name="ShipSprite" type="Sprite2D" parent="."]
|
|
||||||
texture = ExtResource("1_aomjn")
|
|
||||||
|
|
||||||
[node name="LaserSpawn" type="Node2D" parent="."]
|
|
||||||
position = Vector2(0, -58)
|
|
||||||
|
|
||||||
[node name="EffectSpawn" type="Node2D" parent="."]
|
|
||||||
File diff suppressed because one or more lines are too long
61
MB_FYP/scenes/pause_menu.tscn
Normal file
61
MB_FYP/scenes/pause_menu.tscn
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://btjj225d18y2q"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://be6xxaq8drt5q" path="res://assets/Fonts/Kenney Pixel Square.ttf" id="1_b7j7x"]
|
||||||
|
[ext_resource type="Script" path="res://script/pause_menu.cs" id="1_mq0ks"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://01tjlnox4crb" path="res://scenes/input_menu.tscn" id="2_ugxyj"]
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_6mqtv"]
|
||||||
|
font = ExtResource("1_b7j7x")
|
||||||
|
font_size = 28
|
||||||
|
|
||||||
|
[node name="PauseMenu" type="CenterContainer"]
|
||||||
|
process_mode = 2
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_right = -1520.0
|
||||||
|
offset_bottom = -880.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_mq0ks")
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
custom_minimum_size = Vector2(400, 200)
|
||||||
|
layout_mode = 2
|
||||||
|
color = Color(0.231373, 0.219608, 0.203922, 1)
|
||||||
|
|
||||||
|
[node name="VBox" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Paused"
|
||||||
|
label_settings = SubResource("LabelSettings_6mqtv")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="VSeparator" type="VSeparator" parent="VBox"]
|
||||||
|
visibility_layer = 0
|
||||||
|
custom_minimum_size = Vector2(0, 70)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="HBox" type="HBoxContainer" parent="VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="InputsButton" type="Button" parent="VBox/HBox"]
|
||||||
|
custom_minimum_size = Vector2(100, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Inputs"
|
||||||
|
|
||||||
|
[node name="ResumeButton" type="Button" parent="VBox/HBox"]
|
||||||
|
custom_minimum_size = Vector2(100, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Resume"
|
||||||
|
|
||||||
|
[node name="QuitButton" type="Button" parent="VBox/HBox"]
|
||||||
|
custom_minimum_size = Vector2(100, 35)
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Main Menu"
|
||||||
|
|
||||||
|
[node name="InputMenu" parent="." instance=ExtResource("2_ugxyj")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://ek36asqxxjep"]
|
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_w4vts"]
|
|
||||||
_data = [Vector2(0.233333, 0.571429), 0.0, 0.0, 0, 0, Vector2(0.56, 0.769231), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
|
||||||
point_count = 3
|
|
||||||
|
|
||||||
[sub_resource type="CurveTexture" id="CurveTexture_t768a"]
|
|
||||||
curve = SubResource("Curve_w4vts")
|
|
||||||
|
|
||||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_cmi2w"]
|
|
||||||
particle_flag_disable_z = true
|
|
||||||
emission_shape = 3
|
|
||||||
emission_box_extents = Vector3(5000, 5000, 1)
|
|
||||||
initial_velocity_min = 0.5
|
|
||||||
initial_velocity_max = 1.0
|
|
||||||
gravity = Vector3(0, 0, 0)
|
|
||||||
scale_min = 0.0
|
|
||||||
scale_max = 4.0
|
|
||||||
scale_curve = SubResource("CurveTexture_t768a")
|
|
||||||
|
|
||||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_145mr"]
|
|
||||||
particle_flag_disable_z = true
|
|
||||||
emission_shape = 3
|
|
||||||
emission_box_extents = Vector3(5000, 5000, 1)
|
|
||||||
gravity = Vector3(0, 0, 0)
|
|
||||||
|
|
||||||
[node name="Star Background" type="Node2D"]
|
|
||||||
position = Vector2(903, 558)
|
|
||||||
|
|
||||||
[node name="StarBack" type="GPUParticles2D" parent="."]
|
|
||||||
z_index = -10
|
|
||||||
emitting = false
|
|
||||||
amount = 1000
|
|
||||||
process_material = SubResource("ParticleProcessMaterial_cmi2w")
|
|
||||||
lifetime = 60.0
|
|
||||||
preprocess = 2.0
|
|
||||||
|
|
||||||
[node name="StarFront" type="GPUParticles2D" parent="."]
|
|
||||||
z_index = -10
|
|
||||||
amount = 10000
|
|
||||||
process_material = SubResource("ParticleProcessMaterial_145mr")
|
|
||||||
lifetime = 60.0
|
|
||||||
preprocess = 10.0
|
|
||||||
speed_scale = 0.2
|
|
||||||
|
|
@ -4,9 +4,16 @@ using System;
|
||||||
public partial class game : Node2D
|
public partial class game : Node2D
|
||||||
{
|
{
|
||||||
private Node _lasers;
|
private Node _lasers;
|
||||||
|
|
||||||
private player _player;
|
private player _player;
|
||||||
|
|
||||||
private Node _asteroids;
|
private Node _asteroids;
|
||||||
|
|
||||||
private wavecontroller _waveController;
|
private wavecontroller _waveController;
|
||||||
|
|
||||||
|
private CenterContainer _pauseMenu;
|
||||||
|
|
||||||
|
private Control _pauseControl;
|
||||||
|
|
||||||
private Node _friendlies;
|
private Node _friendlies;
|
||||||
|
|
||||||
|
|
@ -38,6 +45,8 @@ public partial class game : Node2D
|
||||||
_hud = GetNode<Control>("UI/HUD");
|
_hud = GetNode<Control>("UI/HUD");
|
||||||
_scoreLabel = GetNode<Label>("UI/HUD/Layout/Score");
|
_scoreLabel = GetNode<Label>("UI/HUD/Layout/Score");
|
||||||
_flightAssistLabel = GetNode<Label>("UI/HUD/Layout/FlightAssist");
|
_flightAssistLabel = GetNode<Label>("UI/HUD/Layout/FlightAssist");
|
||||||
|
_pauseMenu = GetNode<CenterContainer>("UI/PauseControl/PauseMenu");
|
||||||
|
_pauseControl = GetNode<Control>("UI/PauseControl");
|
||||||
|
|
||||||
//HealthLabel = GetNode<Label>("UI/HUD/Health");
|
//HealthLabel = GetNode<Label>("UI/HUD/Health");
|
||||||
_asteroids = GetNode<Node>("Asteroids");
|
_asteroids = GetNode<Node>("Asteroids");
|
||||||
|
|
@ -92,11 +101,11 @@ public partial class game : Node2D
|
||||||
|
|
||||||
if (_waveController.CurrWave % 2 == 0)
|
if (_waveController.CurrWave % 2 == 0)
|
||||||
{
|
{
|
||||||
_player.HealShip(100); // heal ship by 100 at the start of each round
|
_player.HealShip(100); // heal ship by 100 at the start of each 2nd round
|
||||||
UpdateHealthLabel(_player.Health);
|
UpdateHealthLabel(_player.Health);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("reset"))
|
if (Input.IsActionJustPressed("reset"))
|
||||||
|
|
@ -108,7 +117,7 @@ public partial class game : Node2D
|
||||||
{
|
{
|
||||||
UpdateFALabel();
|
UpdateFALabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
//AUTO SPAWN AFTER CLEAR
|
//AUTO SPAWN AFTER CLEAR
|
||||||
if (_asteroids.GetChildCount() == 0)
|
if (_asteroids.GetChildCount() == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
30
MB_FYP/script/pause_controller.cs
Normal file
30
MB_FYP/script/pause_controller.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class pause_controller : Control
|
||||||
|
{
|
||||||
|
private Control _pauseMenu;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_pauseMenu = GetNode<Control>("PauseMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
if (@event.IsActionPressed("pause"))
|
||||||
|
{
|
||||||
|
if (!GetTree().Paused)
|
||||||
|
{
|
||||||
|
GetTree().Paused = true;
|
||||||
|
_pauseMenu.Visible = true;;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetTree().Paused = false;
|
||||||
|
_pauseMenu.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
36
MB_FYP/script/pause_menu.cs
Normal file
36
MB_FYP/script/pause_menu.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class pause_menu : CenterContainer
|
||||||
|
{
|
||||||
|
private Button _resumeButton;
|
||||||
|
private Button _quitButton;
|
||||||
|
private Button _inputButton;
|
||||||
|
|
||||||
|
private input_menu _inputMenu;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_resumeButton = GetNode<Button>("VBox/HBox/ResumeButton");
|
||||||
|
_quitButton = GetNode<Button>("VBox/HBox/QuitButton");
|
||||||
|
_inputButton = GetNode<Button>("VBox/HBox/InputsButton");
|
||||||
|
_inputMenu = GetNode<input_menu>("InputMenu");
|
||||||
|
|
||||||
|
_resumeButton.Pressed += () =>
|
||||||
|
{
|
||||||
|
Visible = false;
|
||||||
|
GetTree().Paused = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
_inputButton.Pressed += () =>
|
||||||
|
{
|
||||||
|
_inputMenu.Visible = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
_quitButton.Pressed += () =>
|
||||||
|
{
|
||||||
|
GetTree().Paused = false;
|
||||||
|
GetTree().ChangeSceneToFile("res://scenes/main_menu.tscn");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue