Kill them all game, Android SDK, Java, Eclipse



Here is an Android game I built after watching a series of tutorials, which you can find here

There tutorials are by edu4java
Here is her channel.
http://www.youtube.com/user/edu4java?feature=watch

I am currently adding more functionality to this game such as splash screen, HUD, High Score Board ect..

This is built in the Eclipse IDE, using the Java and the Eclipse Emulator.

source

6 thoughts on “Kill them all game, Android SDK, Java, Eclipse

  • July 17, 2017 at 8:33 pm
    Permalink

    package com.example.killthemall;
    import java.util.ArrayList;
    import java.util.List;
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Paint;
    import android.graphics.Paint.Style;
    import android.media.MediaPlayer;
    import android.view.Gravity;
    import android.view.MotionEvent;
    import android.view.SurfaceHolder;
    import android.view.SurfaceHolder.Callback;
    import android.view.SurfaceView;
    import android.widget.Toast;

    //local variables
    public class GameView extends SurfaceView
    {
        private int  time = 0;
        private long startTime = System.currentTimeMillis();
    // Each state should have a function
    // I will not be posting all of the code
        private static final int INITAL = 0;
        private static final int SPLASH = 1;
        private static final int RUN = 2;
        private static final int SCORE = 3;
    }

    //helper function to get time that has passed
    private void getTickCount(long StartTime)
     {
    // subtract the StartTime from the current time
            long currentMillisec = System.currentTimeMillis() – StartTime;
    //casting
            int temp = (int)(-currentMillisec / 1000);
            time = (int) (currentMillisec / 1000);
            
            //De-increment score per second and create the total score
            score = temp + bad + good + 100;

        }

    //**********DRAW_EVENTS******************************
        @Override
        protected void onDraw(Canvas canvas)
       {
    //**********GAME_RUN******************************            
          if (gameState == RUN)
            {
                //Start the timer and score
                getTickCount(startTime);
                
                //Create the paint for the score
                Paint paintS = new Paint();
                paintS.setColor(Color.BLACK);
                paintS.setStyle(Style.FILL);
                
                //create the HUD
                Bitmap bmpHUD = BitmapFactory.decodeResource(getResources(), R.drawable.hud);
                canvas.drawColor(Color.BLACK);
                canvas.drawBitmap(bmpHUD, 20, 10, null);
                
                //Draw the score
                canvas.drawText(String.valueOf(score), 80, 26, paintS);
                canvas.drawText(String.valueOf(time), 250, 26, paintS);

                //Draw blood
                for (int i = temps.size() – 1; i >= 0; i–)
                {
                    temps.get(i).onDraw(canvas);
                }
                
                //Draw sprites
                for (Sprite sprite : sprites)
                {
                    sprite.onDraw(canvas);
                }
            }

    if (gameState ==  SCORE)
            {
                if (state3)
                {
                    //song.pause();
                    applause.start();
                    state3 = false;
                }
                
                //Create the paint for the score
                Paint paintHS = new Paint();
                paintHS.setColor(Color.RED);
                paintHS.setStyle(Style.FILL);
                
                
                Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.score);
                canvas.drawColor(Color.BLACK);
                canvas.drawBitmap(background, 10, 10, null);
                
                //I did not complete this part but
               // all you would have to do is change the values to variables
              // which would be loaded in from some sort of file.
            // look into saving and loading files

                //Score 1
                canvas.drawText("JNL", 95, 70, paintHS);
                canvas.drawText(String.valueOf(score), 185, 70, paintHS);
                //Score 2
                canvas.drawText("JNL", 95, 125, paintHS);
                canvas.drawText(String.valueOf(66), 185, 125, paintHS);
                //Score 3
                canvas.drawText("KML", 95, 182, paintHS);
                canvas.drawText(String.valueOf(53), 185, 182, paintHS);
                //Score 4
                canvas.drawText("JML", 95, 240, paintHS);
                canvas.drawText(String.valueOf(33), 185, 240, paintHS);
                //Score 5
                canvas.drawText("EZ", 95, 298, paintHS);
                canvas.drawText(String.valueOf(28), 185, 298, paintHS);
                //Score 6
                canvas.drawText("NIK", 95, 356, paintHS);
                canvas.drawText(String.valueOf(19), 185, 356, paintHS);
            }

    Reply
  • July 17, 2017 at 8:33 pm
    Permalink

    Is it possible to get the code for the score, play and timer today. Would be greatly appreciated as I am doing this for a project and after days of trying to figure it out I am out of time. Thanks KenRuddell@yahoo.com Have a great summer.

    Reply
  • July 17, 2017 at 8:33 pm
    Permalink

    hey can you give me the source code it will be very much helpful for me

    Reply
  • July 17, 2017 at 8:33 pm
    Permalink

    Hey can you teach me how to do the timer, score and high score stuff??please…thank you

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *