Library

Course: Android Game Development for Beginners

Android Game Development for Beginners

  • Life Time Access
  • Certificate on Completion
  • Access on Android and iOS App
  • Self-Paced
About this Course

Hi, and welcome to my course Android Game Development for Beginners. I am Sandip, and I’ll be guiding you through the process of creating your very own Android games, using Android Studio and Java. Sound exciting? Let’s get started.


This course will introduce some key elements of game programming. And I believe, the best way to learn game programming is by making one. So, I will walk you through the process of creating an android game, from start to finish, step by step in a completely hands-on fashion, sharing some super useful resources along the way. As we move on, we will be creating a small but complete game called “Plane Shooter”. I'll show you exactly how to Create Levels for your game in the easiest way possible. Not only that, I'll show you how to monetize your app through Google AdMob Banner and Interstitial ad so that you can start getting some revenue. This course will improve your problem-solving ability as I invite you to find the solution yourself so that you can think like a programmer. I will also be available to support you along the way.


You may be motivated to make your own games that others would love to play or may be motivated by the money you can make if your game becomes very popular and in-demand or you are passionate about the gaming industry and decided to start your career as a game developer. Whatever your motivation, you need to have a solid knowledge of game programming and the skills required to make your Android game a reality. A game that you build yourself, and publish is a fantastic resume piece and could help you get a great job you might not otherwise be able to get. Even if you don't plan on doing the actual coding itself, it may be important to know at least the basics of Java which is the preferred language for Android game development. 


Why Android? Because you will find the android to have a larger amount of players available. Many smartphones and tablets use Google Play Store as well as the Amazon Store which is android based. Getting your app to big success is greatly dependent upon its exposure. Putting it in the Android mainstream market is one way to get it to #1.


So what you are waiting for? Join me on this exciting and rewarding journey to become a game developer. Enroll today!

Basic knowledge
  • You should have Android Studio installed.
  • Some basic programming experience like variable, if-else, loop, method
What you will learn
  • You'll be able to build a complete 2D game in less than 3 hours.
  • You'll have a clear understanding of the core concepts behind a 2D game.
  • You'll be able to brush-up your Java skills.
  • Monetize your app through Google Admob and start getting some revenue.
Curriculum
Number of Lectures: 22
Total Duration: 02:28:14
Introduction
  • Introduction to the Course  
  • Important Update: Must read before you proceed!  

    In this course, I used Android Studio version 2.3.3 which was the latest version when I created this course. The current version is 3.4.1 released in May 2019.

    Here are some minor actions you need to take only in two lectures related to designing the XML Layout, if you're using the latest version of Android Studio, to follow along with the course. Rest of the code, including Java, works just fine as before.

    1. Section 2, lecture titled "Create the Project":

    a) I drag and dropped an ImageButton from "Images" group under Palette. In Studio 3.4.1 ImageButton can be dragged from "Buttons" group under Palette. While dragging the ImageButton we used to see two dotted lines, with an orange dotted rectangle at the center, indicating it's the center of the layout. In the latest Android Studio, we don't get these indications while working with RelativeLayout. We can easily solve this issue by writing just two lines inside ImageButton (which used to be auto-generated):

    android:layout_centerHorizontal="true"

    android:layout_centerVertical="true"

    b) TextView was dragged from "All" group under Palette. Now, it can be dragged from "Common" or "Text" group under Palette. Previously, TextView could be dropped just below the ImageButton. Now, if you try to drag and drop a TextView below the ImageButton, it will automatically be placed at the top-left of the layout. We can simply solve this issue by writing just three lines inside TextView:

    android:layout_below="@+id/imageButton"

    android:layout_centerHorizontal="true"

    android:layout_marginTop="12dp"

    c) We clicked the 3-dots after textColor from "Properties" window, which caused the Resources window to pop-up. We clicked Color group and selected "holo_red_dark". Now, the name of the "Properties" window is "Attributes". We can see that a default color is selected after textColor. We can click the small vertical bar next to it which causes the Resources window to pop-up. There, you can expand "Android" group and select "holo_red_dark".

    d) Inside StartGame class, if you override onCreate() in latest Android Studio, you'll see an optional Annotation (@androidx.annotation.Nullable) in the parameter. Just remove that since it's not required.

    2. Section 8, lecture titled "Design the GameOver screen":

    a) In GameOver class, in the onCreate() parameter, delete the optional Annotation (@androidx.annotation.Nullable) as well.

    b) While designing the game_over.xml add these 3 lines for the left button (Restart) which used to be auto-generated:

    android:layout_alignParentLeft="true"

    android:layout_alignParentStart="true"

    android:layout_alignParentTop="true"

    and,

    c) For the right button (Exit):

    android:layout_alignParentEnd="true"

    android:layout_alignParentRight="true"

    android:layout_alignParentTop="true"

    d) for LinearLayout(vertical) add these lines:

    android:layout_centerHorizontal="true"

    android:layout_centerVertical="true"


    That's it. Hope that helps. Happy learning!

Creating a project in Android Studio
  • Create the Project  
  • Game Resource  

    I have uploaded the full project source code (with Admob integration) here. 

    You can also download the same project (without Admob) here.


    Here are some useful sites for you to download game assets.

    1. OpenGameArt

    2. GameArt2D

    3. Kenney

    4. Craftpix


    My image dimensions are as follows:

    Background: 320 x 438 pixels

    Plane 1: 126 x 74

    Plane 2: 126 x 64

    Missile: 10 x 50

    Explosion: 80 x 125

    Play: 100 x 100

    GameOver: 180 x 113

    Cannon: 100 x 160

Frame-by-Frame Animation
  • Frame-by-Frame Animation - A high-level overview  
  • Set a background image for Canvas  
  • Make the background image fully fit the Canvas  
  • Make the Plane move  
Object Oriented Animation Technique
  • Do it Object Oriented way  
  • Add another plane  
More Development
  • Draw the tank  
  • Get Touch Event  
  • Fire the Missiles when tank is touched  
Collision Detection
  • Collision detection  
Add more fun
  • Add sound  
  • Add score  
  • Add health indicator  
  • Create cool explosion effect  
GameOver
  • Design the GameOver screen  
  • It's GameOver  
  • Idea for Creating Level  

    You can implement different levels for your game in a number of ways. In this lecture, I'll guide you step-by-step for creating levels and add features like switching the scene and increasing the speed of the Planes for every succeeding level, in the easiest way possible. Just use if/else condition in your code. Lets dive into that. Open the full project in Android Studio. You can download the initial project (without level) from Section 2: Lecture 4, titled "Game Resource" or directly from here. Next, follow these steps.

    1. If you want to use total three background images for three levels, create two more background image (preferably) with same dimension(320 x 438 pixels) and copy them into drawable folder in Android Studio.

    2. Declare two more Bitmap objects in GameView.

    Bitmap background2, background3;

    3. In the constructor, initialize those objects.

    background2 = BitmapFactory.decodeResource(getResources(), R.drawable.background2);
    background3 = BitmapFactory.decodeResource(getResources(), R.drawable.background3);
    

    4. Define a static integer variable in GameView, call it "level" and initially set it to 1.

    static int level = 1;

    5. Inside GameView > onDraw() use your own logic to change the level. For example:

    if (count > 10 && count < 21) {
    	level = 2;
    } else if (count >= 21) {
    	level = 3;
    }
    

    6. Modify the code for drawing background Bitmaps based on level.

    if (level == 1) {
    	canvas.drawBitmap(background, null, rect, null);
    } else if (level == 2) {
    	canvas.drawBitmap(background2, null, rect, null);
    } else if (level == 3) {
    	canvas.drawBitmap(background3, null, rect, null);
    }
    

    7. Speed of the planes can be increased by changing velocity property based on level, in Plane and Plane2 class.

    Inside Plane > resetPosition() , use your own logic to change the speed. For example:

    if (GameView.level == 1) {
        velocity = 8 + random.nextInt(13);
    } else if (GameView.level == 2) {
        velocity = 13 + random.nextInt(13);
    } else if (GameView.level == 3) {
        velocity = 18 + random.nextInt(13);
    }
    

    8. Inside Plane2 > resetPosition() , may be use some other logic to change the speed. For example:

    if (GameView.level == 1) {
        velocity = 5 + random.nextInt(21);
    } else if (GameView.level == 2) {
        velocity = 10 + random.nextInt(21);
    } else if (GameView.level == 3) {
        velocity = 15 + random.nextInt(13);
    }
    

    9. Run the project to check the output. You can also download the finished project from here.


    Hope that helps. Now, you can use your own imagination to achieve things you want in your game. Good luck!

  • Monetize your app with Admob  

    Download the tutorial (PDF) from here.


    This tutorial shows you how to monetize your app with Google AdMob through Banner and Interstitial ads so that you can start getting some revenue.

    This guide is for publishers who want to monetize an Android app with AdMob and aren't using Firebase. For simplicity, I am not using Firebase.


    Prerequisites

    • Use Android Studio 1.0 or higher
    • Target Android API level 14 or higher
    • Recommended: Create a Google AdMob account and register an app.


Course Wrap-Up
Reviews (0)