From c79df83d5e294b31dbf333488a303f5b21b8c117 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:36:46 +0200 Subject: [PATCH 01/12] Add Poison Feature with related code --- .feature-model | 1 + src/logic/DataOfSquare.java | 1 + src/logic/ThreadsController.java | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/.feature-model b/.feature-model index c543b91..c67b942 100644 --- a/.feature-model +++ b/.feature-model @@ -3,6 +3,7 @@ Snake_Game Tile Food Spawn + Poison Blank Snake Update diff --git a/src/logic/DataOfSquare.java b/src/logic/DataOfSquare.java index 092a1c7..5e2727f 100644 --- a/src/logic/DataOfSquare.java +++ b/src/logic/DataOfSquare.java @@ -15,6 +15,7 @@ public DataOfSquare(int color) { //Lets add the color to the arrayList C.add(Color.darkGray);// &line[Tile::Snake] C.add(Color.BLUE); // &line[Food] + C.add(Color.RED); // &line[Poison] C.add(Color.white); // &line[Playing_Area] square = new SquarePanel(C.get(color)); } diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index 416ca7d..234ca4c 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -15,6 +15,7 @@ public class ThreadsController extends Thread { private final ArrayList positions = new ArrayList<>(); private Tuple foodPosition; // &line[Food] + private Tuple poisonPosition; // &line[Poison] //Constructor of ControllerThread public ThreadsController(Tuple positionDepart) { @@ -34,6 +35,11 @@ public ThreadsController(Tuple positionDepart) { foodPosition = new Tuple(Window.getWindowHeight() - 1, Window.getWindowWidth() - 1); spawnFood(foodPosition);//&line[Spawn] // &end[Food] + + // &begin[Poison] + foodPosition = new Tuple(Window.getWindowHeight() - 3, Window.getWindowWidth() - 3); + spawnFood(poisonPosition); // &line[Poison] + // &end[Poison] } //Important part : @@ -79,6 +85,18 @@ private void checkCollision() { spawnFood(foodPosition); // &line[Spawn] } // &end[Food] + + + // &begin[Poison] + boolean eatingPoison = posCritique.getX() == poisonPosition.y && posCritique.getY() == poisonPosition.x; + if (eatingFood) { + System.out.println("Yummy!"); + sizeSnake = sizeSnake + 1; + poisonPosition = getTileNotInSnake(); + + spawnFood(poisonPosition); // &line[Spawn] + } + // &end[Poison] } //Stops The Game @@ -91,6 +109,7 @@ private void stopTheGame(String s) { } // &end[Collision] + //Put food in a position and displays it // &begin[Spawn] private void spawnFood(Tuple foodPositionIn) { @@ -98,6 +117,12 @@ private void spawnFood(Tuple foodPositionIn) { } // &end[Spawn] + // &begin[Spawn] + private void spawnPoison(Tuple poisonPositionIn) { + Squares.get(poisonPositionIn.x).get(poisonPositionIn.y).lightMeUp(SquareToLightUp.FOOD); + } + // &end[Spawn] + // &begin[Blank] //return a position not occupied by the snake private Tuple getTileNotInSnake() { From 7131506c9f2c8f7d454d75a9aacb1473cc443114 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:43:03 +0200 Subject: [PATCH 02/12] Add Poison Feature with related code --- src/logic/ThreadsController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index 234ca4c..e407fea 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -89,12 +89,12 @@ private void checkCollision() { // &begin[Poison] boolean eatingPoison = posCritique.getX() == poisonPosition.y && posCritique.getY() == poisonPosition.x; - if (eatingFood) { - System.out.println("Yummy!"); - sizeSnake = sizeSnake + 1; + if (eatingPoison) { + System.out.println("Ouch"); + sizeSnake = sizeSnake - 1; poisonPosition = getTileNotInSnake(); - spawnFood(poisonPosition); // &line[Spawn] + spawnPoison(poisonPosition); // &line[Spawn] } // &end[Poison] } From 08de1d069abf1ecbc52c52d1f8e978387a6261ee Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:46:32 +0200 Subject: [PATCH 03/12] Add test features --- .feature-model | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.feature-model b/.feature-model index c67b942..2a5e019 100644 --- a/.feature-model +++ b/.feature-model @@ -4,6 +4,8 @@ Snake_Game Food Spawn Poison + TestFeature1 + TestFeature2 Blank Snake Update From 5e29d4e0973bf3c69767e8e49e7fc6605aa4d7a1 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:43:03 +0200 Subject: [PATCH 04/12] Poison Feature: fixed --- src/logic/ThreadsController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index 234ca4c..e407fea 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -89,12 +89,12 @@ private void checkCollision() { // &begin[Poison] boolean eatingPoison = posCritique.getX() == poisonPosition.y && posCritique.getY() == poisonPosition.x; - if (eatingFood) { - System.out.println("Yummy!"); - sizeSnake = sizeSnake + 1; + if (eatingPoison) { + System.out.println("Ouch"); + sizeSnake = sizeSnake - 1; poisonPosition = getTileNotInSnake(); - spawnFood(poisonPosition); // &line[Spawn] + spawnPoison(poisonPosition); // &line[Spawn] } // &end[Poison] } From 67277b64f8081d54a88449c2164a46e71af1bcdb Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:46:32 +0200 Subject: [PATCH 05/12] Add test features --- .feature-model | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.feature-model b/.feature-model index c67b942..2a5e019 100644 --- a/.feature-model +++ b/.feature-model @@ -4,6 +4,8 @@ Snake_Game Food Spawn Poison + TestFeature1 + TestFeature2 Blank Snake Update From 69cf4c44f25dfbd631875dedb8020d16f9804358 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:50:37 +0200 Subject: [PATCH 06/12] Add TestFeature1 --- .feature-model | 1 - src/logic/ThreadsController.java | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.feature-model b/.feature-model index 2a5e019..faa4850 100644 --- a/.feature-model +++ b/.feature-model @@ -5,7 +5,6 @@ Snake_Game Spawn Poison TestFeature1 - TestFeature2 Blank Snake Update diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index e407fea..738069e 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -16,6 +16,8 @@ public class ThreadsController extends Thread { private final ArrayList positions = new ArrayList<>(); private Tuple foodPosition; // &line[Food] private Tuple poisonPosition; // &line[Poison] + + private Tuple testFeature1; // &line[TestFeature1] //Constructor of ControllerThread public ThreadsController(Tuple positionDepart) { From 0a6fe8f4a8aa49941bff33c5b91199882f1c03a7 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:52:50 +0200 Subject: [PATCH 07/12] Add TestFeature1 --- .feature-model | 1 + 1 file changed, 1 insertion(+) diff --git a/.feature-model b/.feature-model index c67b942..450566a 100644 --- a/.feature-model +++ b/.feature-model @@ -2,6 +2,7 @@ Snake_Game Playing_Area Tile Food + TestFeature1 Spawn Poison Blank From 2595fe30688e62aa484d1a494691cab3f0ff9242 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:57:26 +0200 Subject: [PATCH 08/12] Delete TestFeature1 with code & annotations --- .feature-model | 1 - src/logic/ThreadsController.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.feature-model b/.feature-model index 450566a..c67b942 100644 --- a/.feature-model +++ b/.feature-model @@ -2,7 +2,6 @@ Snake_Game Playing_Area Tile Food - TestFeature1 Spawn Poison Blank diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index 738069e..b73a75f 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -17,7 +17,6 @@ public class ThreadsController extends Thread { private Tuple foodPosition; // &line[Food] private Tuple poisonPosition; // &line[Poison] - private Tuple testFeature1; // &line[TestFeature1] //Constructor of ControllerThread public ThreadsController(Tuple positionDepart) { @@ -221,3 +220,4 @@ private void deleteTail() { // &end[Tail] } + From 55c8428ee7cff2cd9734881da3c42ed71980e8eb Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:26:05 +0200 Subject: [PATCH 09/12] Add second type of poison --- src/logic/DataOfSquare.java | 1 + src/logic/ThreadsController.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/logic/DataOfSquare.java b/src/logic/DataOfSquare.java index 5e2727f..9f51fdd 100644 --- a/src/logic/DataOfSquare.java +++ b/src/logic/DataOfSquare.java @@ -16,6 +16,7 @@ public DataOfSquare(int color) { C.add(Color.darkGray);// &line[Tile::Snake] C.add(Color.BLUE); // &line[Food] C.add(Color.RED); // &line[Poison] + C.add(Color.YELLOW); // &line[Poison] C.add(Color.white); // &line[Playing_Area] square = new SquarePanel(C.get(color)); } diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index b73a75f..c5edcaa 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -17,6 +17,8 @@ public class ThreadsController extends Thread { private Tuple foodPosition; // &line[Food] private Tuple poisonPosition; // &line[Poison] + private Tuple poisonPosition2; // &line[Poison] + //Constructor of ControllerThread public ThreadsController(Tuple positionDepart) { From 094e2b2f86729abb4a631eff56bba5bc0d85cc29 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Sat, 5 Oct 2024 19:02:32 +0200 Subject: [PATCH 10/12] add feature-to-folder annotations --- src/graphics/.feature-to-folder | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/graphics/.feature-to-folder diff --git a/src/graphics/.feature-to-folder b/src/graphics/.feature-to-folder new file mode 100644 index 0000000..00212dd --- /dev/null +++ b/src/graphics/.feature-to-folder @@ -0,0 +1 @@ +Update Controls \ No newline at end of file From 9c95a6c29397876260fd016e1e1ebd207ed3fab0 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:00:04 +0100 Subject: [PATCH 11/12] add MildPoison feature with code --- .feature-model | 1 + src/logic/DataOfSquare.java | 2 +- src/logic/SquareToLightUp.java | 2 ++ src/logic/ThreadsController.java | 38 ++++++++++++++++++++++---------- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.feature-model b/.feature-model index c67b942..1e29a90 100644 --- a/.feature-model +++ b/.feature-model @@ -4,6 +4,7 @@ Snake_Game Food Spawn Poison + MildPoison Blank Snake Update diff --git a/src/logic/DataOfSquare.java b/src/logic/DataOfSquare.java index 9f51fdd..def1121 100644 --- a/src/logic/DataOfSquare.java +++ b/src/logic/DataOfSquare.java @@ -16,7 +16,7 @@ public DataOfSquare(int color) { C.add(Color.darkGray);// &line[Tile::Snake] C.add(Color.BLUE); // &line[Food] C.add(Color.RED); // &line[Poison] - C.add(Color.YELLOW); // &line[Poison] + C.add(Color.YELLOW); // &line[MildPoison] C.add(Color.white); // &line[Playing_Area] square = new SquarePanel(C.get(color)); } diff --git a/src/logic/SquareToLightUp.java b/src/logic/SquareToLightUp.java index 5d73498..a860cd6 100644 --- a/src/logic/SquareToLightUp.java +++ b/src/logic/SquareToLightUp.java @@ -3,5 +3,7 @@ public enum SquareToLightUp { SNAKE, // &line[Tile::Snake] FOOD, // &line[Food] + POISON, // &line[Poison] + MILD_POISON, // &line[MildPoison] BACK_GROUND // &line[Blank] } diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index c5edcaa..ccc7add 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -9,16 +9,13 @@ public class ThreadsController extends Thread { private final ArrayList> Squares; private final Tuple headSnakePos; - private int sizeSnake = 3; + private int sizeSnake = 4; private final long delay = 75; public static Direction directionSnake; - private final ArrayList positions = new ArrayList<>(); private Tuple foodPosition; // &line[Food] private Tuple poisonPosition; // &line[Poison] - - private Tuple poisonPosition2; // &line[Poison] - + private Tuple mildPoisonPosition; // &line[MildPoison] //Constructor of ControllerThread public ThreadsController(Tuple positionDepart) { @@ -40,9 +37,14 @@ public ThreadsController(Tuple positionDepart) { // &end[Food] // &begin[Poison] - foodPosition = new Tuple(Window.getWindowHeight() - 3, Window.getWindowWidth() - 3); - spawnFood(poisonPosition); // &line[Poison] + poisonPosition = new Tuple(Window.getWindowHeight() - 3, Window.getWindowWidth() - 3); + spawnFood(poisonPosition); // &line[Spawn] // &end[Poison] + + // &begin[MildPoison] + poisonPosition = new Tuple(Window.getWindowHeight() - 5, Window.getWindowWidth() - 5); + spawnFood(poisonPosition); // &line[Spawn] + // &end[MildPoison] } //Important part : @@ -78,6 +80,7 @@ private void checkCollision() { } } // &end[Collision] + // &begin[Food] boolean eatingFood = posCritique.getX() == foodPosition.y && posCritique.getY() == foodPosition.x; if (eatingFood) { @@ -94,12 +97,22 @@ private void checkCollision() { boolean eatingPoison = posCritique.getX() == poisonPosition.y && posCritique.getY() == poisonPosition.x; if (eatingPoison) { System.out.println("Ouch"); - sizeSnake = sizeSnake - 1; + sizeSnake = sizeSnake - 3; poisonPosition = getTileNotInSnake(); spawnPoison(poisonPosition); // &line[Spawn] } // &end[Poison] + + // &begin[MildPoison] + boolean eatingMildPoison = posCritique.getX() == mildPoisonPosition.y && posCritique.getY() == mildPoisonPosition.x; + if (eatingMildPoison) { + System.out.println("Mild Poison eaten"); + sizeSnake = sizeSnake - 1; + mildPoisonPosition = getTileNotInSnake(); + spawnMildPoison(mildPoisonPosition); // &line[Spawn] + } + // &end[MildPoison] } //Stops The Game @@ -118,14 +131,15 @@ private void stopTheGame(String s) { private void spawnFood(Tuple foodPositionIn) { Squares.get(foodPositionIn.x).get(foodPositionIn.y).lightMeUp(SquareToLightUp.FOOD); } - // &end[Spawn] - - // &begin[Spawn] private void spawnPoison(Tuple poisonPositionIn) { - Squares.get(poisonPositionIn.x).get(poisonPositionIn.y).lightMeUp(SquareToLightUp.FOOD); + Squares.get(poisonPositionIn.x).get(poisonPositionIn.y).lightMeUp(SquareToLightUp.POISON); + } + private void spawnMildPoison(Tuple mildPoisonPositionIn) { + Squares.get(mildPoisonPositionIn.x).get(mildPoisonPositionIn.y).lightMeUp(SquareToLightUp.MILD_POISON); } // &end[Spawn] + // &begin[Blank] //return a position not occupied by the snake private Tuple getTileNotInSnake() { From ca5785c12ce4902e611965df2c8a8545fe613662 Mon Sep 17 00:00:00 2001 From: Riman <95256096+RimanHoubbi@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:57:24 +0100 Subject: [PATCH 12/12] test change to a feature --- src/logic/ThreadsController.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/logic/ThreadsController.java b/src/logic/ThreadsController.java index ccc7add..42950b0 100644 --- a/src/logic/ThreadsController.java +++ b/src/logic/ThreadsController.java @@ -45,6 +45,12 @@ public ThreadsController(Tuple positionDepart) { poisonPosition = new Tuple(Window.getWindowHeight() - 5, Window.getWindowWidth() - 5); spawnFood(poisonPosition); // &line[Spawn] // &end[MildPoison] + + // &begin[MildPoison] + // test functionality + //code + // &end[MildPoison] + } //Important part :