pull/10/head
Alexis1663 2 years ago
parent 7807fae158
commit 8fc415f548

@ -11,36 +11,6 @@
android:supportsRtl="true"
android:theme="@style/Theme.Tetris"
tools:targetApi="31">
<activity
android:name="tetrisGame.activity.Menu"
android:exported="true"/>
<activity
android:name="tetrisGame.activity.Game"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="activity.Menu" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="activity.Game" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="activity.Option" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="activity.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -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<ViewsGame>(R.id.tabGame)
//To clean the window
view.invalidate()
val game: Game = Game(10,20,view)
game.startGame()
}
}

@ -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<Array<Int>> = 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")
}
}

@ -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<Array<Int>>()
fun setCoordinateTable(table: Array<Array<Int>>){
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<Array<Int>>()
for (i in 0 until nbCaseHauteur) {
var array = arrayOf<Int>()
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)

@ -15,7 +15,8 @@
<FrameLayout
android:layout_width="250dp"
android:layout_height="450dp">
android:layout_height="450dp"
android:layout_gravity="center">
<views.ViewsGame
android:id="@+id/tabGame"

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainFragment">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
@ -19,21 +19,32 @@
<TextView
android:id="@+id/appName"
android:gravity="center"
android:textSize="@android:dimen/app_icon_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
android:text="Tetris"/>
<Button
android:id="@+id/buttonStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/buttonOption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Options" />
<Button
android:id="@+id/buttonStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start" />
<Button
android:id="@+id/buttonOption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Options" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"

Loading…
Cancel
Save