Android Open Source - BobEngine Start Room






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 bobby.example.bobengineexample;
//from  ww w . j ava 2  s  .  c o m
import java.util.Random;

import bobby.engine.bobengine.BobView;
import bobby.engine.bobengine.NumberDisplay;
import bobby.engine.bobengine.Room;

public class StartRoom extends Room {

  // Game objects
  private Android[] droid;
  private NumberDisplay num;

  // Other objects
  private Random rand;

  // Constants
  private final int NUM_DROIDS = 5;   // Number of bouncing icons (not actually droids anymore, whatever)
  private final double DROID_SIZE = 10; // Size... sort of. Bigger number = smaller bouncing icons

  StartRoom(BobView container) {
    super(container);

    rand = new Random();
    droid = new Android[NUM_DROIDS];
    num = new NumberDisplay(nextInstance(), this);

    for (int i = 0; i < NUM_DROIDS; i++) {
      droid[i] = new Android(nextInstance(), this);
    }

    set();

    for (int i = 0; i < NUM_DROIDS; i++) {
      addObject(droid[i]);
    }
    
    addObject(num);
  }

  public void set() {
    for (int i = 0; i < NUM_DROIDS; i++) {
      droid[i].set(rand.nextInt(getWidth()), rand.nextInt(getHeight()), DROID_SIZE, 1);
    }
    
    num.set(500, 1000, 1f / 6f, 1);
    num.setAfterKerning(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    num.setBeforeKerning(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  }

  @Override
  public void step(double deltaTime) {
    getView().setBackgroundColor(1, 1, 1, 0);
    
    for (int x = 0; x < NUM_DROIDS; x++) {
      for (int y = 0; y < NUM_DROIDS; y++) {
        // Uncomment these lines for collision detection
        //if (x != y && checkCollision(droid[x], droid[y])) {
        //  getView().setBackgroundColor(0, 0, 1, 1);
        //}
      }
    }
    
    num.setNumber((int) ((60.0 / deltaTime) * 10));
    num.x = (getWidth() / 2) + num.getWidth() / 2;

    super.step(deltaTime);
  }
}




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