O'Reilly logo

LibGDX Cross-Platform Development Blueprints by Indraneel Potnis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Whack-A-Mole

In this chapter, we are going to learn how to make a Whack-A-Mole style game. The objective of the game is to whack as many moles as possible. The moles come up and go down from the ground through holes. The user can tap on the moles to hit/whack them. The user gets points on whacking the moles and the points are displayed on the screen.

We will cover the following topics in this chapter:

  • Making the initial screen
  • Adding some color
  • Animating the mole
  • Adding randomness and taking inputs
  • Adding more effects
  • Keeping scores and adding sounds

Making the initial screen

We will implement a basic game screen with some moles.

Implementing the Mole class

We will set up a new project with the LibGDX setup, which is similar to the following: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required