|
|
|
@ -54,6 +54,7 @@ class Shape(val typeShape: TypeShape,var position: Position) {
|
|
|
|
|
|
|
|
|
|
return sharePosition
|
|
|
|
|
}
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
|
|
|
|
|
fun sharePositionUp(shape: Shape): MutableList<Position>{
|
|
|
|
|
val sharePosition = mutableListOf<Position>()
|
|
|
|
@ -71,5 +72,67 @@ class Shape(val typeShape: TypeShape,var position: Position) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sharePosition
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
fun sharePositionRotationRight(shape: Shape):Array<IntArray>{
|
|
|
|
|
var leftmostCol = 4
|
|
|
|
|
val rotatedMatrix = Array(4) { row ->
|
|
|
|
|
IntArray(4) { col ->
|
|
|
|
|
shape.typeShape.showShape[4 - col - 1][row]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Trouver l'index de la colonne la plus à gauche
|
|
|
|
|
for (row in 0 until 4) {
|
|
|
|
|
for (col in 0 until 4) {
|
|
|
|
|
if (rotatedMatrix[row][col] != 0 && col < leftmostCol) {
|
|
|
|
|
leftmostCol = col
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Décaler chaque ligne de la matrice vers la gauche
|
|
|
|
|
for (row in 0 until 4) {
|
|
|
|
|
for (col in 0 until leftmostCol) {
|
|
|
|
|
rotatedMatrix[row][col] = 0
|
|
|
|
|
}
|
|
|
|
|
for (col in leftmostCol until 4) {
|
|
|
|
|
rotatedMatrix[row][col - leftmostCol] = rotatedMatrix[row][col]
|
|
|
|
|
if ( col - leftmostCol != col){
|
|
|
|
|
rotatedMatrix[row][col] = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rotatedMatrix
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun sharePositionRotationLeft(shape: Shape):Array<IntArray>{
|
|
|
|
|
var leftmostCol = 4
|
|
|
|
|
// Pivoter la matrice
|
|
|
|
|
val rotatedMatrix = Array(4) { row ->
|
|
|
|
|
IntArray(4) { col ->
|
|
|
|
|
shape.typeShape.showShape[col][4 - row - 1]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Trouver l'index de la colonne la plus à gauche
|
|
|
|
|
for (row in 0 until 4) {
|
|
|
|
|
for (col in 0 until 4) {
|
|
|
|
|
if (rotatedMatrix[row][col] != 0 && col < leftmostCol) {
|
|
|
|
|
leftmostCol = col
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Décaler chaque ligne de la matrice vers la gauche
|
|
|
|
|
for (row in 0 until 4) {
|
|
|
|
|
for (col in 0 until leftmostCol) {
|
|
|
|
|
rotatedMatrix[row][col] = 0
|
|
|
|
|
}
|
|
|
|
|
for (col in leftmostCol until 4) {
|
|
|
|
|
rotatedMatrix[row][col - leftmostCol] = rotatedMatrix[row][col]
|
|
|
|
|
if ( col - leftmostCol != col){
|
|
|
|
|
rotatedMatrix[row][col] = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rotatedMatrix
|
|
|
|
|
>>>>>>> Enzo
|
|
|
|
|
}
|
|
|
|
|
}
|