How to create a simple Android Game?
Hi, guys!! Today let's see how to build a simple game which I named it as RGB game. If you are new to Android App development I would suggest you go through my previous posts.
I am creating this simple game in Android Studio. It's easy Just follow the steps following. By the end, you are ready with a game. So let's go write the code.
So what is RGB color code?
The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors.An RGB color value is specified with rgb(red,green,blue)
Each parameter defines the intensity of the color as an integer between 0 to 255.
How this Android game works:
There are a total of 3 levels in this game. Easy, Medium & Hard levels. In easy level, there are 3 colors to guess from, 6 and 9 colors for the next colors respectively.
Hard Level |
Easy Level |
Medium Level |
In the hard level, you have 9 colors and you need to guess the correct one with the RGB color code shown on the top of the page.
So, if you want to try this even before going to the coding part, here is the link for apk download. Put this into your mobile if you are seeing this from PC, and mobile users can directly download this into the mobile and install it.
Let's get into coding part now:
First, we will create the project.
So, if you want to try this even before going to the coding part, here is the link for apk download. Put this into your mobile if you are seeing this from PC, and mobile users can directly download this into the mobile and install it.
Let's get into coding part now:
First, we will create the project.
Create a name for the project. I named it Guess RGB.
Select API:17 Jellybean as the minimum SDK for the app. So this is the version that a mobile should minimum have to run your app.
Select Empty activity.
Let the activity name and layout name be default as it is.
activity_main.xml file:
It consists of 3 linear layouts wherein each linear layout we have 3 Card Views and inside of the cards, we have buttons. We will show the layouts according to the level, 1 linear layout for easy level, 2 linear layouts for medium and 3 linear layouts for hard level.dialog_items.xml:
Model class:
The RGB class is a plain old java object(POJO) class. It consists of three double type variables r,g,b and getter and setters for them.
Now MainActivity.java:
That's it: you made an Android Game.
Thank you, Happy learning.
Comments
Post a Comment