Learning How To Programing a Simple Android Game



Click to watch


Learning How To Programing a Simple Android Game






It is difficult for beginners (you and me) to be able to create a simple game for ourselves. We wish that if there is a simple game that could see it as a template for us accordingly to start programming. And this is source code of first Android game called "Strawberry" (like Mario game) that I bought on http://codecanyon.net. In the future if possible I will bought more complex new games. To ensure copyright, we will not copy the source code from the author, instead will adjust to suit our purposes. The most important thing each opinion to discuss of us to help build something better, or at least experience to developing games for beginners.




I will begin from ".../src/..." folder where contains one or many packages and inside them have one or many source code files with file extension .java (I believe). In this game, I see have only a package "com.oldenweb.Strawberry". However, in naming the package does not seem to comply the rules. And this is first problem we may be interested in.

More details in http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html and http://stackoverflow.com/questions/12041857/what-is-the-rule-of-the-name-of-the-packages-that-start-with-number. In fact, there are many other issues related to the package that we need to ask. What is a Package? Why do we have to use them? They have meaning how? so on.

Next, in package "com.oldenweb.Strawberry" only contains a "Main.java" file.


package com.oldenweb.Strawberry;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.AssetFileDescriptor;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.AnimationDrawable;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.net.ConnectivityManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.TypedValue;
import android.view.View;
import android.view.View.OnSystemUiVisibilityChangeListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.games.Games;
import com.google.android.gms.games.GamesStatusCodes;
import com.google.android.gms.games.leaderboard.LeaderboardVariant;
import com.google.android.gms.games.leaderboard.Leaderboards;
import com.google.example.games.basegameutils.BaseGameActivity;




Here (I call them) is beginning part inside "Main.java" file. Except for the first line is considered as the package we have named. All remaining lines begin "import" keyword. With a similar structure as package "com.oldenweb.Strawberry" proves they are the other package containing the different files in it.





To be continued...

We need to learn Data Structures & Algorithms. Why we have to learn it ?
Share on Google Plus

About Unknown

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment