Android Open Source - SimpleGame Simple Object






From Project

Back to project page SimpleGame.

License

The source code is released under:

GNU General Public License

If you think the Android project SimpleGame 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 ru.rs.gameobjects;
//w  w w. java 2s.  c  o  m
import ru.rs.GameObject;
import ru.rs.Renderable;
import ru.rs.interfaces.Game;
import ru.rs.objects.math.Vector;
import android.graphics.Bitmap;

public abstract class SimpleObject extends GameObject implements Renderable {
  public Bitmap image;
  public Side side;
  public Game game;

  public SimpleObject(float x, float y, float width, float height) {
    super(x, y, width, height);
  }

  public SimpleObject(Vector position, Bitmap image) {
    super(position.x, position.y, image.getWidth(), image.getHeight());
    this.image = image;
  }

  public SimpleObject(Side side, Game game) {
    this.side = side;
    this.game = game;
    setImage();

    float x = (Side.ENEMY.equals(this.side)) ? this.game.getGraphics()
        .getWidth() - image.getWidth() - 1 : 0;
    float y = 1;

    position = new Vector(x, y);
  }

  public void render() {
    game.getGraphics()
        .drawBitmap(
            image,
            position.x,
            game.getGraphics().getHeight() - position.y
                - image.getHeight());
  }

  protected abstract void setImage();
}




Java Source Code List

ru.rs.Resources.java
ru.rs.SimpleGame.java
ru.rs.gameobjects.Castle.java
ru.rs.gameobjects.DynamicObject.java
ru.rs.gameobjects.GeneralGrid.java
ru.rs.gameobjects.Side.java
ru.rs.gameobjects.SimpleGameWorld.java
ru.rs.gameobjects.SimpleObject.java
ru.rs.gameobjects.Unit.java
ru.rs.screens.CollisionScreen.java
ru.rs.screens.LoadingScreen.java
ru.rs.screens.MenuScreen.java