Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Restart the Game

This video was last updated on Jul 14 2022

Learn to build the “Restart Game” feature which is triggered whenever the start over button is clicked.


Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

For the next item on our nice to haves on our programming todo list, you’ll add the ability for the player to restart the game. To do this, we’re going to need a new method we can call to restart the game. Let’s go implement this functionality now.

private fun startNewGame() {
totalScore = 0
currentRound = 1
sliderValue = 50
targetValue = Random.nextInt(1, 100)
binding.gameScoreTextView?.text = totalScore.toString()
binding.gameRoundTextView?.text = currentRound.toString()
binding.targetTextView.text = targetValue.toString()
binding.seekBar.progress = sliderValue
private fun newTargetValue() = Random.nextInt(1, 100)
binding.startOverButton?.setOnClickListener {