117 lines
1.9 KiB
Java
Executable File
117 lines
1.9 KiB
Java
Executable File
package com.hyperling.apps.games;
|
|
|
|
import android.graphics.Rect;
|
|
|
|
/**
|
|
* Created by ling on 12/22/16.
|
|
* https://youtu.be/kGqKNpk6VJw?list=PLWweaDaGRHjvQlpLV0yZDmRKVBdy6rSlg
|
|
*/
|
|
|
|
public abstract class GameObject {
|
|
protected int x;
|
|
protected int y;
|
|
protected int dx;
|
|
protected int dy;
|
|
protected int width;
|
|
protected int height;
|
|
|
|
protected int centerX;
|
|
protected int endX;
|
|
|
|
protected int centerY;
|
|
protected int bottomY;
|
|
|
|
public int getX() {
|
|
return x;
|
|
}
|
|
|
|
public void setX(int x) {
|
|
this.x = x;
|
|
}
|
|
|
|
public int getY() {
|
|
return y;
|
|
}
|
|
|
|
public void setY(int y) {
|
|
this.y = y;
|
|
}
|
|
|
|
public int getDx() {
|
|
return dx;
|
|
}
|
|
|
|
public void setDx(int dx) {
|
|
this.dx = dx;
|
|
}
|
|
|
|
public int getDy() {
|
|
return dy;
|
|
}
|
|
|
|
public void setDy(int dy) {
|
|
this.dy = dy;
|
|
}
|
|
|
|
public int getWidth() {
|
|
return width;
|
|
}
|
|
|
|
public void setWidth(int width) {
|
|
this.width = width;
|
|
}
|
|
|
|
public int getHeight() {
|
|
return height;
|
|
}
|
|
|
|
public void setHeight(int height) {
|
|
this.height = height;
|
|
}
|
|
|
|
public int getCenterX() {
|
|
return centerX;
|
|
}
|
|
|
|
public void setCenterX(int centerX) {
|
|
this.centerX = centerX;
|
|
}
|
|
|
|
public int getEndX() {
|
|
return endX;
|
|
}
|
|
|
|
public void setEndX(int endX) {
|
|
this.endX = endX;
|
|
}
|
|
|
|
public int getCenterY() {
|
|
return centerY;
|
|
}
|
|
|
|
public void setCenterY(int centerY) {
|
|
this.centerY = centerY;
|
|
}
|
|
|
|
public int getBottomY() {
|
|
return bottomY;
|
|
}
|
|
|
|
public void setBottomY(int bottomY) {
|
|
this.bottomY = bottomY;
|
|
}
|
|
|
|
public void updateEdgeLocations(){
|
|
endX = x + width;
|
|
bottomY = y + height;
|
|
|
|
centerX = (x + endX) / 2;
|
|
centerY = (y + bottomY) / 2;
|
|
}
|
|
|
|
public Rect getRect(){
|
|
return new Rect(x, y, x + width, y + height);
|
|
}
|
|
|
|
}
|