Book Image

Learning Android Game Development

By : Nikhil Malankar
Book Image

Learning Android Game Development

By: Nikhil Malankar

Overview of this book

In this book, we’ll start with installing Android studio and its components, and setting it up ready for Android N. We teach you how to take inputs from users, create images and interact with them, and work with sprites to create animations. You’ll then explore the various collision detection methods and use sprites to create an explosion. Moving on, you’ll go through the process of UI creation and see how to create buttons as well as display the score and other parameters on screen. By the end of the book, you will have a working example and an understanding of a 2D platform game like Super Mario and know how to convert your 2D games to 3D games.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
4
Creating Sprites and Interactive Objects

Collision detection


To explain it simply, collision is a short duration interaction between two bodies. There are many different types of collisions such as elastic and non-elastic. The study of the intersection of two or more objects overlapping each other is called as collision detection. It is one of the most complex pieces of computational mathematics and is divided into many types, such as:

  • Bounding Box Collision: This is the simplest form of collision techniques wherein we take two rectangles and check for collision if they overlap each other. For this, we need four coordinates of each rectangle, namely, the x and y position and width and height of both rectangles.
  • Circle Collision: This is the second simplest type of collision wherein we test for collisions between two circles. Here, the radius of two circles and x and y position of the center of the circles are taken into account to test for overlapping.
  • Separating Axis Theorem: This type of collision is a bit more complex than the...