This project is focussed on creating a simple, fun, interactive brain training android game (using Java).
This project is focussed on creating a simple, fun, interactive brain training android game (using Java).
Android is a mobile operating system based on a modified version of the Linux kernel and some other open source softwares, designed primarily for touchscreen mobile devices such as smartphones and tablets. Android is developed by a consortium of developers known as the Open Handset Alliance and commercially sponsored by Google.
About 70 percent of Android smartphones run Google's ecosystem. Android was primarily built on Java (and Kotlin) language. Java is the best option when it comes to building core native android apps. Hence, here we will be using Java.
People spend hours at the gym, lifting weights, doing cardio exercises and following proper diets to keep their bodies physically fit. But what do people do to keep their brains in shape? Usually, when people are done at the gym they crash in front of a TV and put their brain into a passive mode where all the skills the mind has, i.e. memory, thinking and logical reasoning stagnates. Your brain is the most important part of your body and to not keep it fit is to invite laziness and lethargy into your life. Brain exercise is an approach to train the brain to perform at optimum levels and be sharp and strong even as old age acts to deteriorate your memory. In our daily life, we always feel stressed out. We exercise for the physical wellness of our body. But what do we actually do for the mental health? This game is like an exercise for the brain. Games of these kinds are categorically termed as cognitive games.
The game's walkthrough is shown below:
The app can also be found at the Amazon store. If you face some issue with the Amazon store, you can download Bfit_2.32
from here instead.
So do try the app first!!
The project can be broadly classified into 4 sections:-
Each of these stages are covered in detailed multiple milestones ahead.
This is an android app adaptation of the brainmetrix.
This project is focussed on creating a simple, fun, interactive brain training android game (using Java).
Android is a mobile operating system based on a modified version of the Linux kernel and some other open source softwares, designed primarily for touchscreen mobile devices such as smartphones and tablets. Android is developed by a consortium of developers known as the Open Handset Alliance and commercially sponsored by Google.
About 70 percent of Android smartphones run Google's ecosystem. Android was primarily built on Java (and Kotlin) language. Java is the best option when it comes to building core native android apps. Hence, here we will be using Java.
People spend hours at the gym, lifting weights, doing cardio exercises and following proper diets to keep their bodies physically fit. But what do people do to keep their brains in shape? Usually, when people are done at the gym they crash in front of a TV and put their brain into a passive mode where all the skills the mind has, i.e. memory, thinking and logical reasoning stagnates. Your brain is the most important part of your body and to not keep it fit is to invite laziness and lethargy into your life. Brain exercise is an approach to train the brain to perform at optimum levels and be sharp and strong even as old age acts to deteriorate your memory. In our daily life, we always feel stressed out. We exercise for the physical wellness of our body. But what do we actually do for the mental health? This game is like an exercise for the brain. Games of these kinds are categorically termed as cognitive games.
The game's walkthrough is shown below:
The app can also be found at the Amazon store. If you face some issue with the Amazon store, you can download Bfit_2.32
from here instead.
So do try the app first!!
The project can be broadly classified into 4 sections:-
Each of these stages are covered in detailed multiple milestones ahead.
This is an android app adaptation of the brainmetrix.
First you need to set up the development environment for the android. For this, you need to install Android Studio, Java 8 or higher.
Check the version of java to know whether you have successfully installed it or not-
java -version
Congratulations!!! Your initial set up is done!
You should be able to set up the initial development environment required to develop the game.
This milestone can be primarily utilised to get familiarised with Android Studio.
Basic knowledge of Java, XML is recommended prior to starting this task.
res
folder and create a file with activity_main.xml
that will contain code for UI of the Game. <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:onClick="runme"
android:text="click me to run"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:id="@+id/twview"
android:hint="your score"
android:layout_height="wrap_content" />
</LinearLayout>
Now it's time to implement the logic. Here we have to create a multithreading algorithm such that when we click the start button it will randomly flash multiple blocks with green light one by one, that we have earlier created. The user must click consecutive blocks within that time framework. If the user misses the block or clicked (touched) the wrong block then the block the user touches must become red temporarily. Please see the references for a better understanding. After 60 seconds we have to show the result to the users, i.e. how many the user had missed and how many were clicked correctly.
Create a class MainActivity in src by extending AppCompatActivity class. This AppCompatActivity class provides a method called onCreate() that is used when our activity or particular screens start.
Override the onCreate() method here we have to write all logic that has to perform when our activity has been created. Here we have to set our view by the setContentView() method. We have to give ID to all the buttons in continuous order to track them.
Create integer buttonNumber to , score, and create an array of Button class to store id of these buttons.
Create runme() method
Create check() method
Creating levels of difficulties for the game
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
buttons[finalN].setBackgroundColor(Color.GREEN);
}
});
}
});
}
How do you match the id of the boxes (/grid buttons)? No idea? Think harder :p
Please refer to the walkthrough of the game again.
Now our game is almost completed. But when a new user starts using the app, the user should ideally be given a quick tour of the app's functionalities. Now we are creating the walkthrough or Guided Tour to introduce first-time users to our app. Here we use ShowcaseView gradle library for this purpose. Using this library you can keep indicating what each button does and what all the app's major features are.
A simple example of the Showcase Builder pattern that you may use is given below. You can find various other methods in the ShowcaseView library or you can choose alternative libraries as an option.
new ShowcaseView.Builder(this)
.setTarget(new ActionViewTarget(this, ActionViewTarget.Type.HOME))
.setContentTitle("ShowcaseView")
.setContentText("This is highlighting the Home button")
.hideOnTouchOutside()
.build();
Here setTarget() and build() are mandatory. By setTarget() you have to choose where you have to use showCase.
How to chain multiple showCase views?
We can choose addView() in showcase Builder to run multiple Showcase view one after one.
How will the app know that you are using your app for the first time?
The SharedPreferences is the answer. By SharedPreferences, we can store and retrieve small amounts of primitive data. It can be thought of as a dictionary or a key/value pair.
Where should we check SharedPreferences value?
The onCreate() method which we had overridden from AppCompatActivity is the correct place to check. As we know the onCreate() method runs when our Activity instance is run. If we run our app for the first time it checks the value from our SharedPreferences and then later decides that we have to show the walkthrough or not.
A splash screen is mostly the first screen of the app when it is opened. It is a constant screen that appears for a specific amount of time, generally shows for the first time when the app is launched. The Splash screen is used to display some basic introductory information such as the company logo, content, etc just before the app loads completely.
Thread myThread = new Thread(){
@Override
public void run() {
try {
sleep(3000);
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
For game applications to be consumable by the end-users (public) we have to create a release-ready package. An optional step before building your app for release is obfuscating your code. Obfuscation hides functions and classes used in the Android code to provide security against reverse engineering attempts on the app.
Your app is now ready to be rolled out onto the Play Store.