This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
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" | |
android:padding="16dp" | |
tools:context=".MainActivity"> | |
<RelativeLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onClick(v: View) { | |
if(curState == state.finish) | |
return | |
when(v.id){ | |
R.id.btn_rock->{ | |
img_mc.setImageResource(R.drawable.ic_rock) | |
cekAnswer(type.rock) | |
} | |
R.id.btn_paper->{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface GameState { | |
fun onStartEngine() | |
fun onUpdate(time:Long) | |
fun onFinish() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GameEngine { | |
// time length 20 s | |
val TIME_UNIT: Long = 21000 | |
var timer:CountDownTimer? = null | |
fun init(state: GameState){ | |
state.onStartEngine() | |
// interval 1 s | |
timer = object : CountDownTimer(TIME_UNIT, 1000){ |