A.I, Data and Software Engineering

Break your nails with TIMER BOMB DEFUSAL game

B

Are you fast and durable enough to defuse a deadly bomb? Let try to create the bomb defusal game with Android Studio and Kotlin! Video tutorial is at the end of the post.

The mechanic

Players need to click as fast as they can to beat the speed of the timer bomb. When the progress goes down to 0, the bomb will be disabled. In contrast, if it reaches the full bar, the bomb will explode, and it will be a very sad day for the player.

The UI

It is a simple design with 3 widgets:

  • An image view
  • A progress bar
  • A start button

The XML should look similar to this:

The background music

This is optional. However, games should always include music. We will create a flexible service that can change music based on the resource id. The media player is preferable to play longer music files.

Progressbar Animation

We animate the progress bar when players start the game. And change the colour from Green to Red using a RGB colour filter. The colour will vary based on the value of the current progress.

The main activity

We wire up all logics to this class. It should be able to handle the progress bar and also user click. Therefore, we implement two interfaces, i.e, AnimationListener, View.OnClickListener.

Don’t forget to register the listener to corresponding component. For example, we can register the bomb or the parent view to receive the click and the progresss bar to monitor the animation.

We may need to consider the reset method to put everything in their initial state.

Nevertheless, the most important part is how to control user interaction, especially when they click the bomb continuously. We need to reduce the progress by some value and update the animation accordingly.

Finally, we can make the decision when animation finished, i.e, when the progress reach 0 or full bar.

Video tutorial

Enjoy the 10 minute video tutorial for the bomb defusal game implementation.

Other useful links

Add comment

A.I, Data and Software Engineering

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.

Pin It on Pinterest

Newsletters

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Petaminds will use the information you provide on this form to be in touch with you and to provide updates.