refactor du code et ajouts des quotas, avec des récompense entre chaque quota #68

This commit is contained in:
2025-09-14 19:35:43 +02:00
parent 85cd832864
commit 43bdbc3581
44 changed files with 918 additions and 339 deletions

View File

@@ -1,18 +1,86 @@
[gd_scene load_steps=9 format=3 uid="uid://csiacsndm62ll"]
[gd_scene load_steps=14 format=3 uid="uid://csiacsndm62ll"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_51ks3"]
[ext_resource type="Script" uid="uid://crt2d4m5ba25i" path="res://gui/game/pause/scripts/pause.gd" id="1_he4ox"]
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="2_8d1kg"]
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="2_apjlw"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="3_0pdto"]
[ext_resource type="Texture2D" uid="uid://vmsn54d1ptih" path="res://common/icons/player-play.svg" id="5_apjlw"]
[ext_resource type="Texture2D" uid="uid://bewr0t1wi8pff" path="res://common/icons/rotate.svg" id="6_58dya"]
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="7_yj6f1"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_58dya"]
shader = ExtResource("2_apjlw")
shader_parameter/strength = 3.3
shader_parameter/mix_percentage = 0.3
[sub_resource type="LabelSettings" id="LabelSettings_apjlw"]
font = ExtResource("2_8d1kg")
font_size = 50
[sub_resource type="Animation" id="Animation_58dya"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_apjlw"]
resource_name = "pause"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.0333333),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [false, true]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.0333333, 0.3),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_yj6f1"]
_data = {
&"RESET": SubResource("Animation_58dya"),
&"pause": SubResource("Animation_apjlw")
}
[node name="Pause" type="Control"]
visible = false
z_index = 10
layout_mode = 3
anchors_preset = 15
@@ -23,6 +91,7 @@ grow_vertical = 2
script = ExtResource("1_he4ox")
[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource("ShaderMaterial_58dya")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -101,6 +170,12 @@ layout_mode = 2
text = "Quit"
icon = ExtResource("7_yj6f1")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_yj6f1")
}
[connection signal="pressed" from="Tutorial/VBoxContainer/HBoxContainer/Resume" to="." method="_on_resume_pressed"]
[connection signal="pressed" from="Tutorial/VBoxContainer/HBoxContainer/Restart" to="." method="_on_restart_pressed"]
[connection signal="pressed" from="Tutorial/VBoxContainer/HBoxContainer/Quit" to="." method="_on_quit_pressed"]

View File

@@ -0,0 +1,44 @@
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture,repeat_disable, filter_nearest;
/**
* How blurry the result should be.
* Limited to 20 because of performance, if you want feel free to break it.
*/
uniform float strength : hint_range(0.1, 20.0) = 3.3;
/**
* How dark the blur will be
*/
uniform float mix_percentage: hint_range(0.0, 1.0) = 0.3;
float gaussianDistribution(float x, float STD){ // STD stands for standard deviation
return exp(-(x*x)/(2.*STD*STD))/(sqrt(2.*PI)*STD);
}
vec3 gaussianblur(sampler2D sampler, vec2 pos, vec2 pixel_size, float sigmaUsed, int radius){
vec3 blurredPixel = vec3(0.0);
float total_weight = 0.0;
// Loop over the radius (tecnically its a square)
for(int i = -radius ; i <= radius; i++){
for(int j = -radius; j <= radius; j++){
// Calculate the offset from the current pixel
vec2 offset = vec2(float(i), float(j))*pixel_size;
vec2 changedPos = pos + offset;
// Calculate the weight based on the Gaussian distribution multiplying both dimentions (how far are X and Y form the center (pos))
float weight = gaussianDistribution(float(i), sigmaUsed)*gaussianDistribution(float(j), sigmaUsed);
// Add the weighted color value to the blurred pixel
blurredPixel += texture(SCREEN_TEXTURE, changedPos).rgb * weight;
total_weight += weight;
}
}
// Normalize the blurred pixel color by the total weight
blurredPixel/=total_weight;
return blurredPixel;
}
void fragment() {
vec3 PixelBlurred = gaussianblur(SCREEN_TEXTURE, SCREEN_UV, SCREEN_PIXEL_SIZE, strength, int(round(3.0 * strength)));
vec3 color = mix(PixelBlurred, vec3(0.0), mix_percentage);
// The radius is 3*strength because it is the point where the Gaussian weight is near zero.
COLOR = vec4(color, 1.);
}

View File

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

View File

@@ -1,13 +1,16 @@
extends Control
var pause = false :
set(v):
pause = v
visible = pause
get_tree().paused = pause
var pause = false : set = set_pause
func set_pause(p):
if p != pause:
if p:
%AnimationPlayer.play("pause")
else:
%AnimationPlayer.play_backwards("pause")
pause = p
get_tree().paused = pause
func _ready():
pause = true
func _input(_event):
if Input.is_action_just_pressed("pause"):
@@ -17,6 +20,8 @@ func _on_resume_pressed():
pause = false
func _on_restart_pressed():
GameInfo.game_data.current_planet_data = null
pause = false
get_tree().reload_current_scene()
func _on_quit_pressed():