From af15a6c06c418c8ca59c3eecfee0410db9d64ffc Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Thu, 13 Mar 2025 15:39:13 +0100 Subject: [PATCH 01/12] premier commit --- examples/Projet/projet.cpp | 210 ++++++++++++++++++++++++++ examples/Projet/projet_liam_frit.tscn | 19 +++ 2 files changed, 229 insertions(+) create mode 100644 examples/Projet/projet.cpp create mode 100644 examples/Projet/projet_liam_frit.tscn diff --git a/examples/Projet/projet.cpp b/examples/Projet/projet.cpp new file mode 100644 index 0000000..830bafb --- /dev/null +++ b/examples/Projet/projet.cpp @@ -0,0 +1,210 @@ +#define BLACK 0xFF000000 +#define RED 0xFF0000FF +#define GREEN 0xFF00FF00 +#define BLUE 0xFFFF0000 + +#define RAYON 100 + +void circle(uint cx, uint cy, uint rayon, int epaisseur) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (rayon - epaisseur) * (rayon - epaisseur) && + (x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { + data_0[p] = RED; + } + + + + +} + +void TEST(uint cx, uint cy, uint rayon, int epaisseur) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (rayon - epaisseur) * (rayon - epaisseur) && + (x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { + data_0[p] = RED; + } + + + + +} + +void circleFull(uint cx, uint cy, uint rayon) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { + data_0[p] = BLUE; + } +} + +// bool checkCollision(uint cx, uint cy) { +// for (int i = -1; i <= 1; i++) { +// for (int j = -1; j <= 1; j++) { +// uint nx = cx + i; +// uint ny = cy + j; +// uint p = nx + ny * WSX; + +// if (data_0[p] == RED) { +// return true; +// } +// } +// } +// return false; +// } + +// void main() { +// uint x = gl_GlobalInvocationID.x; +// uint y = gl_GlobalInvocationID.y; +// uint p = x + y * WSX; + +// circle(540, 540, 200, 10); + +// bool collision = checkCollision(540, step+540); + +// if(!collision) { +// circleFull(540, step+540, 30); +// } else { +// TEST(10, 10, 200, 10); +// //circleFull(540, -step, 30); +// } +// } + + +bool checkCollision(uint cx, uint cy, uint radius, String couleur) { + for (int angle = 0; angle < 360; angle += 15) { + float radians = float(angle) * 3.14159 / 180.0; + uint checkX = cx + uint(float(radius) * cos(radians)); + uint checkY = cy + uint(float(radius) * sin(radians)); + + if (checkX < WSX && checkY < WSY) { + uint checkP = checkX + checkY * WSX; + + if (data_0[checkP] == couleur) { + return true; + } + } + } + return false; +} + +void main() { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + circle(540, 540, 200, 10); + + uint movingCircleRadius = 30; + uint centerX = 540; + uint centerY = step + 540; + + bool collision = checkCollision(centerX, centerY, movingCircleRadius); + + if (!collision) { + circleFull(centerX, centerY, movingCircleRadius); + } else { + if (!collision) { + circleFull(centerX, (step*-1)+540, movingCircleRadius); + } + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// if (data_0[p] != 0xFFFFFFFF && data_0[p] != 0x00000000) { + // if (data_0[p + WSX] == 0x00000000) { + // data_0[p + WSX] = data_0[p]; + // data_0[p] = 0x00000000; + // } + // } + //circle(mousex,mousey,300); + // circle(540,540,200,10); + // if(data_0[p] != RED){ + // circleFull(540,540,step); + + // }else{ + // circleFull(540,540, 199); + // } + + // circle(540,540,200,10); + // circleFull(540,540,100); + + // if (x == mousex && y == mousey) { + // data_0[p] = BLUE; + // } + + // // si le pixel est non vide et non sol + // if (data_0[p] != 0xFFFFFFFF && data_0[p] != 0x00000000) { + // // il tombe + // if (data_0[p + WSX] == 0x00000000) { + // data_0[p + WSX] = data_0[p]; + // data_0[p] = 0x00000000; + // } + // } + + + + // uint x = gl_GlobalInvocationID.x; + // uint y = gl_GlobalInvocationID.y; + // uint p = x + y * WSX; + + + + // data_0[p] = 0xFFFFFFFF; + + // if((x < 32 && x > 10) && y<32&&y>10)data_0[p] = RED; + + + + // if (!checkCollision(540, 540, step)) { + // circleFull(540, 540, step); + // } else { + + // circleFull(540, 540, -step); // Fixe le dernier cercle avant la collision + // } + + // // Cercle rouge fixe au centre + // circle(540, 540, 200, 10); \ No newline at end of file diff --git a/examples/Projet/projet_liam_frit.tscn b/examples/Projet/projet_liam_frit.tscn new file mode 100644 index 0000000..aca52b0 --- /dev/null +++ b/examples/Projet/projet_liam_frit.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=3 uid="uid://bonxt31s15o3g"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_8kd26"] +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_5doh8"] + +[node name="ProjetLiamFrit" type="Node2D"] + +[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_8kd26") +WSX = 1080 +WSY = 1080 +glsl_file = "res://examples/Projet/projet.cpp" +GLSL_code = "" +data = [NodePath("../Icon")] + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(435.875, 235) +scale = Vector2(3.92383, 3.43359) +texture = ExtResource("2_5doh8") From 2b0f6d8567ebec3ae41293dfafd86d665499e400 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Mon, 17 Mar 2025 08:21:16 +0100 Subject: [PATCH 02/12] Deuxieme Commit Tentative de changement de version --- examples/Projet/projet_liam_frit.tscn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Projet/projet_liam_frit.tscn b/examples/Projet/projet_liam_frit.tscn index aca52b0..5f76fbb 100644 --- a/examples/Projet/projet_liam_frit.tscn +++ b/examples/Projet/projet_liam_frit.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://bonxt31s15o3g"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_8kd26"] +[ext_resource type="Script" uid="uid://c8esqdv0y26yp" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_8kd26"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_5doh8"] [node name="ProjetLiamFrit" type="Node2D"] From 1c76adaf06c45b8ba512857be79e318b2d89e992 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Mon, 17 Mar 2025 08:35:38 +0100 Subject: [PATCH 03/12] Update Projet.cpp Affichage qui fonctionne --- examples/Projet/projet.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/examples/Projet/projet.cpp b/examples/Projet/projet.cpp index 830bafb..1d37906 100644 --- a/examples/Projet/projet.cpp +++ b/examples/Projet/projet.cpp @@ -20,20 +20,20 @@ void circle(uint cx, uint cy, uint rayon, int epaisseur) { } -void TEST(uint cx, uint cy, uint rayon, int epaisseur) { - uint x = gl_GlobalInvocationID.x; - uint y = gl_GlobalInvocationID.y; - uint p = x + y * WSX; +// void TEST(uint cx, uint cy, uint rayon, int epaisseur) { +// uint x = gl_GlobalInvocationID.x; +// uint y = gl_GlobalInvocationID.y; +// uint p = x + y * WSX; - if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (rayon - epaisseur) * (rayon - epaisseur) && - (x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { - data_0[p] = RED; - } +// if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (rayon - epaisseur) * (rayon - epaisseur) && +// (x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { +// data_0[p] = RED; +// } -} +// } void circleFull(uint cx, uint cy, uint rayon) { uint x = gl_GlobalInvocationID.x; @@ -79,7 +79,7 @@ void circleFull(uint cx, uint cy, uint rayon) { // } -bool checkCollision(uint cx, uint cy, uint radius, String couleur) { +bool checkCollision(uint cx, uint cy, uint radius, uint couleur) { for (int angle = 0; angle < 360; angle += 15) { float radians = float(angle) * 3.14159 / 180.0; uint checkX = cx + uint(float(radius) * cos(radians)); @@ -107,14 +107,12 @@ void main() { uint centerX = 540; uint centerY = step + 540; - bool collision = checkCollision(centerX, centerY, movingCircleRadius); + bool collision = checkCollision(centerX, centerY, movingCircleRadius, RED); if (!collision) { circleFull(centerX, centerY, movingCircleRadius); } else { - if (!collision) { circleFull(centerX, (step*-1)+540, movingCircleRadius); - } } } From baee988d5a569404f23ae94ed12bc343d6567d8b Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Mon, 17 Mar 2025 09:09:31 +0100 Subject: [PATCH 04/12] Update projet.cpp Rota Rotation Visible mais pas de rebond --- examples/Projet/projet.cpp | 175 +++++-------------------------------- 1 file changed, 23 insertions(+), 152 deletions(-) diff --git a/examples/Projet/projet.cpp b/examples/Projet/projet.cpp index 1d37906..724f5a6 100644 --- a/examples/Projet/projet.cpp +++ b/examples/Projet/projet.cpp @@ -1,9 +1,7 @@ #define BLACK 0xFF000000 -#define RED 0xFF0000FF +#define RED 0xFFFF0000 #define GREEN 0xFF00FF00 -#define BLUE 0xFFFF0000 - -#define RAYON 100 +#define BLUE 0xFF0000FF void circle(uint cx, uint cy, uint rayon, int epaisseur) { uint x = gl_GlobalInvocationID.x; @@ -14,70 +12,27 @@ void circle(uint cx, uint cy, uint rayon, int epaisseur) { (x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { data_0[p] = RED; } - - - - } -// void TEST(uint cx, uint cy, uint rayon, int epaisseur) { -// uint x = gl_GlobalInvocationID.x; -// uint y = gl_GlobalInvocationID.y; -// uint p = x + y * WSX; - -// if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (rayon - epaisseur) * (rayon - epaisseur) && -// (x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { -// data_0[p] = RED; -// } - - - - -// } - -void circleFull(uint cx, uint cy, uint rayon) { +void circleFull1(uint cx, uint cy, uint rayon) { uint x = gl_GlobalInvocationID.x; uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; - if ((x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { data_0[p] = BLUE; } } -// bool checkCollision(uint cx, uint cy) { -// for (int i = -1; i <= 1; i++) { -// for (int j = -1; j <= 1; j++) { -// uint nx = cx + i; -// uint ny = cy + j; -// uint p = nx + ny * WSX; - -// if (data_0[p] == RED) { -// return true; -// } -// } -// } -// return false; -// } - -// void main() { -// uint x = gl_GlobalInvocationID.x; -// uint y = gl_GlobalInvocationID.y; -// uint p = x + y * WSX; - -// circle(540, 540, 200, 10); - -// bool collision = checkCollision(540, step+540); - -// if(!collision) { -// circleFull(540, step+540, 30); -// } else { -// TEST(10, 10, 200, 10); -// //circleFull(540, -step, 30); -// } -// } +void circleFull2(uint cx, uint cy, uint rayon) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { + data_0[p] = RED; + } +} bool checkCollision(uint cx, uint cy, uint radius, uint couleur) { for (int angle = 0; angle < 360; angle += 15) { @@ -101,108 +56,24 @@ void main() { uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; + // Dessiner le cercle fixe circle(540, 540, 200, 10); uint movingCircleRadius = 30; - uint centerX = 540; - uint centerY = step + 540; + // Mouvement en oscillation + float amplitudeX = 100.0; // Amplitude du mouvement en X + float amplitudeY = 150.0; // Amplitude du mouvement en Y + float frequency = 0.01; // Fréquence de l'oscillation + + uint centerX = uint(540.0 + amplitudeX * cos(float(step) * frequency)); + uint centerY = uint(540.0 + amplitudeY * sin(float(step) * frequency)); + bool collision = checkCollision(centerX, centerY, movingCircleRadius, RED); - + if (!collision) { - circleFull(centerX, centerY, movingCircleRadius); + circleFull1(centerX, centerY, movingCircleRadius); } else { - circleFull(centerX, (step*-1)+540, movingCircleRadius); + circleFull2(centerX, centerY, movingCircleRadius); } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// if (data_0[p] != 0xFFFFFFFF && data_0[p] != 0x00000000) { - // if (data_0[p + WSX] == 0x00000000) { - // data_0[p + WSX] = data_0[p]; - // data_0[p] = 0x00000000; - // } - // } - //circle(mousex,mousey,300); - // circle(540,540,200,10); - // if(data_0[p] != RED){ - // circleFull(540,540,step); - - // }else{ - // circleFull(540,540, 199); - // } - - // circle(540,540,200,10); - // circleFull(540,540,100); - - // if (x == mousex && y == mousey) { - // data_0[p] = BLUE; - // } - - // // si le pixel est non vide et non sol - // if (data_0[p] != 0xFFFFFFFF && data_0[p] != 0x00000000) { - // // il tombe - // if (data_0[p + WSX] == 0x00000000) { - // data_0[p + WSX] = data_0[p]; - // data_0[p] = 0x00000000; - // } - // } - - - - // uint x = gl_GlobalInvocationID.x; - // uint y = gl_GlobalInvocationID.y; - // uint p = x + y * WSX; - - - - // data_0[p] = 0xFFFFFFFF; - - // if((x < 32 && x > 10) && y<32&&y>10)data_0[p] = RED; - - - - // if (!checkCollision(540, 540, step)) { - // circleFull(540, 540, step); - // } else { - - // circleFull(540, 540, -step); // Fixe le dernier cercle avant la collision - // } - - // // Cercle rouge fixe au centre - // circle(540, 540, 200, 10); \ No newline at end of file From 9c45cd8ff11aa06e3f44da7ee491b012cfcc1e65 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Mon, 17 Mar 2025 10:03:06 +0100 Subject: [PATCH 05/12] Update projet.cpp Quelques petites modifications --- examples/Projet/projet.cpp | 73 +++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/examples/Projet/projet.cpp b/examples/Projet/projet.cpp index 724f5a6..d292998 100644 --- a/examples/Projet/projet.cpp +++ b/examples/Projet/projet.cpp @@ -1,7 +1,8 @@ #define BLACK 0xFF000000 -#define RED 0xFFFF0000 +#define RED 0xFF0000FF #define GREEN 0xFF00FF00 -#define BLUE 0xFF0000FF +#define BLUE 0xFFFF0000 +#define COLLISION_MARKER 0xFFFF00FF void circle(uint cx, uint cy, uint rayon, int epaisseur) { uint x = gl_GlobalInvocationID.x; @@ -14,23 +15,18 @@ void circle(uint cx, uint cy, uint rayon, int epaisseur) { } } -void circleFull1(uint cx, uint cy, uint rayon) { +void circleFull(uint cx, uint cy, uint rayon, uint indice) { uint x = gl_GlobalInvocationID.x; uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; - - if ((x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { - data_0[p] = BLUE; - } -} - -void circleFull2(uint cx, uint cy, uint rayon) { - uint x = gl_GlobalInvocationID.x; - uint y = gl_GlobalInvocationID.y; - uint p = x + y * WSX; - - if ((x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { - data_0[p] = RED; + if(indice == 1){ + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { + data_0[p] = BLUE; + } + } else if(indice == 2){ + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { + data_0[p] = RED; + } } } @@ -56,24 +52,37 @@ void main() { uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; - // Dessiner le cercle fixe - circle(540, 540, 200, 10); + bool hasCollided = (data_0[0] == COLLISION_MARKER); + + if (p != 0) { + data_0[p] = BLACK; + } + + circle(540, 540, 200, 20); uint movingCircleRadius = 30; + uint centerX = 540; - // Mouvement en oscillation - float amplitudeX = 100.0; // Amplitude du mouvement en X - float amplitudeY = 150.0; // Amplitude du mouvement en Y - float frequency = 0.01; // Fréquence de l'oscillation - - uint centerX = uint(540.0 + amplitudeX * cos(float(step) * frequency)); - uint centerY = uint(540.0 + amplitudeY * sin(float(step) * frequency)); - - bool collision = checkCollision(centerX, centerY, movingCircleRadius, RED); - - if (!collision) { - circleFull1(centerX, centerY, movingCircleRadius); + float amplitude = 160.0; + float frequency = 0.01; + uint normalY = uint(540.0 + amplitude * sin(float(step) * frequency)); + uint invertedY = uint(540.0 - amplitude * sin(float(step) * frequency)); + + if (!hasCollided) { + bool collision = checkCollision(centerX, normalY, movingCircleRadius, RED); + if (collision) { + data_0[0] = COLLISION_MARKER; + hasCollided = true; + } + } + + uint newcolor; + + if (!hasCollided) { + newcolor = 1; // BLUE + circleFull(centerX, normalY, movingCircleRadius, newcolor); } else { - circleFull2(centerX, centerY, movingCircleRadius); + newcolor = 2; // RED + circleFull(centerX, invertedY, movingCircleRadius, newcolor); } -} +} \ No newline at end of file From d7071be36ac1db6ec5f105996e903384109f7bb1 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Mon, 17 Mar 2025 23:20:16 +0100 Subject: [PATCH 06/12] =?UTF-8?q?Ajout=20de=20deux=20test=20diff=C3=A9rent?= =?UTF-8?q?=20pour=20fond=20mouvant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deux nouveau fond possible pour faire du mouvement et jouer avec les carrés --- examples/Projet/projet2.cpp | 100 ++++++++++++++++ examples/Projet/projet_2_test.cpp | 187 ++++++++++++++++++++++++++++++ 2 files changed, 287 insertions(+) create mode 100644 examples/Projet/projet2.cpp create mode 100644 examples/Projet/projet_2_test.cpp diff --git a/examples/Projet/projet2.cpp b/examples/Projet/projet2.cpp new file mode 100644 index 0000000..2ba1910 --- /dev/null +++ b/examples/Projet/projet2.cpp @@ -0,0 +1,100 @@ +#define BLACK 0xFF000000 +#define WHITE 0xFFFFFFFF +#define RED 0xFF0000FF +#define GREEN 0xFF00FF00 +#define BLUE 0xFFFF0000 +#define YELLOW 0xFF00FFFF +#define CYAN 0xFFFFFF00 +#define MAGENTA 0xFFFF00FF +#define ORANGE 0xFF0080FF +#define PURPLE 0xFF800080 +#define PINK 0xFFFFAFAF +#define BROWN 0xFF4F2F0F +#define GRAY 0xFF808080 +#define LIGHT_GRAY 0xFFC0C0C0 +#define DARK_GRAY 0xFF404040 + +uint x = gl_GlobalInvocationID.x; +uint y = gl_GlobalInvocationID.y; +uint p = x + y * WSX; + +void drawSquare(uint centerX, uint centerY, uint size, uint couleur) { + if (x >= centerX - size && x <= centerX + size && + y >= centerY - size && y <= centerY + size) { + + if (couleur == 1) { + data_0[p] = RED; + } else if (couleur == 2) { + data_0[p] = BLUE; + } else if (couleur == 3) { + data_0[p] = GREEN; + } else if (couleur == 4) { + data_0[p] = BLACK; + } else if (couleur == 5) { + data_0[p] = WHITE; + } else if (couleur == 6) { + data_0[p] = YELLOW; + } else if (couleur == 7) { + data_0[p] = CYAN; + } else if (couleur == 8) { + data_0[p] = MAGENTA; + } else if (couleur == 9) { + data_0[p] = ORANGE; + } else if (couleur == 10) { + data_0[p] = PURPLE; + } else if (couleur == 11) { + data_0[p] = PINK; + } else if (couleur == 12) { + data_0[p] = BROWN; + } else if (couleur == 13) { + data_0[p] = GRAY; + } else if (couleur == 14) { + data_0[p] = LIGHT_GRAY; + } else if (couleur == 15) { + data_0[p] = DARK_GRAY; + } + + + + + } +} + + +void circle(uint cx, uint cy, uint rayon, int epaisseur) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (rayon - epaisseur) * (rayon - epaisseur) && + (x - cx) * (x - cx) + (y - cy) * (y - cy) <= rayon * rayon) { + data_0[p] = RED; + } +} + +void main() { + if (step == 0) { + data_0[p] = GREEN; + } + + uint centerX = 540; + uint centerY = 540; + + for (uint i = 0; i < step +2; i++) { + uint size = step - (i * 10); + if (size > 0) { + // drawSquare(270, 270, size, (i + step / 30) % 15 + 1); + // drawSquare(810, 270, size, (i + step / 30) % 15 + 1); + // drawSquare(270, 810, size, (i + step / 30) % 15 + 1); + // drawSquare(810, 810, size, (i + step / 30) % 15 + 1); + drawSquare(540, 540, size, (i + step / 30) % 15 + 1); + } + } + + // if (input_params.append(Input.get_mouse_button_mask()) != 0) { + // uint mouseX = Input.get_mouse_position().x; + // uint mouseY = Input.get_mouse_position().y; + + drawSquare(540, 540, 20, 1); + circle(mousex,mousey,50,3); + // } +} diff --git a/examples/Projet/projet_2_test.cpp b/examples/Projet/projet_2_test.cpp new file mode 100644 index 0000000..53bc9e3 --- /dev/null +++ b/examples/Projet/projet_2_test.cpp @@ -0,0 +1,187 @@ +#define BLACK 0xFF000000 +#define WHITE 0xFFFFFFFF +#define RED 0xFF0000FF +#define GREEN 0xFF00FF00 +#define BLUE 0xFFFF0000 +#define YELLOW 0xFF00FFFF +#define CYAN 0xFFFFFF00 +#define MAGENTA 0xFFFF00FF +#define ORANGE 0xFF0080FF +#define PURPLE 0xFF800080 +#define PINK 0xFFFFAFAF +#define BROWN 0xFF4F2F0F +#define GRAY 0xFF808080 +#define LIGHT_GRAY 0xFFC0C0C0 +#define DARK_GRAY 0xFF404040 + +int x = int(gl_GlobalInvocationID.x); // Conversion explicite en `int` +int y = int(gl_GlobalInvocationID.y); +int p = x + y * int(WSX); + +void drawRotatedSquare(int centerX, int centerY, int size, int couleur, float angle) { + float cosA = cos(angle); + float sinA = sin(angle); + + for (int dx = -size; dx <= size; dx++) { + for (int dy = -size; dy <= size; dy++) { + int xOrig = centerX + dx; + int yOrig = centerY + dy; + + // Rotation des coordonnées + int xRot = centerX + int(dx * cosA - dy * sinA); + int yRot = centerY + int(dx * sinA + dy * cosA); + + if (xRot >= 0 && xRot < int(WSX) && yRot >= 0 && yRot < int(WSY)) { + int pRot = xRot + yRot * int(WSX); + if (couleur == 1) { + data_0[pRot] = RED; + } else if (couleur == 2) { + data_0[pRot] = BLUE; + } else if (couleur == 3) { + data_0[pRot] = GREEN; + } else if (couleur == 4) { + data_0[pRot] = BLACK; + } else if (couleur == 5) { + data_0[pRot] = WHITE; + } else if (couleur == 6) { + data_0[pRot] = YELLOW; + } else if (couleur == 7) { + data_0[pRot] = CYAN; + } else if (couleur == 8) { + data_0[pRot] = MAGENTA; + } else if (couleur == 9) { + data_0[pRot] = ORANGE; + } else if (couleur == 10) { + data_0[pRot] = PURPLE; + } else if (couleur == 11) { + data_0[pRot] = PINK; + } else if (couleur == 12) { + data_0[pRot] = BROWN; + } else if (couleur == 13) { + data_0[pRot] = GRAY; + } else if (couleur == 14) { + data_0[pRot] = LIGHT_GRAY; + } else if (couleur == 15) { + data_0[pRot] = DARK_GRAY; + } + } + } + } +} + +void main() { + if (step == 0) { + data_0[p] = GREEN; + } + + float angle = (step / 50)%360 * 3.14159 / 180.0; + for (int i = 0; i < step +2; i++) { + int size = step - (i * 10); + if (size > 0) { + + drawRotatedSquare(540, 540, size, (i + step / 30) % 15 + 1, angle); + + } +} +} + + + + +// #define BLACK 0xFF000000 +// #define WHITE 0xFFFFFFFF +// #define RED 0xFF0000FF +// #define GREEN 0xFF00FF00 +// #define BLUE 0xFFFF0000 +// #define YELLOW 0xFF00FFFF +// #define CYAN 0xFFFFFF00 +// #define MAGENTA 0xFFFF00FF +// #define ORANGE 0xFF0080FF +// #define PURPLE 0xFF800080 +// #define PINK 0xFFFFAFAF +// #define BROWN 0xFF4F2F0F +// #define GRAY 0xFF808080 +// #define LIGHT_GRAY 0xFFC0C0C0 +// #define DARK_GRAY 0xFF404040 + +// int x = int(gl_GlobalInvocationID.x); +// int y = int(gl_GlobalInvocationID.y); +// int p = x + y * int(WSX); + +// // Matrice de rotation simplifiée +// void rotate(int inX, int inY, int centerX, int centerY, float cosA, float sinA, out int outX, out int outY) { +// int relX = inX - centerX; +// int relY = inY - centerY; + +// outX = centerX + int(relX * cosA - relY * sinA); +// outY = centerY + int(relX * sinA + relY * cosA); +// } + +// void drawRotatedSquare(int centerX, int centerY, int size, int couleur, float angle) { +// float cosA = cos(angle); +// float sinA = sin(angle); + +// int x1, y1, x2, y2, x3, y3, x4, y4; + +// // Calcul des 4 coins du carré +// rotate(centerX - size, centerY - size, centerX, centerY, cosA, sinA, x1, y1); +// rotate(centerX + size, centerY - size, centerX, centerY, cosA, sinA, x2, y2); +// rotate(centerX - size, centerY + size, centerX, centerY, cosA, sinA, x3, y3); +// rotate(centerX + size, centerY + size, centerX, centerY, cosA, sinA, x4, y4); + +// // On ne modifie que les bords du carré (pas l'intérieur) +// if ((x >= x1 && x <= x2 && (y == y1 || y == y3)) || +// (y >= y1 && y <= y3 && (x == x1 || x == x2))) { + +// int pRot = x + y * int(WSX); + +// // Choix de la couleur avec `if` +// if (couleur == 1) { +// data_0[pRot] = RED; +// } else if (couleur == 2) { +// data_0[pRot] = BLUE; +// } else if (couleur == 3) { +// data_0[pRot] = GREEN; +// } else if (couleur == 4) { +// data_0[pRot] = BLACK; +// } else if (couleur == 5) { +// data_0[pRot] = WHITE; +// } else if (couleur == 6) { +// data_0[pRot] = YELLOW; +// } else if (couleur == 7) { +// data_0[pRot] = CYAN; +// } else if (couleur == 8) { +// data_0[pRot] = MAGENTA; +// } else if (couleur == 9) { +// data_0[pRot] = ORANGE; +// } else if (couleur == 10) { +// data_0[pRot] = PURPLE; +// } else if (couleur == 11) { +// data_0[pRot] = PINK; +// } else if (couleur == 12) { +// data_0[pRot] = BROWN; +// } else if (couleur == 13) { +// data_0[pRot] = GRAY; +// } else if (couleur == 14) { +// data_0[pRot] = LIGHT_GRAY; +// } else if (couleur == 15) { +// data_0[pRot] = DARK_GRAY; +// } +// } +// } + +// void main() { +// if (step == 0) { +// data_0[p] = GREEN; +// } + +// // Réduction de la vitesse de rotation +// float angle = (step / 20.0) * 3.14159 / 180.0; + +// for (int i = 0; i < step +2; i++) { +// int size = step - (i * 10); +// if (size > 0) { +// drawRotatedSquare(540, 540, size, (i + step / 30) % 15 + 1, angle); +// } +// } +// } From 20a5483d86e0bf4a399bdd5213807c6bd8a10c49 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Tue, 18 Mar 2025 00:06:55 +0100 Subject: [PATCH 07/12] Tentative de shoot Tentative de shoot them up --- examples/Projet/Shoot_them_up_test.cpp | 0 examples/Projet/projet2.cpp | 35 ++++++++++++-------------- examples/Projet/projet_liam_frit.tscn | 2 +- 3 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 examples/Projet/Shoot_them_up_test.cpp diff --git a/examples/Projet/Shoot_them_up_test.cpp b/examples/Projet/Shoot_them_up_test.cpp new file mode 100644 index 0000000..e69de29 diff --git a/examples/Projet/projet2.cpp b/examples/Projet/projet2.cpp index 2ba1910..8706cdb 100644 --- a/examples/Projet/projet2.cpp +++ b/examples/Projet/projet2.cpp @@ -73,28 +73,25 @@ void circle(uint cx, uint cy, uint rayon, int epaisseur) { void main() { if (step == 0) { - data_0[p] = GREEN; + data_0[p] = GREEN; } - uint centerX = 540; uint centerY = 540; + // for (uint i = 0; i < step +2; i++) { + // uint size = step - (i * 10); + // if (size > 0) { + // // drawSquare(270, 270, size, (i + step / 30) % 15 + 1); + // // drawSquare(810, 270, size, (i + step / 30) % 15 + 1); + // // drawSquare(270, 810, size, (i + step / 30) % 15 + 1); + // // drawSquare(810, 810, size, (i + step / 30) % 15 + 1); + // drawSquare(540, 540, size, (i + step / 30) % 15 + 1); + // } + // } - for (uint i = 0; i < step +2; i++) { - uint size = step - (i * 10); - if (size > 0) { - // drawSquare(270, 270, size, (i + step / 30) % 15 + 1); - // drawSquare(810, 270, size, (i + step / 30) % 15 + 1); - // drawSquare(270, 810, size, (i + step / 30) % 15 + 1); - // drawSquare(810, 810, size, (i + step / 30) % 15 + 1); - drawSquare(540, 540, size, (i + step / 30) % 15 + 1); + //drawSquare(540, 540, 20, 1); + //circle(mousex, mousey, 50, 3); + + if ((mouse_button)> 0) { + circle(mousex, mousey, 50, 3); } - } - - // if (input_params.append(Input.get_mouse_button_mask()) != 0) { - // uint mouseX = Input.get_mouse_position().x; - // uint mouseY = Input.get_mouse_position().y; - - drawSquare(540, 540, 20, 1); - circle(mousex,mousey,50,3); - // } } diff --git a/examples/Projet/projet_liam_frit.tscn b/examples/Projet/projet_liam_frit.tscn index 5f76fbb..e8f5f72 100644 --- a/examples/Projet/projet_liam_frit.tscn +++ b/examples/Projet/projet_liam_frit.tscn @@ -9,7 +9,7 @@ script = ExtResource("1_8kd26") WSX = 1080 WSY = 1080 -glsl_file = "res://examples/Projet/projet.cpp" +glsl_file = "res://examples/Projet/projet2.cpp" GLSL_code = "" data = [NodePath("../Icon")] From d79febd1a28d545955f21f4a4cf431801c1c771c Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Tue, 18 Mar 2025 01:07:14 +0100 Subject: [PATCH 08/12] =?UTF-8?q?Destruction=20des=20carr=C3=A9s=20mais=20?= =?UTF-8?q?probl=C3=A8me=20de=20r=C3=A9apparition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nous pouvons casser les carrés mais lors de la réapparition il n'y a pas qu'un seul carré qui réapparait --- examples/Projet/Shoot_them_up_test.cpp | 135 +++++++++++++++++++++++++ examples/Projet/projet_liam_frit.tscn | 2 +- 2 files changed, 136 insertions(+), 1 deletion(-) diff --git a/examples/Projet/Shoot_them_up_test.cpp b/examples/Projet/Shoot_them_up_test.cpp index e69de29..d760414 100644 --- a/examples/Projet/Shoot_them_up_test.cpp +++ b/examples/Projet/Shoot_them_up_test.cpp @@ -0,0 +1,135 @@ +// Définition des couleurs +#define BLACK 0xFF000000 +#define WHITE 0xFFFFFFFF +#define RED 0xFF0000FF +#define GREEN 0xFF00FF00 +#define BLUE 0xFFFF0000 +#define YELLOW 0xFF00FFFF +#define CYAN 0xFFFFFF00 +#define MAGENTA 0xFFFF00FF + +// Variables globales pour suivre l'état des carrés +bool isErased1 = false; +bool isErased2 = false; +bool isErased3 = false; +bool isErased4 = false; +bool isErased5 = false; // Suivre si le premier carré est effacé +// Vous pouvez créer de nombreuses variables comme celles-ci pour d'autres carrés si nécessaire + +uint x = gl_GlobalInvocationID.x; +uint y = gl_GlobalInvocationID.y; +uint p = x + y * WSX; + +// Fonction de hachage pour la génération aléatoire +uint wang_hash(uint seed) { + seed = (seed ^ 61) ^ (seed >> 16); + seed *= 9; + seed = seed ^ (seed >> 4); + seed *= 0x27d4eb2d; + seed = seed ^ (seed >> 15); + return seed; +} + +// Fonction pour dessiner un carré +void drawSquare(uint centerX, uint centerY, uint size, uint couleur) { + if (x >= centerX - size && x <= centerX + size && + y >= centerY - size && y <= centerY + size) { + + if (couleur == 1) { + data_0[p] = RED; + } else if (couleur == 2) { + data_0[p] = BLUE; + } else if (couleur == 3) { + data_0[p] = GREEN; + } else if (couleur == 4) { + data_0[p] = YELLOW; + } else if (couleur == 5) { + data_0[p] = CYAN; + } else if (couleur == 6) { + data_0[p] = MAGENTA; + } + } +} + +// Fonction principale +void main() { + // Remplir l'écran en noir au premier frame + if (step == 0) { + data_0[p] = BLACK; + + + } + + + uint seed = 12345; + + uint centerX1 = 100 + wang_hash(seed + step) % 880; + uint centerY1 = 100 + wang_hash(seed + step) % 880; + uint size1 = 20 + wang_hash(seed + step) % 60; + uint color1 = 1 + wang_hash(seed + step) % 6; + + uint centerX2 = 100 + wang_hash(seed+ step + 50) % 880; + uint centerY2 = 100 + wang_hash(seed + step+ 60) % 880; + uint size2 = 20 + wang_hash(seed + step+ 70) % 60; + uint color2 = 1 + wang_hash(seed + step+ 80) % 6; + + uint centerX3 = 100 + wang_hash(seed+ step + 90) % 880; + uint centerY3 = 100 + wang_hash(seed + step+ 100) % 880; + uint size3 = 20 + wang_hash(seed+ step + 110) % 60; + uint color3 = 1 + wang_hash(seed + step+ 120) % 6; + + uint centerX4 = 100 + wang_hash(seed + step+ 130) % 880; + uint centerY4 = 100 + wang_hash(seed + step+ 140) % 880; + uint size4 = 20 + wang_hash(seed + step+ 150) % 60; + uint color4 = 1 + wang_hash(seed + step+ 160) % 6; + + uint centerX5 = 100 + wang_hash(seed+ step + 170) % 880; + uint centerY5 = 100 + wang_hash(seed + step+ 180) % 880; + uint size5 = 20 + wang_hash(seed+ step + 190) % 60; + uint color5 = 1 + wang_hash(seed + step+ 200) % 6; + + + + drawSquare(1000, 50, 30,1); + + // Utiliser une graine fixe pour avoir des positions stables + + + // Coordonnées et taille du premier carré + + + // Si le carré n'a pas été effacé, dessiner + if (step == 1) { + drawSquare(centerX1, centerY1, size1, color1); + drawSquare(centerX2, centerY2, size2, color2); + drawSquare(centerX3, centerY3, size3, color3); + drawSquare(centerX4, centerY4, size4, color4); + drawSquare(centerX5, centerY5, size5, color5); + } + + if (mouse_button > 0) { + if (mousex >= 1000 - 30 && mousex <= 1000 + 30 && + mousey >= 50 - 30 && mousey <= 50 + 30) { + + drawSquare(centerX1, centerY1, size1, color1); + } + } + + + // Vérification si la souris est dans la zone du carré + if (mouse_button > 0) { + if (mousex >= centerX1 - size1 && mousex <= centerX1 + size1 && + mousey >= centerY1 - size1 && mousey <= centerY1 + size1) { + + // Effacer le carré en changeant la couleur à noir + data_0[p] = BLACK; + isErased1 = true; // Marquer l'état comme effacé + }else if (mousex >= centerX2 - size2 && mousex <= centerX2 + size2 && + mousey >= centerX2 - size2 && mousey <= centerX2 + size2) { + + // Effacer le carré en changeant la couleur à noir + data_0[p] = BLACK; + isErased2 = true; // Marquer l'état comme effacé + } + } +} diff --git a/examples/Projet/projet_liam_frit.tscn b/examples/Projet/projet_liam_frit.tscn index e8f5f72..d180e91 100644 --- a/examples/Projet/projet_liam_frit.tscn +++ b/examples/Projet/projet_liam_frit.tscn @@ -9,7 +9,7 @@ script = ExtResource("1_8kd26") WSX = 1080 WSY = 1080 -glsl_file = "res://examples/Projet/projet2.cpp" +glsl_file = "res://examples/Projet/Shoot_them_up_test.cpp" GLSL_code = "" data = [NodePath("../Icon")] From 4e1b6322f1ef56b8bd75f07c0a93cc4dbf477324 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Tue, 18 Mar 2025 01:34:52 +0100 Subject: [PATCH 09/12] Viser et tirer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nous pouvons désormais viser et tirer sur le cercle ainsi que sur un carré pour changer le fond --- examples/Projet/projet.cpp | 122 +++++++++++++++++++++++--- examples/Projet/projet2.cpp | 17 ++++ examples/Projet/projet_liam_frit.tscn | 2 +- 3 files changed, 126 insertions(+), 15 deletions(-) diff --git a/examples/Projet/projet.cpp b/examples/Projet/projet.cpp index d292998..40579f9 100644 --- a/examples/Projet/projet.cpp +++ b/examples/Projet/projet.cpp @@ -3,6 +3,17 @@ #define GREEN 0xFF00FF00 #define BLUE 0xFFFF0000 #define COLLISION_MARKER 0xFFFF00FF +#define WHITE 0xFFFFFFFF +#define YELLOW 0xFF00FFFF +#define CYAN 0xFFFFFF00 +#define MAGENTA 0xFFFF00FF +#define ORANGE 0xFF0080FF +#define PURPLE 0xFF800080 +#define PINK 0xFFFFAFAF +#define BROWN 0xFF4F2F0F +#define GRAY 0xFF808080 +#define LIGHT_GRAY 0xFFC0C0C0 +#define DARK_GRAY 0xFF404040 void circle(uint cx, uint cy, uint rayon, int epaisseur) { uint x = gl_GlobalInvocationID.x; @@ -47,42 +58,125 @@ bool checkCollision(uint cx, uint cy, uint radius, uint couleur) { return false; } +void drawSquare(uint centerX, uint centerY, uint size, uint couleur) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + if (x >= centerX - size && x <= centerX + size && + y >= centerY - size && y <= centerY + size) { + + if (couleur == 1) { + data_0[p] = DARK_GRAY; + } else if (couleur == 2) { + data_0[p] = YELLOW; + } else if (couleur == 3) { + data_0[p] = GREEN; + } else if (couleur == 4) { + data_0[p] = BLACK; + } else if (couleur == 5) { + data_0[p] = WHITE; + } else if (couleur == 6) { + data_0[p] = YELLOW; + } else if (couleur == 7) { + data_0[p] = CYAN; + } else if (couleur == 8) { + data_0[p] = MAGENTA; + } else if (couleur == 9) { + data_0[p] = ORANGE; + } else if (couleur == 10) { + data_0[p] = PURPLE; + } else if (couleur == 11) { + data_0[p] = PINK; + } else if (couleur == 12) { + data_0[p] = BROWN; + } else if (couleur == 13) { + data_0[p] = GRAY; + } else if (couleur == 14) { + data_0[p] = LIGHT_GRAY; + } else if (couleur == 15) { + data_0[p] = DARK_GRAY; + } + + + + + } +} + + +void drawCross(uint cx, uint cy, uint radius, uint thickness) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (radius - thickness) * (radius - thickness) && + (x - cx) * (x - cx) + (y - cy) * (y - cy) <= radius * radius) { + data_0[p] = WHITE; + } + + if ((y >= cy - thickness && y <= cy + thickness && x >= cx - radius && x <= cx + radius) || + (x >= cx - thickness && x <= cx + thickness && y >= cy - radius && y <= cy + radius)) { + data_0[p] = WHITE; +} +} + void main() { uint x = gl_GlobalInvocationID.x; uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; bool hasCollided = (data_0[0] == COLLISION_MARKER); - + if (p != 0) { data_0[p] = BLACK; } - + + drawSquare(1000, 50, 30, 1); + drawCross(mousex, mousey, 50, 3); + circle(540, 540, 200, 20); uint movingCircleRadius = 30; uint centerX = 540; float amplitude = 160.0; - float frequency = 0.01; - uint normalY = uint(540.0 + amplitude * sin(float(step) * frequency)); - uint invertedY = uint(540.0 - amplitude * sin(float(step) * frequency)); + float frequency = 0.05; + float sinValue = sin(float(step) * frequency); + uint normalY = uint(540.0 + amplitude * sinValue); + uint invertedY = uint(540.0 - amplitude * sinValue); - if (!hasCollided) { - bool collision = checkCollision(centerX, normalY, movingCircleRadius, RED); - if (collision) { - data_0[0] = COLLISION_MARKER; - hasCollided = true; + + if (mouse_button > 0) { + + if ((mousex - centerX) * (mousex - centerX) + (mousey - normalY) * (mousey - normalY) <= movingCircleRadius * movingCircleRadius) { + data_0[p] = CYAN; + } + } + + if (mouse_button > 0) { + if (mousex >= 1000 - 30 && mousex <= 1000 + 30 && + mousey >= 50 - 30 && mousey <= 50 + 30) { + + for (uint i = 0; i < step +2; i++) { + uint size = step - (i * 10); + if (size > 0) { + // drawSquare(270, 270, size, (i + step / 30) % 15 + 1); + // drawSquare(810, 270, size, (i + step / 30) % 15 + 1); + // drawSquare(270, 810, size, (i + step / 30) % 15 + 1); + // drawSquare(810, 810, size, (i + step / 30) % 15 + 1); + drawSquare(540, 540, size, (i + step / 30) % 15 + 1); + } + } } } uint newcolor; - if (!hasCollided) { - newcolor = 1; // BLUE + newcolor = 2; circleFull(centerX, normalY, movingCircleRadius, newcolor); } else { - newcolor = 2; // RED + newcolor = 2; circleFull(centerX, invertedY, movingCircleRadius, newcolor); } -} \ No newline at end of file +} + diff --git a/examples/Projet/projet2.cpp b/examples/Projet/projet2.cpp index 8706cdb..1ceb765 100644 --- a/examples/Projet/projet2.cpp +++ b/examples/Projet/projet2.cpp @@ -71,6 +71,23 @@ void circle(uint cx, uint cy, uint rayon, int epaisseur) { } } +void drawCross(uint cx, uint cy, uint radius) { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + // Vérifier si on est sur le contour du cercle + if ((x - cx) * (x - cx) + (y - cy) * (y - cy) >= (radius - 1) * (radius - 1) && + (x - cx) * (x - cx) + (y - cy) * (y - cy) <= radius * radius) { + data_0[p] = WHITE; // Contour du cercle + } + + // Dessiner la croix (lignes horizontale et verticale) + if ((x >= cx - radius && x <= cx + radius && y == cy) || (y >= cy - radius && y <= cy + radius && x == cx)) { + data_0[p] = WHITE; // Lignes de la croix (blanches) + } +} + void main() { if (step == 0) { data_0[p] = GREEN; diff --git a/examples/Projet/projet_liam_frit.tscn b/examples/Projet/projet_liam_frit.tscn index d180e91..5f76fbb 100644 --- a/examples/Projet/projet_liam_frit.tscn +++ b/examples/Projet/projet_liam_frit.tscn @@ -9,7 +9,7 @@ script = ExtResource("1_8kd26") WSX = 1080 WSY = 1080 -glsl_file = "res://examples/Projet/Shoot_them_up_test.cpp" +glsl_file = "res://examples/Projet/projet.cpp" GLSL_code = "" data = [NodePath("../Icon")] From e24f45bf551acd9bf05d508409543d2374ef9de7 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Tue, 18 Mar 2025 02:01:22 +0100 Subject: [PATCH 10/12] =?UTF-8?q?Version=20Adapt=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plus de chose , quelque problème réglé tels que la collision sur le cercle La couleur qui change bien quand on touche le rond avec le viseur --- examples/Projet/projet.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/examples/Projet/projet.cpp b/examples/Projet/projet.cpp index 40579f9..6d6ca48 100644 --- a/examples/Projet/projet.cpp +++ b/examples/Projet/projet.cpp @@ -134,12 +134,13 @@ void main() { drawSquare(1000, 50, 30, 1); drawCross(mousex, mousey, 50, 3); - circle(540, 540, 200, 20); + // Agrandissement du cercle + circle(540, 540, 300, 20); // Le rayon du cercle est maintenant de 300 uint movingCircleRadius = 30; uint centerX = 540; - float amplitude = 160.0; + float amplitude = 270.0; float frequency = 0.05; float sinValue = sin(float(step) * frequency); uint normalY = uint(540.0 + amplitude * sinValue); @@ -147,9 +148,9 @@ void main() { if (mouse_button > 0) { - if ((mousex - centerX) * (mousex - centerX) + (mousey - normalY) * (mousey - normalY) <= movingCircleRadius * movingCircleRadius) { data_0[p] = CYAN; + drawSquare(mousex, mousey, 5, 7); } } @@ -158,15 +159,11 @@ void main() { mousey >= 50 - 30 && mousey <= 50 + 30) { for (uint i = 0; i < step +2; i++) { - uint size = step - (i * 10); - if (size > 0) { - // drawSquare(270, 270, size, (i + step / 30) % 15 + 1); - // drawSquare(810, 270, size, (i + step / 30) % 15 + 1); - // drawSquare(270, 810, size, (i + step / 30) % 15 + 1); - // drawSquare(810, 810, size, (i + step / 30) % 15 + 1); - drawSquare(540, 540, size, (i + step / 30) % 15 + 1); - } + uint size = step - (i * 10); + if (size > 0) { + drawSquare(540, 540, size, (i + step / 30) % 15 + 1); } + } } } @@ -175,8 +172,25 @@ void main() { newcolor = 2; circleFull(centerX, normalY, movingCircleRadius, newcolor); } else { - newcolor = 2; + newcolor = 1; circleFull(centerX, invertedY, movingCircleRadius, newcolor); } + + // Ajout du mouvement libre de la boule à l'intérieur du cercle + float angle = float(step) * frequency; + uint newX = uint(centerX + amplitude * cos(angle)); // Position X dans le cercle + uint newY = uint(540.0 + amplitude * sin(angle)); // Position Y dans le cercle + + // Déplacer la boule à n'importe où dans le cercle en fonction du mouvement de la souris + if (mouse_button > 0) { + if ((mousex - newX) * (mousex - newX) + (mousey - newY) * (mousey - newY) <= movingCircleRadius * movingCircleRadius) { + data_0[p] = CYAN; + } + } + + // Dessiner la boule à la nouvelle position calculée + circleFull(newX, newY, movingCircleRadius, 2); // 2 représente la couleur de la boule en mouvement } + + From 3b78c969fa6c8f7a01027548f250d7f625182025 Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Tue, 18 Mar 2025 02:08:20 +0100 Subject: [PATCH 11/12] Tentative d'ajout de shoot them up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Un carré est censé apparaître mais est actuellement toujours mis derrière le fond --- examples/Projet/projet.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/examples/Projet/projet.cpp b/examples/Projet/projet.cpp index 6d6ca48..030a71e 100644 --- a/examples/Projet/projet.cpp +++ b/examples/Projet/projet.cpp @@ -120,10 +120,30 @@ void drawCross(uint cx, uint cy, uint radius, uint thickness) { } } +uint wang_hash(uint seed) { + seed = (seed ^ 61) ^ (seed >> 16); + seed *= 9; + seed = seed ^ (seed >> 4); + seed *= 0x27d4eb2d; + seed = seed ^ (seed >> 15); + return seed; +} + void main() { uint x = gl_GlobalInvocationID.x; uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; + + uint seed = 12345; + + uint centerX1 = 100 + wang_hash(seed + step) % 880; + uint centerY1 = 100 + wang_hash(seed + step) % 880; + uint size1 = 20 + wang_hash(seed + step) % 60; + uint color1 = 1 + wang_hash(seed + step) % 6; + + if (step == 1) { + drawSquare(centerX1, centerY1, size1, color1); + } bool hasCollided = (data_0[0] == COLLISION_MARKER); @@ -146,7 +166,16 @@ void main() { uint normalY = uint(540.0 + amplitude * sinValue); uint invertedY = uint(540.0 - amplitude * sinValue); - + if (mouse_button > 0) { + if (mousex >= centerX1 - size1 && mousex <= centerX1 + size1 && + mousey >= centerY1 - size1 && mousey <= centerY1 + size1) { + + // Effacer le carré en changeant la couleur à noir + data_0[p] = BLACK; + + } + } + if (mouse_button > 0) { if ((mousex - centerX) * (mousex - centerX) + (mousey - normalY) * (mousey - normalY) <= movingCircleRadius * movingCircleRadius) { data_0[p] = CYAN; From 8d8dc32f48bbcd3aa3aac7d2b12bff3cee94481e Mon Sep 17 00:00:00 2001 From: Liam-fprog Date: Tue, 18 Mar 2025 10:45:08 +0100 Subject: [PATCH 12/12] =?UTF-8?q?Mise=20=C3=A0=20jour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/Projet/projet_liam_frit.tscn | 2 +- examples/example_1.tscn | 2 +- project.godot | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Projet/projet_liam_frit.tscn b/examples/Projet/projet_liam_frit.tscn index 5f76fbb..aca52b0 100644 --- a/examples/Projet/projet_liam_frit.tscn +++ b/examples/Projet/projet_liam_frit.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://bonxt31s15o3g"] -[ext_resource type="Script" uid="uid://c8esqdv0y26yp" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_8kd26"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_8kd26"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_5doh8"] [node name="ProjetLiamFrit" type="Node2D"] diff --git a/examples/example_1.tscn b/examples/example_1.tscn index 4d271f5..9b4fac1 100644 --- a/examples/example_1.tscn +++ b/examples/example_1.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://ddr6qtwy1pesd"] -[ext_resource type="Script" uid="uid://c8esqdv0y26yp" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_6846p"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_6846p"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_s3fct"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_dmk8h"] diff --git a/project.godot b/project.godot index 1617345..0436dd7 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="compute_shader_studio" run/main_scene="res://examples/example_1.tscn" -config/features=PackedStringArray("4.4", "Forward Plus") +config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png" [editor_plugins]