diff --git a/Tetris/app/src/main/AndroidManifest.xml b/Tetris/app/src/main/AndroidManifest.xml index 51d0ed1..d884f48 100644 --- a/Tetris/app/src/main/AndroidManifest.xml +++ b/Tetris/app/src/main/AndroidManifest.xml @@ -11,36 +11,6 @@ android:supportsRtl="true" android:theme="@style/Theme.Tetris" tools:targetApi="31"> - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tetris/app/src/main/java/but/androidstudio/tetris/GameFragment.kt b/Tetris/app/src/main/java/but/androidstudio/tetris/GameFragment.kt index 1a4232c..8deddf0 100644 --- a/Tetris/app/src/main/java/but/androidstudio/tetris/GameFragment.kt +++ b/Tetris/app/src/main/java/but/androidstudio/tetris/GameFragment.kt @@ -5,6 +5,9 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import modele.Game import views.ViewsGame class GameFragment : Fragment() { @@ -24,8 +27,7 @@ class GameFragment : Fragment() { super.onViewCreated(view, savedInstanceState) val view = view.findViewById(R.id.tabGame) - - //To clean the window - view.invalidate() + val game: Game = Game(10,20,view) + game.startGame() } } \ No newline at end of file diff --git a/Tetris/app/src/main/java/modele/Game.kt b/Tetris/app/src/main/java/modele/Game.kt index d7d0b9d..b550eab 100644 --- a/Tetris/app/src/main/java/modele/Game.kt +++ b/Tetris/app/src/main/java/modele/Game.kt @@ -1,7 +1,16 @@ package modele -class Game(private val width: Int,private val height: Int) { + +import android.util.Log +import but.androidstudio.tetris.R +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import views.ViewsGame + +class Game(private val width: Int,private val height: Int,private val viewsGame: ViewsGame) { private val dashBoard: DashBoard = DashBoard(width,height) private var currentShape: Shape? = null + private var table: Array> = arrayOf(arrayOf()) + private var difficulty: Difficulty = Difficulty.EASY // To get the current difficulty @@ -18,8 +27,9 @@ class Game(private val width: Int,private val height: Int) { // The start game function fun startGame(){ - //this.setCurrentShape(TypeShape.SquareShape) + Log.d("toto","toto") + Log.d("toto","toto404") } } \ No newline at end of file diff --git a/Tetris/app/src/main/java/views/ViewsGame.kt b/Tetris/app/src/main/java/views/ViewsGame.kt index c7d2549..7c9519c 100644 --- a/Tetris/app/src/main/java/views/ViewsGame.kt +++ b/Tetris/app/src/main/java/views/ViewsGame.kt @@ -7,9 +7,14 @@ import android.graphics.Paint import android.util.AttributeSet import android.view.View -class ViewsGame(context:Context, attrs: AttributeSet?) : View(context, attrs) { +class ViewsGame(context:Context, attrs: AttributeSet?) : View(context, attrs) { val myPaint:Paint = Paint() + var tableau = arrayOf>() + + fun setCoordinateTable(table: Array>){ + this.tableau = table + } override fun onDraw(canvas: Canvas) { super.onDraw(canvas) @@ -21,7 +26,6 @@ class ViewsGame(context:Context, attrs: AttributeSet?) : View(context, attrs) { val nbCaseHauteur:Int = 15 // Pour remplir le tableau de zero ( a enlever) - var tableau = arrayOf>() for (i in 0 until nbCaseHauteur) { var array = arrayOf() for (j in 0 until nbCaseLargeur) { @@ -30,7 +34,7 @@ class ViewsGame(context:Context, attrs: AttributeSet?) : View(context, attrs) { tableau += array } - // Test + /*// Test // Droite tableau[0][0] = 1 tableau[1][0] = 1 @@ -65,7 +69,7 @@ class ViewsGame(context:Context, attrs: AttributeSet?) : View(context, attrs) { tableau[6][3] = 7 tableau[6][4] = 7 tableau[7][4] = 7 - tableau[7][5] = 7 + tableau[7][5] = 7*/ myPaint.color = Color.GRAY canvas.drawRect(0F,0F,tailleTableauLargeur,tailleTableauHauteur,myPaint) diff --git a/Tetris/app/src/main/res/layout/fragment_game.xml b/Tetris/app/src/main/res/layout/fragment_game.xml index c33fcb0..4940f57 100644 --- a/Tetris/app/src/main/res/layout/fragment_game.xml +++ b/Tetris/app/src/main/res/layout/fragment_game.xml @@ -15,7 +15,8 @@ + android:layout_height="450dp" + android:layout_gravity="center"> + android:text="Tetris"/> -