From 7b52be7c56edaebc70a4a972b0f2d85f46f87f7b Mon Sep 17 00:00:00 2001 From: Jolys Enzo Date: Wed, 5 Apr 2023 08:16:06 +0200 Subject: [PATCH] correction bug --- Tetris/app/src/main/java/modele/DashBoard.kt | 2 -- Tetris/app/src/main/java/modele/Shape.kt | 24 +++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Tetris/app/src/main/java/modele/DashBoard.kt b/Tetris/app/src/main/java/modele/DashBoard.kt index e376a92..2025ba2 100644 --- a/Tetris/app/src/main/java/modele/DashBoard.kt +++ b/Tetris/app/src/main/java/modele/DashBoard.kt @@ -217,8 +217,6 @@ class DashBoard(private val width: Int,private val height: Int,private val view: // Write the shape in gridOfGame private fun writeShape(shape: Shape){ - println("Final X : "+shape.position.x) - println("Final Y : "+shape.position.y) for (line in 0..3) { for (column in 0..3) { diff --git a/Tetris/app/src/main/java/modele/Shape.kt b/Tetris/app/src/main/java/modele/Shape.kt index 464f509..e9c5a84 100644 --- a/Tetris/app/src/main/java/modele/Shape.kt +++ b/Tetris/app/src/main/java/modele/Shape.kt @@ -54,25 +54,24 @@ class Shape(val typeShape: TypeShape,var position: Position) { return sharePosition } -<<<<<<< HEAD - fun sharePositionUp(shape: Shape): MutableList{ + fun sharePositionUp(shape: Shape): MutableList { val sharePosition = mutableListOf() - for( line in 0..3){ + for (line in 0..3) { for (column in 0..3) { - if ( line != 3 ){ - if ( (typeShape.showShape[line][column] == 1) and (typeShape.showShape[line+1][column] == 0)){ - sharePosition.add(Position(column,line)) + if (line != 3) { + if ((typeShape.showShape[line][column] == 1) and (typeShape.showShape[line + 1][column] == 0)) { + sharePosition.add(Position(column, line)) } } - if ( (line == 3) and (typeShape.showShape[line][column] == 1) ){ - sharePosition.add(Position(column,line)) + if ((line == 3) and (typeShape.showShape[line][column] == 1)) { + sharePosition.add(Position(column, line)) } } } - return sharePosition -======= + } + fun sharePositionRotationRight(shape: Shape):Array{ var leftmostCol = 4 @@ -104,7 +103,7 @@ class Shape(val typeShape: TypeShape,var position: Position) { return rotatedMatrix } - fun sharePositionRotationLeft(shape: Shape):Array{ + fun sharePositionRotationLeft(shape: Shape):Array { var leftmostCol = 4 // Pivoter la matrice val rotatedMatrix = Array(4) { row -> @@ -127,12 +126,11 @@ class Shape(val typeShape: TypeShape,var position: Position) { } for (col in leftmostCol until 4) { rotatedMatrix[row][col - leftmostCol] = rotatedMatrix[row][col] - if ( col - leftmostCol != col){ + if (col - leftmostCol != col) { rotatedMatrix[row][col] = 0 } } } return rotatedMatrix ->>>>>>> Enzo } } \ No newline at end of file