|
|
@ -1,5 +1,8 @@
|
|
|
|
package but.androidstudio.tetris
|
|
|
|
package but.androidstudio.tetris
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
|
|
|
import android.hardware.Sensor
|
|
|
|
|
|
|
|
import android.hardware.SensorManager
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.util.Log
|
|
|
|
import android.util.Log
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
@ -10,16 +13,19 @@ import android.widget.Button
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
import kotlinx.coroutines.delay
|
|
|
|
import kotlinx.coroutines.delay
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
import androidx.core.content.ContextCompat.getSystemService
|
|
|
|
import modele.Game
|
|
|
|
import modele.Game
|
|
|
|
import views.ViewsGame
|
|
|
|
import views.ViewsGame
|
|
|
|
|
|
|
|
|
|
|
|
class GameFragment : Fragment() {
|
|
|
|
class GameFragment : Fragment(){
|
|
|
|
|
|
|
|
|
|
|
|
private val heightGame:Int = 15 // Line number
|
|
|
|
private val heightGame:Int = 15 // Line number
|
|
|
|
private val withGame:Int = 7 // Column number
|
|
|
|
private val withGame:Int = 7 // Column number
|
|
|
|
private lateinit var viewGame:ViewsGame
|
|
|
|
private lateinit var viewGame:ViewsGame
|
|
|
|
private lateinit var modeleGame:Game
|
|
|
|
private lateinit var modeleGame:Game
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lateinit var sensorManager: SensorManager
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -53,9 +59,13 @@ class GameFragment : Fragment() {
|
|
|
|
modeleGame.dashBoard.moveLeft(modeleGame.currentShape)
|
|
|
|
modeleGame.dashBoard.moveLeft(modeleGame.currentShape)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buttonRotateRight.setOnClickListener {
|
|
|
|
buttonRotateRight.setOnClickListener {
|
|
|
|
modeleGame.dashBoard.moveDown(modeleGame.currentShape)
|
|
|
|
modeleGame.dashBoard.rotateShapeRight(modeleGame.currentShape)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
buttonRotateLeft.setOnClickListener {
|
|
|
|
|
|
|
|
modeleGame.dashBoard.rotateShapeLeft(modeleGame.currentShape)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modeleGame.startGame()
|
|
|
|
modeleGame.startGame()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|