Android Open Source - BobEngine Background






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  .  ja  v  a  2 s.c  o m*/
import bobby.engine.bobengine.GameObject;
import bobby.engine.bobengine.Room;

/**
 * Created by Ben on 1/9/2015.
 */
public class Background extends GameObject {

    // Variables
    private int speed;

    /**
     * Initialization. Requires a unique Id number and the room containing this
     * GameObject.
     *
     * @param id             - ID number
     * @param containingRoom - Room that this object is in.
     */
    public Background(int id, Room containingRoom) {
        super(id, containingRoom);

        layer = 0; // By default, the layer is 1. Lower layers are drawn first, so they will appear behind higher layers

        setGraphic(GameView.bg, 1);
    }

    /**
     * Set up and reset the background
     */
    public void set(int x, int speed) {
        this.x = x;
        this.speed = speed;

        width = getRoom().getWidth();
        height = getRoom().getHeight();
        y = height / 2;
    }

    @Override
    public void step(double dt) {
        x -= speed;

        if (x <= -width / 2) {
            x = getRoom().getWidth() + width / 2 - (x + width / 2);
        }
    }
}




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