Android Open Source - Stickman Game Object






From Project

Back to project page Stickman.

License

The source code is released under:

Apache License

If you think the Android project Stickman 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.wireframe.stickman;
/*from www.ja  va2  s .c  o  m*/
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;

public abstract class GameObject implements Comparable<GameObject>{
  
  public static final int Z_BACKGROUND = 0;
  public static final int Z_BACKGROUNDOBJECT = 1;
  public static final int Z_OBJECTS = 3;
  public static final int Z_FLOATINGTEXTS = 4;
  public static final int Z_FOREGROUND = 5;
  

  private Rectangle bounds;
  private Vector3 position;
  private Vector2 size;
  public abstract void dispose();
  public abstract void draw(SpriteBatch batch);
  public abstract void update();
  
  public GameObject(Vector3 position, Vector2 size){
    this.position = position.cpy();
    this.size = size.cpy();
    this.bounds = new Rectangle(position.x, position.y, size.x, size.y);    
  }

  public Vector3 getPosition() {
    return position.cpy();
  }

  public void setPosition(Vector3 position2) {
    this.position = position2.cpy();
  }
  
  public Vector2 getSize() {
    return size.cpy();
  }

  public void setSize(Vector2 size) {
    this.size = size.cpy();
  }

  public void setSize(float x, float y) {
    this.size = new Vector2(x,y);
  }

  public void moveBy(float x, float y) {
    position.x += x;
    position.y += y;
    bounds.setX(bounds.getX() + x);
    bounds.setY(bounds.getY() + y);
  }
  
  public void moveTo(float x, float y) {
    position.x = x;
    position.y = y;
    bounds.setX(x);
    bounds.setY(y);
  }
  
  public Rectangle getBounds(){
    return new Rectangle(bounds);
  }
  
  @Override
  public int compareTo(GameObject other){
    return (int) Math.signum(other.getZ()- getZ());
  }

  public float getX(){
    return position.x;
  }
  
  public float getY(){
    return position.y;
  }

  public float getZ() {
    return position.z;
  }
  
  public float getWidth(){
    return size.x;
  }
  
  public float getHeight(){
    return size.y;
  }
}




Java Source Code List

com.wireframe.stickman.AICharacter.java
com.wireframe.stickman.AndroidGUI.java
com.wireframe.stickman.Brick.java
com.wireframe.stickman.Character.java
com.wireframe.stickman.Door.java
com.wireframe.stickman.Enemy.java
com.wireframe.stickman.FloatingText.java
com.wireframe.stickman.Friendly.java
com.wireframe.stickman.GUI.java
com.wireframe.stickman.GameObject.java
com.wireframe.stickman.GameRules.java
com.wireframe.stickman.Health.java
com.wireframe.stickman.Interactable.java
com.wireframe.stickman.Ladder.java
com.wireframe.stickman.Player.java
com.wireframe.stickman.Resources.java
com.wireframe.stickman.SmallButton.java
com.wireframe.stickman.Spawner.java
com.wireframe.stickman.Spikes.java
com.wireframe.stickman.StickmanGame.java
com.wireframe.stickman.StickmanResources.java
com.wireframe.stickman.Tile.java
com.wireframe.stickman.Toggleable.java
com.wireframe.stickman.WaterShore.java
com.wireframe.stickman.Water.java
com.wireframe.stickman.World.java
com.wireframe.stickman.android.AndroidLauncher.java
com.wireframe.stickman.desktop.DesktopLauncher.java
com.wireframe.stickman.desktop.EditorLauncher.java
com.wireframe.stickman.editor.MapMaker.java
com.wireframe.stickman.editor.MappingPanel.java
com.wireframe.stickman.editor.PlacedTile.java
com.wireframe.stickman.editor.SelectionPanel.java
com.wireframe.stickman.editor.SelectionTile.java
com.wireframe.stickman.editor.SizingPanel.java