Title screen background and music

This commit is contained in:
Marco 2025-02-19 11:06:31 +01:00
commit 5b2b11545a
12 changed files with 326 additions and 123 deletions

BIN
Music/Title.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

19
Music/Title.mp3.import Normal file
View file

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://di416g5wgx6j0"
path="res://.godot/imported/Title.mp3-5ef7234bc4e97639c388a0ca7fed0414.mp3str"
[deps]
source_file="res://Music/Title.mp3"
dest_files=["res://.godot/imported/Title.mp3-5ef7234bc4e97639c388a0ca7fed0414.mp3str"]
[params]
loop=true
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

View file

@ -0,0 +1,31 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dnsadvmunm76k"]
[ext_resource type="FontFile" uid="uid://coek1e2q257pq" path="res://fonts/at01.ttf" id="1_dp7be"]
[resource]
default_font = ExtResource("1_dp7be")
default_font_size = 16
Button/colors/font_color = Color(0, 0.717647, 0, 1)
Button/colors/font_disabled_color = Color(0, 0, 0, 1)
Button/colors/font_focus_color = Color(0, 0, 0, 1)
Button/colors/font_hover_color = Color(0, 0, 0, 1)
Button/colors/font_hover_pressed_color = Color(0, 0, 0, 1)
Button/colors/font_outline_color = Color(0, 0, 0, 1)
Button/colors/font_pressed_color = Color(0, 0, 0, 1)
Button/colors/icon_disabled_color = Color(0, 0, 0, 1)
Button/colors/icon_focus_color = Color(0, 0, 0, 1)
Button/colors/icon_hover_color = Color(0, 0, 0, 1)
Button/colors/icon_hover_pressed_color = Color(0, 0, 0, 1)
Button/colors/icon_normal_color = Color(0, 0, 0, 1)
Button/colors/icon_pressed_color = Color(0, 0, 0, 1)
Button/constants/align_to_largest_stylebox = 0
Button/constants/h_separation = 0
Button/constants/icon_max_width = 0
Button/constants/outline_size = 0
Button/font_sizes/font_size = 16
Button/fonts/font = ExtResource("1_dp7be")
Button/styles/disabled = null
Button/styles/focus = null
Button/styles/hover = null
Button/styles/normal = null
Button/styles/pressed = null

View file

@ -1,11 +1,32 @@
[gd_scene load_steps=5 format=3 uid="uid://5xajclchk3my"]
[gd_scene load_steps=12 format=3 uid="uid://5xajclchk3my"]
[ext_resource type="Script" path="res://Scripts/MainMenu.cs" id="1_702nk"]
[ext_resource type="PackedScene" uid="uid://bv451a8wgty4u" path="res://Scenes/test.tscn" id="2_6rjfu"]
[ext_resource type="Texture2D" uid="uid://xvadkvwajs0t" path="res://Sprites/UI/Crystal.png" id="2_j4e6a"]
[ext_resource type="Texture2D" uid="uid://dicat7qqa0a7o" path="res://Sprites/Portraits/CirnoTitle.png" id="2_mpelb"]
[ext_resource type="Texture2D" uid="uid://by38ufb51f6rx" path="res://Sprites/UI/TitleBackground.png" id="2_qdx0s"]
[ext_resource type="FontFile" uid="uid://ccm3u37q1hvux" path="res://fonts/Xolonium-Regular.ttf" id="3_bl0se"]
[ext_resource type="AudioStream" uid="uid://di416g5wgx6j0" path="res://Music/Title.mp3" id="4_i6ku4"]
[ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="4_nk7wn"]
[sub_resource type="Theme" id="Theme_c7h4d"]
[sub_resource type="LabelSettings" id="LabelSettings_fb256"]
line_spacing = 0.0
font = ExtResource("3_bl0se")
font_size = 34
outline_size = 8
outline_color = Color(0, 0, 0, 1)
shadow_size = 9
shadow_offset = Vector2(16, 16)
[sub_resource type="LabelSettings" id="LabelSettings_htmja"]
line_spacing = 2.0
font = ExtResource("3_bl0se")
font_size = 12
outline_size = 4
outline_color = Color(0, 0, 0, 1)
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
@ -16,47 +37,103 @@ offset_bottom = -2.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_702nk")
GameScene = "res://Scenes/game.tscn"
GameScene = ExtResource("2_6rjfu")
MainMenuScene = "res://Scenes/MainMenu.tscn"
[node name="TextureRect2" type="TextureRect" parent="."]
layout_mode = 0
offset_right = 320.0
offset_bottom = 160.0
texture = ExtResource("2_qdx0s")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 0
offset_left = 79.0
offset_top = -14.0
offset_right = 241.0
offset_bottom = 148.0
texture = ExtResource("2_mpelb")
offset_left = 113.0
offset_top = 16.0
offset_right = 161.0
offset_bottom = 56.0
texture = ExtResource("2_j4e6a")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
offset_right = 337.0
offset_bottom = 158.0
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 16.0
offset_right = -13.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
[node name="GridContainer" type="GridContainer" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
columns = 3
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
[node name="GameButtons" type="VBoxContainer" parent="MarginContainer/GridContainer"]
layout_mode = 2
size_flags_vertical = 6
[node name="StartButton" type="Button" parent="MarginContainer/GridContainer/GameButtons"]
layout_mode = 2
theme = ExtResource("4_nk7wn")
text = "Start"
[node name="DebugButton" type="Button" parent="MarginContainer/GridContainer/GameButtons"]
layout_mode = 2
theme = ExtResource("4_nk7wn")
text = "Debug"
[node name="ExitButton" type="Button" parent="MarginContainer/GridContainer/GameButtons"]
layout_mode = 2
theme = ExtResource("4_nk7wn")
text = "Exit
"
[node name="Title" type="HBoxContainer" parent="MarginContainer/GridContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/GridContainer/Title"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 0
theme_override_constants/separation = -9
[node name="Label" type="Label" parent="MarginContainer/GridContainer/Title/VBoxContainer"]
layout_mode = 2
theme = SubResource("Theme_c7h4d")
theme_override_fonts/font = ExtResource("3_bl0se")
theme_override_font_sizes/font_size = 28
text = "CIRNO: No Reason"
text = "CIRNO"
label_settings = SubResource("LabelSettings_fb256")
horizontal_alignment = 1
[node name="StartButton" type="Button" parent="MarginContainer/VBoxContainer"]
[node name="Label2" type="Label" parent="MarginContainer/GridContainer/Title/VBoxContainer"]
layout_mode = 2
text = "Start"
size_flags_horizontal = 4
size_flags_vertical = 0
text = "NO REASON"
label_settings = SubResource("LabelSettings_htmja")
horizontal_alignment = 1
[node name="DebugButton" type="Button" parent="MarginContainer/VBoxContainer"]
[node name="TextureRect" type="TextureRect" parent="MarginContainer/GridContainer/Title/VBoxContainer"]
layout_mode = 2
text = "Debug"
size_flags_horizontal = 4
texture = ExtResource("2_mpelb")
stretch_mode = 2
[node name="ExitButton" type="Button" parent="MarginContainer/VBoxContainer"]
[node name="Options" type="VBoxContainer" parent="MarginContainer/GridContainer"]
layout_mode = 2
text = "Exit
"
size_flags_vertical = 6
[connection signal="pressed" from="MarginContainer/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/DebugButton" to="." method="_on_debug_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"]
[node name="Button" type="Button" parent="MarginContainer/GridContainer/Options"]
layout_mode = 2
theme = ExtResource("4_nk7wn")
text = "Options"
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("4_i6ku4")
autoplay = true
[connection signal="pressed" from="MarginContainer/GridContainer/GameButtons/StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="MarginContainer/GridContainer/GameButtons/DebugButton" to="." method="_on_debug_button_pressed"]
[connection signal="pressed" from="MarginContainer/GridContainer/GameButtons/ExitButton" to="." method="_on_exit_button_pressed"]

View file

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using Cirno.Scripts.Components.Actors;
public partial class EnemyNavigationMovement : MovementHandler
public partial class EnemyNavigationMovement : MovementHandler
{
public override Vector2 FacingDirection
{
@ -19,21 +19,19 @@ public partial class EnemyNavigationMovement : MovementHandler
set => _parent.MovementDirection = value;
}
[Export]
private bool _navigationEnabled = false;
[Export] private bool _navigationEnabled = false;
[Export] public float AlarmReactRange = 200f;
[Export] public float PlayerDisengageRange = 500f;
public bool NavigationEnabled
{
get => _actorAi is not null && _actorAi.Ai is AiState.Enabled && _navigationEnabled && _navigationAgent != null;
set => _navigationEnabled = value;
}
{
get => _actorAi is not null && _actorAi.Ai is AiState.Enabled && _navigationEnabled && _navigationAgent != null;
set => _navigationEnabled = value;
}
[Export]
private PlayerDetection _playerDetection;
[Export] private PlayerDetection _playerDetection;
private ActorAi _actorAi;
private NavigationAgent2D _navigationAgent;
@ -43,122 +41,117 @@ public partial class EnemyNavigationMovement : MovementHandler
private bool IsPlayerInRange => _playerDetection is { IsPlayerInRange: true };
private bool IsPlayerInSight => _playerDetection is not null && _playerDetection.IsPlayerInSight(_parent.CollisionMask);
private bool IsPlayerInSight =>
_playerDetection is not null && _playerDetection.IsPlayerInSight(_parent.CollisionMask);
public override void Init(Actor parent)
public override void Init(Actor parent)
{
base.Init(parent);
MovementDirection = Vector2.Zero;
FacingDirection = Vector2.Down;
_actorAi = parent.GetNode<ActorAi>("ActorAi");
_navigationAgent = _parent.GetNodeOrNull<NavigationAgent2D>("NavigationAgent2D");
_alarmManager = this.GetAlarmManager();
_actorAi = parent.GetNode<ActorAi>("ActorAi");
_navigationAgent = _parent.GetNodeOrNull<NavigationAgent2D>("NavigationAgent2D");
_alarmManager = this.GetAlarmManager();
if (_alarmManager != null)
{
_alarmManager.AlarmEnabled += AlarmManagerOnAlarmEnabled;
}
{
_alarmManager.AlarmEnabled += AlarmManagerOnAlarmEnabled;
}
}
private void AlarmManagerOnAlarmEnabled(Vector2 location)
{
if (NavigationEnabled && location.DistanceTo(this.GlobalPosition) <= AlarmReactRange)
{
GD.Print($"Enemy {Name} alerted");
_actorAi.State = EnemyState.Alert;
_lastPlayerPosition = location;
}
}
{
if (NavigationEnabled && location.DistanceTo(this.GlobalPosition) <= AlarmReactRange)
{
GD.Print($"Enemy {Name} alerted");
_actorAi.State = EnemyState.Alert;
_lastPlayerPosition = location;
}
}
public override void Move(double delta)
{
if (_actorAi.Ai is not AiState.Enabled)
if (_actorAi.Ai is not AiState.Enabled)
return;
switch (_actorAi.State)
switch (_actorAi.State)
{
case EnemyState.Idle:
if (_playerDetection != null && _playerDetection.IsPlayerInSight(_parent.CollisionMask))
{
_actorAi.State = EnemyState.Alert;
{
_actorAi.State = EnemyState.Alert;
GD.Print("Switching to alert");
}
break;
}
break;
case EnemyState.Alert:
// Update last known player position if it's in range
if (IsPlayerInRange)
{
_lastPlayerPosition = _playerDetection.CachedPlayer.GlobalPosition;
}
if (NavigationEnabled)
{
if (_lastPlayerPosition.HasValue)
{
_navigationAgent.SetTargetPosition(_lastPlayerPosition.Value);
}
var currentAgentPosition = _parent.GlobalPosition;
var nextPathPosition = _navigationAgent.GetNextPathPosition();
var newVelocity = currentAgentPosition.DirectionTo(nextPathPosition) * _parent.MovementSpeed;
// Navigation is over, can do other things like shooting
if (_navigationAgent.IsNavigationFinished())
{
// Shoot player
if (IsPlayerInSight)
{
//Shoot();
}
// TODO: If player totally left the max range it should stop shooting and go back to idle
return;
}
if (_navigationAgent.AvoidanceEnabled)
{
_navigationAgent.SetVelocity(newVelocity);
}
else
{
_on_navigation_agent_2d_velocity_computed(newVelocity);
}
// Update last known player position if it's in range
if (IsPlayerInRange)
{
_lastPlayerPosition = _playerDetection.CachedPlayer.GlobalPosition;
}
_parent.MoveAndSlide();
}
else
{
if (IsPlayerInSight)
{
//Shoot();
}
}
break;
if (NavigationEnabled)
{
if (_lastPlayerPosition.HasValue)
{
_navigationAgent.SetTargetPosition(_lastPlayerPosition.Value);
}
var currentAgentPosition = _parent.GlobalPosition;
var nextPathPosition = _navigationAgent.GetNextPathPosition();
var newVelocity = currentAgentPosition.DirectionTo(nextPathPosition) * _parent.MovementSpeed;
// Navigation is over, can do other things like shooting
if (_navigationAgent.IsNavigationFinished())
{
// Shoot player
if (IsPlayerInSight)
{
//Shoot();
}
// TODO: If player totally left the max range it should stop shooting and go back to idle
return;
}
if (_navigationAgent.AvoidanceEnabled)
{
_navigationAgent.SetVelocity(newVelocity);
}
else
{
_on_navigation_agent_2d_velocity_computed(newVelocity);
}
_parent.MoveAndSlide();
}
else
{
if (IsPlayerInSight)
{
//Shoot();
}
}
break;
}
}
public void _on_navigation_agent_2d_velocity_computed(Vector2 safeVelocity)
{
_parent.Velocity = safeVelocity;
if (_parent.Velocity.Length() > 0) {
{
_parent.Velocity = safeVelocity;
if (_parent.Velocity.Length() > 0)
{
_parent.FacingDirection = _parent.Velocity.Normalized();
}
}
}
}

View file

@ -5,7 +5,7 @@ public partial class MainMenu : Control
{
[Export]
public string GameScene { get; set; }
public PackedScene GameScene { get; set; }
[Export]
public string MainMenuScene { get; set; }
@ -23,7 +23,7 @@ public partial class MainMenu : Control
private void _on_start_button_pressed()
{
if (GameScene != null) {
GetTree().ChangeSceneToFile(GameScene);
GetTree().ChangeSceneToFile(GameScene.ResourcePath);
}
}

BIN
Sprites/UI/Crystal.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/UI/Crystal.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://xvadkvwajs0t"
path="res://.godot/imported/Crystal.png-7bfffa0ee3dabc3d46bd38d70a1b2d57.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/UI/Crystal.png"
dest_files=["res://.godot/imported/Crystal.png-7bfffa0ee3dabc3d46bd38d70a1b2d57.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
Sprites/UI/TitleBackground.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/UI/TitleBackground.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://by38ufb51f6rx"
path="res://.godot/imported/TitleBackground.png-01de501a00dbcf469f33b0ad142141d4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/UI/TitleBackground.png"
dest_files=["res://.godot/imported/TitleBackground.png-01de501a00dbcf469f33b0ad142141d4.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