Android Open Source - TreeFrogEngine Gridded Object






From Project

Back to project page TreeFrogEngine.

License

The source code is released under:

MIT License

If you think the Android project TreeFrogEngine 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.discretesoftworks.framework;
//  w ww. j a va 2  s  .co m
import android.annotation.SuppressLint;

// Allows an object to be added to the "grid"
//  - Basically allows the object to have coordinates and be moved
public class GriddedObject {

  private float x, y, z;
  private int depth;
  private float width, length, height;
  
  
  public GriddedObject(float x, float y, float z){
    this(x,y,z,1,1);
  }
  
  @SuppressLint("UseValueOf")
  public GriddedObject(float x, float y, float z, float width, float length){
    this.x = x;
    this.y = y;
    this.z = z;
    this.depth = new Integer(0); // Temporary code
    setWidth(width);
    setLength(length);
    setHeight(1);
  }
  
  public void setDepth(int depth){
    this.depth = depth;
  }
  
  public Integer getDepth(){
    return depth;
  }
  
  public void setX(float x){
    this.x = x;
  }
  
  public void setY(float y){
    this.y = y;
  }
  
  public void setZ(float z){
    this.z = z;
  }
  
  public void changeX(float dx){
    this.x += dx;
  }
  
  public void changeY(float dy){
    this.y += dy;
  }
  
  public void changeZ(float dz){
    this.z += dz;
  }
  
  public float getX(){
    return x;
  }
  
  public float getY(){
    return y;
  }
  
  public float getZ(){
    return z;
  }
  
  public float getLeft(){
    return (x - width/2);
  }
  
  public float getTop(){
    return (y - length/2);
  }
  
  public float getRight(){
    return (x + width/2);
  }
  
  public float getBottom(){
    return (y + length/2);
  }
  
  public void setCorner(float x, float y){
    setLeft(x);
    setTop(y);
  }
  
  public void setLeft(float l){
    x = l + width/2;
  }
  
  public void setTop(float t){
    y = t + length/2;
  }
  
  public void setRight(float r){
    x = r - width/2;
  }
  
  public void setBottom(float b){
    y = b - length/2;
  }
  
  public void setDimensions(float width, float height){
    setWidth(width);
    setLength(height);
  }
  
  public void setCoordinates(float x, float y){
    setX(x);
    setY(y);
  }
  
  public void setWidth(float width){
    this.width = width;
  }
  
  public void setLength(float length){
    this.length = length;
  }
  
  public void setHeight(float height){
    this.height = height;
  }
  
  public void changeWidth(float dWidth){
    setWidth(width+dWidth);
  }
  
  public void changeLength(float dLength){
    setLength(length+dLength);
  }
  
  public void changeHeight(float dHeight){
    setHeight(height+dHeight);
  }
  
  public float getWidth(){
    return width;
  }
  
  public float getLength(){
    return length;
  }
  
  public float getHeight(){
    return height;
  }
  
}




Java Source Code List

com.discretesoftworks.OUYAframework.OuyaGameController.java
com.discretesoftworks.OUYAframework.OuyaGame.java
com.discretesoftworks.TestGame.Floor.java
com.discretesoftworks.TestGame.Player.java
com.discretesoftworks.TestGame.Pointer.java
com.discretesoftworks.TestGame.TestController.java
com.discretesoftworks.TestGame.TestGame.java
com.discretesoftworks.framework.AndroidGame.java
com.discretesoftworks.framework.Assets.java
com.discretesoftworks.framework.Directional.java
com.discretesoftworks.framework.GameController.java
com.discretesoftworks.framework.GameFont.java
com.discretesoftworks.framework.GameObject.java
com.discretesoftworks.framework.GameRenderer.java
com.discretesoftworks.framework.GriddedObject.java
com.discretesoftworks.framework.ModelLoader.java
com.discretesoftworks.framework.MovingObject.java
com.discretesoftworks.framework.MyGLRenderer.java
com.discretesoftworks.framework.MyGLSurfaceView.java
com.discretesoftworks.framework.NumericalMatrix.java
com.discretesoftworks.framework.Pair.java
com.discretesoftworks.framework.Path.java
com.discretesoftworks.framework.Pool.java
com.discretesoftworks.framework.RaggedDictionary.java
com.discretesoftworks.framework.RenderModel.java
com.discretesoftworks.framework.Sprite.java
com.discretesoftworks.framework.Terrain.java
com.discretesoftworks.framework.TextDisplay.java
com.discretesoftworks.framework.TextHolder.java
com.discretesoftworks.framework.View.java
com.discretesoftworks.networking.NetworkGameController.java
com.discretesoftworks.networking.Writer.java