Android Open Source - BobEngine Game View






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;
/* w w w . j av a  2 s  . c  om*/
import android.content.Context;
import android.util.AttributeSet;

import javax.microedition.khronos.opengles.GL10;

import bobby.engine.bobengine.BobView;
import bobby.engine.bobengine.Graphic;

/**
 * Created by Ben on 1/6/2015.
 */
public class GameView extends BobView {

    // Rooms
    public static StartRoom start;   // The start screen
    public static GameRoom game;     // The actual game
    public static GameOver gameOver; // The game over screen

    // Graphics
    public static Graphic bug;
    public static Graphic title;
    public static Graphic play;
    public static Graphic flower;
    public static Graphic bg;
    public static Graphic over;

    public GameView(Context context) {
        super(context);
    }

    @Override
    protected void onCreateGraphics() {
        /*
         * Here is where we will create our graphics that we will use with our
         * game objects. You'll notice that it is very simple and requires only
         * one called to getGraphicsHelper().addGraphic(drawable) per graphic.
         *
         * Graphics can also be added elsewhere in your program, such as in the
         * constructor of a game object. In a game object or room, you can use
         * the getView() function to get the view that that object or room
         * belongs to. So, just called getView().getGraphicsHelper().addGraphic(drawable)
         * to add a graphic.
         *
         * The purpose of the onCreateGraphics() method is to provide a place to add
         * all your graphics or add graphics that are used by more than one game object.
         */

        /*
         * Here tell the graphics helper how to filter our graphics when they aren't
         * displayed at their native resolutions. We use GL10.GL_NEAREST here
         * because we have retro style graphics and we don't want them to be blurred.
         *
         * For more information, look up OpenGL texture filtering.
         */
        getGraphicsHelper().setParameters(true, GL10.GL_NEAREST, GL10.GL_NEAREST);

        // Now, add the graphics!
        bug = getGraphicsHelper().addGraphic(R.drawable.bug);
        title = getGraphicsHelper().addGraphic(R.drawable.title);
        play = getGraphicsHelper().addGraphic(R.drawable.play);
        flower = getGraphicsHelper().addGraphic(R.drawable.flower);
        bg = getGraphicsHelper().addGraphic(R.drawable.background);
        over = getGraphicsHelper().addGraphic(R.drawable.gameover);
    }


    @Override
    protected void onCreateRooms() {
        /*
         * Here is where you will initialize and setup your rooms. This method is a bit
         * more important than the onCreateGraphics() method. By initializing and setting
         * up your rooms here you are guaranteed to be able to use the getWidth() and
         * getHeight() methods for getting the width and height of the view. Using these
         * methods sooner (for example: in the GameView constructor) will result in an
         * exception due to the view not being inflated yet.
         *
         * It is safe to initialize and setup rooms in this method or anytime after
         * this method is called.
         */


        // Initialize the rooms
        start = new StartRoom(this);
        game = new GameRoom(this);
        gameOver = new GameOver(this);

        // Setup the rooms
        start.set();

        goToRoom(start); // Go to the start screen
    }
}




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