correction bug

pull/9/head
Jolys Enzo 2 years ago
parent bbc903e116
commit 7b52be7c56

@ -217,8 +217,6 @@ class DashBoard(private val width: Int,private val height: Int,private val view:
// Write the shape in gridOfGame // Write the shape in gridOfGame
private fun writeShape(shape: Shape){ private fun writeShape(shape: Shape){
println("Final X : "+shape.position.x)
println("Final Y : "+shape.position.y)
for (line in 0..3) { for (line in 0..3) {
for (column in 0..3) { for (column in 0..3) {

@ -54,25 +54,24 @@ class Shape(val typeShape: TypeShape,var position: Position) {
return sharePosition return sharePosition
} }
<<<<<<< HEAD
fun sharePositionUp(shape: Shape): MutableList<Position>{ fun sharePositionUp(shape: Shape): MutableList<Position> {
val sharePosition = mutableListOf<Position>() val sharePosition = mutableListOf<Position>()
for( line in 0..3){ for (line in 0..3) {
for (column in 0..3) { for (column in 0..3) {
if ( line != 3 ){ if (line != 3) {
if ( (typeShape.showShape[line][column] == 1) and (typeShape.showShape[line+1][column] == 0)){ if ((typeShape.showShape[line][column] == 1) and (typeShape.showShape[line + 1][column] == 0)) {
sharePosition.add(Position(column,line)) sharePosition.add(Position(column, line))
} }
} }
if ( (line == 3) and (typeShape.showShape[line][column] == 1) ){ if ((line == 3) and (typeShape.showShape[line][column] == 1)) {
sharePosition.add(Position(column,line)) sharePosition.add(Position(column, line))
} }
} }
} }
return sharePosition return sharePosition
======= }
fun sharePositionRotationRight(shape: Shape):Array<IntArray>{ fun sharePositionRotationRight(shape: Shape):Array<IntArray>{
var leftmostCol = 4 var leftmostCol = 4
@ -104,7 +103,7 @@ class Shape(val typeShape: TypeShape,var position: Position) {
return rotatedMatrix return rotatedMatrix
} }
fun sharePositionRotationLeft(shape: Shape):Array<IntArray>{ fun sharePositionRotationLeft(shape: Shape):Array<IntArray> {
var leftmostCol = 4 var leftmostCol = 4
// Pivoter la matrice // Pivoter la matrice
val rotatedMatrix = Array(4) { row -> val rotatedMatrix = Array(4) { row ->
@ -127,12 +126,11 @@ class Shape(val typeShape: TypeShape,var position: Position) {
} }
for (col in leftmostCol until 4) { for (col in leftmostCol until 4) {
rotatedMatrix[row][col - leftmostCol] = rotatedMatrix[row][col] rotatedMatrix[row][col - leftmostCol] = rotatedMatrix[row][col]
if ( col - leftmostCol != col){ if (col - leftmostCol != col) {
rotatedMatrix[row][col] = 0 rotatedMatrix[row][col] = 0
} }
} }
} }
return rotatedMatrix return rotatedMatrix
>>>>>>> Enzo
} }
} }
Loading…
Cancel
Save