Attempt to bring in other branch

This commit is contained in:
2024-09-18 16:51:27 -07:00
1389 changed files with 64824 additions and 2665 deletions

View File

@@ -28,8 +28,6 @@ namespace GameJamDungeon
[Node] public ISubViewport GameWindow { get; set; } = default!;
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
public void Initialize()
{
Instantiator = new Instantiator(GetTree());
@@ -38,17 +36,10 @@ namespace GameJamDungeon
AppLogic.Set(AppRepo);
Menu.NewGame += OnNewGame;
Menu.Quit += OnQuit;
AppRepo.ShowLoadingScreen += AppRepo_ShowLoadingScreen;
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
Input.MouseMode = Input.MouseModeEnum.Captured;
this.Provide();
}
private void AppRepo_ShowLoadingScreen()
{
AnimationPlayer.Play("wait_and_load");
}
public void OnReady()
{
AppBinding = AppLogic.Bind();
@@ -57,7 +48,6 @@ namespace GameJamDungeon
.Handle((in AppLogic.Output.ShowLoadingScreen _) =>
{
Menu.Hide();
AnimationPlayer.Play("load");
})
.Handle((in AppLogic.Output.SetupGameScene _) =>
{
@@ -76,12 +66,6 @@ namespace GameJamDungeon
AppLogic.Start();
}
private void AnimationPlayer_AnimationFinished(StringName animName)
{
Instantiator.SceneTree.Paused = false;
//AppLogic.Input(new AppLogic.Input.LoadGameFinished());
}
public void OnNewGame() => AppLogic.Input(new AppLogic.Input.NewGame());
public void OnQuit() => AppLogic.Input(new AppLogic.Input.QuitGame());

140
src/app/App.gdshader Normal file
View File

@@ -0,0 +1,140 @@
shader_type canvas_item;
// Handles the resolution changes, color depth, and dithering
group_uniforms resolution_and_colors;
uniform bool change_color_depth = false;
uniform int target_color_depth : hint_range(1, 8) = 5;
uniform bool dithering = false;
uniform bool scale_resolution = false;
uniform int target_resolution_scale = 3;
// Handles the LUTish recoloring
group_uniforms gradient_recoloring;
uniform bool enable_recolor = false;
uniform sampler2D to_gradient: hint_default_black;
int dithering_pattern(ivec2 fragcoord) {
const int pattern[] = {
-4, +0, -3, +1,
+2, -2, +3, -1,
-3, +1, -4, +0,
+3, -1, +2, -2
};
int x = fragcoord.x % 4;
int y = fragcoord.y % 4;
return pattern[y * 4 + x];
}
vec3 rgb2hsv(vec3 rgb) { //Converts RGB values to HSV
float r = rgb.r;
float g = rgb.g;
float b = rgb.b;
float cmax = max(r,max(g,b));
float cmin = min(r,min(g,b));
float delta = cmax - cmin;
float h = 0.f; //hue
if (delta > 0.f){
if (cmax == r){
h = (g-b)/delta;
h = mod(h,6.f);
} else if (cmax == g){
h = ((b - r) / delta) + 2.f;
} else {
h = ((r-g)/delta) + 4.f;
}
h = h * 60.f;
}
float s = 0.f; //saturation
if (cmax > 0.f){
s = delta / cmax;
}
return vec3(h,s,cmax); // Keep original alpha value
}
vec3 hsv2rgb(vec3 hsv) { //Converts HSV values to RGB
float h = hsv.r;
float s = hsv.g;
float v = hsv.b;
float c = v * s;
//X = C × (1 - |(H / 60°) mod 2 - 1|)
float x = h / 60.f;
x = mod(x,2.f);
x = abs(x - 1.f);
x = c * (1.f - x);
float m = v - c;
vec3 rgb = vec3(0.f,0.f,0.f);
if (h < 60.f) {
rgb = vec3(c,x,0.f);
} else if (h < 120.f){
rgb = vec3(x,c,0.f);
} else if (h < 180.f){
rgb = vec3(0.f,c,x);
} else if (h < 240.f){
rgb = vec3(0.f,x,c);
} else if (h < 300.f){
rgb = vec3(x,0.f,c);
} else if (h < 360.f){
rgb = vec3(c,0.f,x);
}
rgb[0] = rgb[0] + m;
rgb[1] = rgb[1] + m;
rgb[2] = rgb[2] + m;
return rgb;
}
void fragment() {
ivec2 uv;
vec3 color;
if(scale_resolution){
uv = ivec2(FRAGCOORD.xy / float(target_resolution_scale));
color = texelFetch(TEXTURE, uv * target_resolution_scale, 0).rgb;
} else {
uv = ivec2(FRAGCOORD.xy);
color = texelFetch(TEXTURE, uv, 0).rgb;
}
if(enable_recolor){
vec3 hsv = rgb2hsv(color);
float color_pos = (hsv.x / 360.0);
vec3 new_color = texture(to_gradient, vec2((color_pos), 0.5)).rgb;
vec3 new_hsv = rgb2hsv(new_color);
hsv.x = new_hsv.x;
vec3 final_rgb = hsv2rgb(hsv);
color.rgb = final_rgb;
}
// Convert from [0.0, 1.0] range to [0, 255] range
ivec3 c = ivec3(round(color * 255.0));
// Apply the dithering pattern
if (dithering) {
c += ivec3(dithering_pattern(uv));
}
vec3 final_color;
if(change_color_depth){
// Truncate from 8 bits to color_depth bits
c >>= (8 - target_color_depth);
final_color = vec3(c) / float(1 << target_color_depth);
} else {
final_color = vec3(c) / float(1 << 8);
}
// Convert back to [0.0, 1.0] range
COLOR.rgb = final_color;
}

View File

@@ -1,86 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://cagfc5ridmteu"]
[gd_scene load_steps=3 format=3 uid="uid://cagfc5ridmteu"]
[ext_resource type="Script" path="res://src/app/App.cs" id="1_rt73h"]
[ext_resource type="PackedScene" uid="uid://rfvnddfqufho" path="res://src/menu/Menu.tscn" id="2_kvwo1"]
[sub_resource type="Animation" id="Animation_mbxap"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("LoadScreen: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, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SubViewportContainer:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[sub_resource type="Animation" id="Animation_fa8xf"]
resource_name = "load"
length = 5.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("LoadScreen:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1.93333, 4.03333, 5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1), Color(0, 0, 0, 1), Color(0, 0, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SubViewportContainer:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 4.03333),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [false, true]
}
[sub_resource type="Animation" id="Animation_bvk81"]
resource_name = "wait_and_load"
length = 5.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("LoadScreen:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(1.03333, 1.93333, 4.03333, 5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1), Color(0, 0, 0, 1), Color(0, 0, 0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vkd35"]
_data = {
"RESET": SubResource("Animation_mbxap"),
"load": SubResource("Animation_fa8xf"),
"wait_and_load": SubResource("Animation_bvk81")
}
[node name="App" type="CanvasLayer"]
process_mode = 3
script = ExtResource("1_rt73h")
@@ -91,30 +13,15 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
[node name="GameWindow" type="SubViewport" parent="SubViewportContainer"]
unique_name_in_owner = true
transparent_bg = true
handle_input_locally = false
audio_listener_enable_2d = true
audio_listener_enable_3d = true
size = Vector2i(1920, 1080)
render_target_update_mode = 0
size = Vector2i(1280, 960)
render_target_update_mode = 4
[node name="Menu" parent="." instance=ExtResource("2_kvwo1")]
unique_name_in_owner = true
[node name="LoadScreen" type="ColorRect" parent="."]
modulate = Color(1, 1, 1, 0)
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.235294, 0.235294, 0.784314, 1)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
"": SubResource("AnimationLibrary_vkd35")
}

View File

@@ -1,25 +1,25 @@
@startuml AppLogic
state "AppLogic State" as GameJam2024Practice_AppLogic_State {
state "InGame" as GameJam2024Practice_AppLogic_State_InGame
state "MainMenu" as GameJam2024Practice_AppLogic_State_MainMenu
state "SplashScreen" as GameJam2024Practice_AppLogic_State_SplashScreen
state "LeavingMenu" as GameJam2024Practice_AppLogic_State_LeavingMenu
state "AppLogic State" as GameJamDungeon_AppLogic_State {
state "SetupGameScene" as GameJamDungeon_AppLogic_State_SetupGameScene
state "InGame" as GameJamDungeon_AppLogic_State_InGame
state "LoadingScreen" as GameJamDungeon_AppLogic_State_LoadingScreen
state "MainMenu" as GameJamDungeon_AppLogic_State_MainMenu
}
GameJam2024Practice_AppLogic_State_InGame --> GameJam2024Practice_AppLogic_State_MainMenu : GameOver
GameJam2024Practice_AppLogic_State_LeavingMenu --> GameJam2024Practice_AppLogic_State_InGame : FadeOutFinished
GameJam2024Practice_AppLogic_State_MainMenu --> GameJam2024Practice_AppLogic_State_LeavingMenu : NewGame
GameJam2024Practice_AppLogic_State_MainMenu --> GameJam2024Practice_AppLogic_State_MainMenu : QuitGame
GameJam2024Practice_AppLogic_State_SplashScreen --> GameJam2024Practice_AppLogic_State_MainMenu : FadeOutFinished
GameJamDungeon_AppLogic_State_InGame --> GameJamDungeon_AppLogic_State_MainMenu : GameOver
GameJamDungeon_AppLogic_State_LoadingScreen --> GameJamDungeon_AppLogic_State_InGame : LoadGameFinished
GameJamDungeon_AppLogic_State_MainMenu --> GameJamDungeon_AppLogic_State_LoadingScreen : NewGame
GameJamDungeon_AppLogic_State_MainMenu --> GameJamDungeon_AppLogic_State_MainMenu : QuitGame
GameJamDungeon_AppLogic_State_SetupGameScene --> GameJamDungeon_AppLogic_State_InGame : LoadGameFinished
GameJam2024Practice_AppLogic_State_InGame : OnEnter → ShowGame
GameJam2024Practice_AppLogic_State_InGame : OnExit → HideGame
GameJam2024Practice_AppLogic_State_InGame : OnGameOver → RemoveExistingGame
GameJam2024Practice_AppLogic_State_LeavingMenu : OnEnter → FadeToBlack
GameJam2024Practice_AppLogic_State_MainMenu : OnEnter → SetupGameScene, ShowMainMenu
GameJam2024Practice_AppLogic_State_MainMenu : OnQuitGame → ExitGame
GameJam2024Practice_AppLogic_State_SplashScreen : OnEnter → ShowSplashScreen
GameJam2024Practice_AppLogic_State_SplashScreen : OnSplashScreenSkipped() → HideSplashScreen
GameJamDungeon_AppLogic_State_InGame : OnEnter → ShowGame
GameJamDungeon_AppLogic_State_InGame : OnExit → HideGame
GameJamDungeon_AppLogic_State_InGame : OnGameOver → RemoveExistingGame
GameJamDungeon_AppLogic_State_LoadingScreen : OnEnter → ShowLoadingScreen
GameJamDungeon_AppLogic_State_MainMenu : OnEnter → ShowMainMenu
GameJamDungeon_AppLogic_State_MainMenu : OnNewGame → SetupGameScene
GameJamDungeon_AppLogic_State_MainMenu : OnQuitGame → ExitGame
GameJamDungeon_AppLogic_State_SetupGameScene : OnEnter → SetupGameScene, ShowGame
[*] --> GameJam2024Practice_AppLogic_State_SplashScreen
[*] --> GameJamDungeon_AppLogic_State_SetupGameScene
@enduml