Android Open Source - BobEngine Game Over






From Project

Back to project page BobEngine.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project BobEngine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bobbyloujo.jumpybug;
/*ww  w. jav  a2 s  . co  m*/
import bobby.engine.bobengine.BobView;
import bobby.engine.bobengine.GameObject;
import bobby.engine.bobengine.NumberDisplay;
import bobby.engine.bobengine.Room;

/**
 * Created by Ben on 1/6/2015.
 */
public class GameOver extends Room {

    // Objects
    public GameObject play;             // Play button
    private Background bg1;             // Background panel 1
    private Background bg2;             // Background panel 2
    private NumberDisplay score;        // Score display
    private GameObject gameOver;        // Game Over graphic

    public GameOver(BobView container) {
        super(container);

        // Initialize
        play = new GameObject(nextInstance(), this);
        bg1 = new Background(nextInstance(), this);
        bg2 = new Background(nextInstance(), this);
        score = new NumberDisplay(nextInstance(), this);
        gameOver = new GameObject(nextInstance(), this);

        // Add
        addObject(play);
        addObject(bg1);
        addObject(bg2);
        addObject(score);
        addObject(gameOver);
    }

    public void set() {
        play.x = getWidth() / 2;
        play.y = getHeight() / 4;
        play.width = getWidth() / 4;
        play.height = play.width / 2;
        play.setGraphic(GameView.play, 2);

        bg1.set(getWidth() / 2, 4);
        bg2.set(getWidth() * 3 / 2, 4);

        score.setNumber(GameView.game.getScore());
        score.y = getHeight() / 2;
        score.width = getWidth() / 5;
        score.height = score.width;
        score.x = getWidth() / 2;

        gameOver.x = getWidth() / 2;
        gameOver.y = getHeight() * 5 / 6;
        gameOver.width = getWidth() / 3;
        gameOver.height = gameOver.width;
        gameOver.setGraphic(GameView.over, 1);
    }

    /**
     * Step event happens every frame.
     *
     * @param dt
     */
    @Override
    public void step(double dt) {
        score.x = getWidth() / 2 + score.getWidth() / 2; // Center the score

        if (getTouch().objectTouched(play)) {  // Is the play button being touched?
            play.frame = 1;                    // Pressed frame.
        } else {
            play.frame = 0;                    // Not pressed frame.
        }
    }

    /**
     * Released event is fired when a finger/stylus is released from the touchscreen.
     *
     * @param index - ID number of the finger that fired this event.
     */
    public void released(int index){
        super.released(index);                       // MUST call super for the newpress and released events in rooms.

        /**
         * getTouch() provides many useful functions for getting
         * touchscreen input. See the touchInput example for more
         * information.
         */
        if (getTouch().objectTouched(play)) {        // Play button touched
            GameView.game.set();                     // Set up the game room.
            getView().goToRoom(GameView.game);       // Go to the game room.
        }
    }
}




Java Source Code List

bobby.engine.bobengine.BobActivity.java
bobby.engine.bobengine.BobActivity.java
bobby.engine.bobengine.BobRenderer.java
bobby.engine.bobengine.BobRenderer.java
bobby.engine.bobengine.BobView.java
bobby.engine.bobengine.BobView.java
bobby.engine.bobengine.BuildConfig.java
bobby.engine.bobengine.BuildConfig.java
bobby.engine.bobengine.GameObject.java
bobby.engine.bobengine.GameObject.java
bobby.engine.bobengine.Graphic.java
bobby.engine.bobengine.Graphic.java
bobby.engine.bobengine.GraphicsHelper.java
bobby.engine.bobengine.GraphicsHelper.java
bobby.engine.bobengine.NumberDisplay.java
bobby.engine.bobengine.NumberDisplay.java
bobby.engine.bobengine.Room.java
bobby.engine.bobengine.Room.java
bobby.engine.bobengine.SoundPlayer.java
bobby.engine.bobengine.SoundPlayer.java
bobby.engine.bobengine.SplashActivity.java
bobby.engine.bobengine.SplashActivity.java
bobby.engine.bobengine.Touch.java
bobby.engine.bobengine.Touch.java
bobby.engine.template.AnObject.java
bobby.engine.template.AnObject.java
bobby.engine.template.BuildConfig.java
bobby.engine.template.BuildConfig.java
bobby.engine.template.GameView.java
bobby.engine.template.GameView.java
bobby.engine.template.MainActivity.java
bobby.engine.template.MainActivity.java
bobby.engine.template.StartRoom.java
bobby.engine.template.StartRoom.java
bobby.engine.touchinput.AnObject.java
bobby.engine.touchinput.AnObject.java
bobby.engine.touchinput.GameView.java
bobby.engine.touchinput.GameView.java
bobby.engine.touchinput.MainActivity.java
bobby.engine.touchinput.MainActivity.java
bobby.engine.touchinput.StartRoom.java
bobby.engine.touchinput.StartRoom.java
bobby.example.bobengineexample.Android.java
bobby.example.bobengineexample.BuildConfig.java
bobby.example.bobengineexample.GameView.java
bobby.example.bobengineexample.MainActivity.java
bobby.example.bobengineexample.StartRoom.java
bobby.example.cameraexample.ApplicationTest.java
bobby.example.cameraexample.MainActivity.java
com.bobbyloujo.jumpybug.ApplicationTest.java
com.bobbyloujo.jumpybug.Background.java
com.bobbyloujo.jumpybug.Bug.java
com.bobbyloujo.jumpybug.Flower.java
com.bobbyloujo.jumpybug.GameOver.java
com.bobbyloujo.jumpybug.GameRoom.java
com.bobbyloujo.jumpybug.GameView.java
com.bobbyloujo.jumpybug.MainActivity.java
com.bobbyloujo.jumpybug.StartRoom.java