ColorRunner/core/src/de/samdev/colorrunner/game/world/entities/CRGameEntity.java

53 lines
1.5 KiB
Java

package de.samdev.colorrunner.game.world.entities;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import de.samdev.colorrunner.game.world.CRGameWorld;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
public abstract class CRGameEntity {
protected CRGameWorld world;
public Rectangle bounds = new Rectangle();
public float visualRotation = 0f; // 0..360
public float visualZoomX = 1f; // 0..360
public float visualZoomY = 1f; // 0..360
public boolean active = false; // true ::= marked for removal
protected Vector2 tmp_pos = new Vector2();
public CRGameEntity(CRGameWorld _owner, float width, float height) {
this(_owner, 0, 0, width, height);
}
public CRGameEntity(CRGameWorld _owner, float x, float y, float width, float height) {
active = true;
bounds = new Rectangle(x, y, width, height);
world = _owner;
}
public Vector2 getPosition() {
return bounds.getPosition(tmp_pos);
}
public void remove() {
active = false;
}
public abstract void update(float delta);
public abstract Texture getTexture();
public abstract boolean canCollide(boolean actualCollision, CRGameEntity collider);
public TriggerType getTrigger() {
return world.mapprovider.getTrigger((int)((bounds.x + bounds.width/2f) / FloorTileEntity.FLOORTILE_WIDTH), (int)((bounds.y + bounds.height/2f) / FloorTileEntity.FLOORTILE_HEIGHT));
}
}