Reimplemented Colors + cam
This commit is contained in:
parent
faf6e21500
commit
520973d010
@ -6,12 +6,14 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
|
||||
public abstract class AbstractGameRenderer {
|
||||
private final static float GAME_HEIGHT = 512;
|
||||
private final static float MIN_GAME_WIDTH = 672; // ~ 512 * (4/3)
|
||||
private final static float MAX_GAME_WIDTH = 1024; // ~ 512 * (2/1) // ~~ 16:9
|
||||
|
||||
private final static float FREE_ROAM_WIDTH = 1f/4f;
|
||||
|
||||
private int debugTextCount;
|
||||
|
||||
@ -31,21 +33,22 @@ public abstract class AbstractGameRenderer {
|
||||
}
|
||||
|
||||
public void render() {
|
||||
Gdx.gl.glClearColor(1, 0, 1, 1f);
|
||||
Gdx.gl.glClearColor(0.22f, 0.22f, 0.22f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// #################
|
||||
|
||||
shapeRenderer.begin(ShapeType.Filled);
|
||||
|
||||
shapeRenderer.setColor(0.22f, 0.22f, 0.22f, 1);
|
||||
shapeRenderer.rect(0, 0, MIN_GAME_WIDTH, GAME_HEIGHT);
|
||||
|
||||
shapeRenderer.end();
|
||||
|
||||
doRender();
|
||||
}
|
||||
|
||||
protected void updateCameraOffset(float lookAtX) {
|
||||
if (lookAtX > cam.position.x + cam.viewportWidth * FREE_ROAM_WIDTH/2) {
|
||||
cam.position.x += lookAtX - cam.position.x - cam.viewportWidth * FREE_ROAM_WIDTH/2;
|
||||
cam.update();
|
||||
updateCamMatrices();
|
||||
}
|
||||
}
|
||||
|
||||
public void resize(float width, float height) {
|
||||
float cam_width = (width / height) * GAME_HEIGHT;
|
||||
|
||||
@ -56,7 +59,10 @@ public abstract class AbstractGameRenderer {
|
||||
Gdx.app.error("SIZE", "Maximal aspect ratio is 2:1");
|
||||
|
||||
cam.setToOrtho(false, cam_width, GAME_HEIGHT);
|
||||
|
||||
updateCamMatrices();
|
||||
}
|
||||
|
||||
private void updateCamMatrices() {
|
||||
shapeRenderer.setProjectionMatrix(cam.combined);
|
||||
spriteBatch.setProjectionMatrix(cam.combined);
|
||||
fontBatch.setProjectionMatrix(cam.combined);
|
||||
@ -65,12 +71,13 @@ public abstract class AbstractGameRenderer {
|
||||
protected void beginDebug() {
|
||||
fontBatch.begin();
|
||||
font.setColor(1, 0, 1, 1);
|
||||
|
||||
|
||||
debugTextCount = 0;
|
||||
}
|
||||
|
||||
|
||||
protected void renderDebug(String s) {
|
||||
font.draw(fontBatch, s, 10, GAME_HEIGHT - 10 - debugTextCount++ * 20);
|
||||
Vector3 coords = cam.unproject(new Vector3(10, 10 + debugTextCount++ * 20, 0));
|
||||
font.draw(fontBatch, s, coords.x, coords.y);
|
||||
}
|
||||
|
||||
protected void endDebug() {
|
||||
|
@ -10,7 +10,10 @@ public class CRAssets {
|
||||
public static Texture TEX_PLAYER_LEFT;
|
||||
public static Texture TEX_PLAYER_DOWN;
|
||||
|
||||
public static Texture TEX_FLOORTILE;
|
||||
public static Texture TEX_FLOORTILE_UP;
|
||||
public static Texture TEX_FLOORTILE_DOWN;
|
||||
public static Texture TEX_FLOORTILE_LEFT;
|
||||
public static Texture TEX_FLOORTILE_RIGHT;
|
||||
|
||||
static {
|
||||
{
|
||||
@ -43,9 +46,30 @@ public class CRAssets {
|
||||
|
||||
{
|
||||
Pixmap pixmap = new Pixmap(64, 64, Format.RGBA8888);
|
||||
pixmap.setColor(1, 1, 1, 1);
|
||||
pixmap.setColor(1, 0, 0, 1);
|
||||
pixmap.fill();
|
||||
TEX_FLOORTILE = new Texture(pixmap);
|
||||
TEX_FLOORTILE_UP = new Texture(pixmap);
|
||||
}
|
||||
|
||||
{
|
||||
Pixmap pixmap = new Pixmap(64, 64, Format.RGBA8888);
|
||||
pixmap.setColor(0, 1, 0, 1);
|
||||
pixmap.fill();
|
||||
TEX_FLOORTILE_RIGHT = new Texture(pixmap);
|
||||
}
|
||||
|
||||
{
|
||||
Pixmap pixmap = new Pixmap(64, 64, Format.RGBA8888);
|
||||
pixmap.setColor(0, 0, 1, 1);
|
||||
pixmap.fill();
|
||||
TEX_FLOORTILE_DOWN = new Texture(pixmap);
|
||||
}
|
||||
|
||||
{
|
||||
Pixmap pixmap = new Pixmap(64, 64, Format.RGBA8888);
|
||||
pixmap.setColor(1, 1, 0, 1);
|
||||
pixmap.fill();
|
||||
TEX_FLOORTILE_LEFT = new Texture(pixmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ public class CRGameRenderer extends AbstractGameRenderer {
|
||||
|
||||
@Override
|
||||
public void doRender() {
|
||||
updateCameraOffset(gameworld.player.bounds.x);
|
||||
|
||||
beginDebug();
|
||||
renderDebug("FPS: " + (int)gameworld.fps.getFPS());
|
||||
renderDebug("Entitys: " + gameworld.entities.size());
|
||||
|
@ -1,6 +1,5 @@
|
||||
package de.samdev.colorrunner.game.world;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
|
||||
public class AverageExecutionLogger {
|
||||
|
@ -4,87 +4,82 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.gameentities.FloorTileEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.gameentities.floor.DownStateFloorTileEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.gameentities.floor.LeftStateFloorTileEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.gameentities.floor.RightStateFloorTileEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.gameentities.floor.UpStateFloorTileEntity;
|
||||
import de.samdev.colorrunner.input.GameInputListener;
|
||||
import de.samdev.colorrunner.input.SwipeDirection;
|
||||
|
||||
public class CRGameWorld implements GameInputListener {
|
||||
|
||||
|
||||
public PlayerEntity player;
|
||||
|
||||
|
||||
public List<CRGameEntity> entities = new ArrayList<CRGameEntity>();
|
||||
|
||||
|
||||
public FPSCounter fps = new FPSCounter();
|
||||
|
||||
|
||||
public CRGameWorld() {
|
||||
|
||||
addEntity(player = new PlayerEntity(this, 40, 290));
|
||||
|
||||
addEntity(new FloorTileEntity(this, 1*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 2*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 3*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 4*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 5*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 6*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 7*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 8*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 9*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 10*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 11*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 12*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 13*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 14*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 15*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 16*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 17*32, 32));
|
||||
|
||||
addEntity(new FloorTileEntity(this, 18*32, 1*32));
|
||||
addEntity(new FloorTileEntity(this, 19*32, 2*32));
|
||||
addEntity(new FloorTileEntity(this, 19*32, 3*32));
|
||||
addEntity(new FloorTileEntity(this, 18*32, 4*32));
|
||||
addEntity(new FloorTileEntity(this, 18*32, 5*32));
|
||||
addEntity(new FloorTileEntity(this, 19*32, 6*32));
|
||||
addEntity(new FloorTileEntity(this, 20*32, 7*32));
|
||||
|
||||
|
||||
|
||||
addEntity(new FloorTileEntity(this, 21*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 22*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 26*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 27*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 28*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 29*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 29*32, 64));
|
||||
|
||||
addEntity(new UpStateFloorTileEntity(this, 1 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 2 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 3 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 4 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 5 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 6 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 7 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 8 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 9 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 10 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 11 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 12 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 13 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 14 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 15 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 16 * 32, 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 17 * 32, 32));
|
||||
|
||||
|
||||
addEntity(new FloorTileEntity(this, 32*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 33*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 34*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 35*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 36*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 37*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 38*32, 32));
|
||||
addEntity(new FloorTileEntity(this, 39*32, 32));
|
||||
|
||||
|
||||
addEntity(new UpStateFloorTileEntity(this, 18 * 32, 1 * 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 19 * 32, 2 * 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 19 * 32, 3 * 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 18 * 32, 4 * 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 18 * 32, 5 * 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 19 * 32, 6 * 32));
|
||||
addEntity(new UpStateFloorTileEntity(this, 20 * 32, 7 * 32));
|
||||
|
||||
|
||||
addEntity(new FloorTileEntity(this, 11*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 12*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 13*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 14*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 15*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 16*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 17*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 18*32, 456));
|
||||
addEntity(new FloorTileEntity(this, 19*32, 456));
|
||||
addEntity(new RightStateFloorTileEntity(this, 21 * 32, 32));
|
||||
addEntity(new RightStateFloorTileEntity(this, 22 * 32, 32));
|
||||
addEntity(new RightStateFloorTileEntity(this, 26 * 32, 32));
|
||||
addEntity(new RightStateFloorTileEntity(this, 27 * 32, 32));
|
||||
addEntity(new RightStateFloorTileEntity(this, 28 * 32, 32));
|
||||
addEntity(new RightStateFloorTileEntity(this, 29 * 32, 32));
|
||||
addEntity(new RightStateFloorTileEntity(this, 29 * 32, 64));
|
||||
|
||||
addEntity(new LeftStateFloorTileEntity(this, 32 * 32, 32));
|
||||
addEntity(new LeftStateFloorTileEntity(this, 33 * 32, 32));
|
||||
addEntity(new LeftStateFloorTileEntity(this, 34 * 32, 32));
|
||||
addEntity(new LeftStateFloorTileEntity(this, 35 * 32, 32));
|
||||
addEntity(new LeftStateFloorTileEntity(this, 36 * 32, 32));
|
||||
addEntity(new LeftStateFloorTileEntity(this, 37 * 32, 32));
|
||||
addEntity(new LeftStateFloorTileEntity(this, 38 * 32, 32));
|
||||
addEntity(new LeftStateFloorTileEntity(this, 39 * 32, 32));
|
||||
|
||||
addEntity(new DownStateFloorTileEntity(this, 11 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 12 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 13 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 14 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 15 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 16 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 17 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 18 * 32, 456));
|
||||
addEntity(new DownStateFloorTileEntity(this, 19 * 32, 456));
|
||||
}
|
||||
|
||||
public void update(float delta) {
|
||||
fps.Inc();
|
||||
|
||||
|
||||
for (CRGameEntity ent : entities) {
|
||||
ent.update(delta);
|
||||
}
|
||||
@ -92,7 +87,7 @@ public class CRGameWorld implements GameInputListener {
|
||||
|
||||
public CRGameEntity addEntity(CRGameEntity ent) {
|
||||
entities.add(ent);
|
||||
|
||||
|
||||
return ent;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package de.samdev.colorrunner.input;
|
||||
package de.samdev.colorrunner.game.world;
|
||||
|
||||
public enum SwipeDirection {
|
||||
UP,
|
@ -31,4 +31,6 @@ public abstract class CRGameEntity {
|
||||
public abstract void update(float delta);
|
||||
|
||||
public abstract Texture getTexture();
|
||||
|
||||
public abstract boolean canCollide(boolean actualCollision, CRGameEntity collider);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.samdev.colorrunner.game.world.entities;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
@ -26,12 +27,20 @@ public abstract class MovingEntity extends CRGameEntity {
|
||||
|
||||
boolean collided = false;
|
||||
|
||||
Rectangle original = new Rectangle(bounds);
|
||||
|
||||
bounds.x += bx;
|
||||
|
||||
for (CRGameEntity ent : world.entities) {
|
||||
if (ent == this) continue;
|
||||
|
||||
if (ent.bounds.overlaps(bounds)) {
|
||||
if (ent.bounds.overlaps(bounds) && ent.canCollide(true, this)) {
|
||||
|
||||
if (ent.bounds.overlaps(original)) {
|
||||
Gdx.app.log("Collision", "Ignore in bounds collision");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bx < 0) { // LEFT
|
||||
float correction = (ent.bounds.x + ent.bounds.width) - bounds.x;
|
||||
|
||||
@ -57,13 +66,21 @@ public abstract class MovingEntity extends CRGameEntity {
|
||||
if (by == 0) return false;
|
||||
|
||||
boolean collided = false;
|
||||
|
||||
Rectangle original = new Rectangle(bounds);
|
||||
|
||||
bounds.y += by;
|
||||
|
||||
for (CRGameEntity ent : world.entities) {
|
||||
if (ent == this) continue;
|
||||
|
||||
if (ent.bounds.overlaps(bounds)) {
|
||||
if (ent.bounds.overlaps(bounds) && ent.canCollide(true, this)) {
|
||||
|
||||
if (ent.bounds.overlaps(original)) {
|
||||
Gdx.app.log("Collision", "Ignore in bounds collision");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (by < 0) { // DOWN
|
||||
float correction = (ent.bounds.y + ent.bounds.height) - bounds.y;
|
||||
|
||||
@ -94,13 +111,21 @@ public abstract class MovingEntity extends CRGameEntity {
|
||||
for (CRGameEntity ent : world.entities) {
|
||||
if (ent == this) continue;
|
||||
|
||||
if (Math.abs((ent.bounds.y + ent.bounds.height) - bounds.y) < F_EPSILON && ent.bounds.x < (bounds.x + bounds.width) && (ent.bounds.x + ent.bounds.width) > bounds.x) {
|
||||
if (Math.abs((ent.bounds.y + ent.bounds.height) - bounds.y) < F_EPSILON && ent.bounds.x < (bounds.x + bounds.width) && (ent.bounds.x + ent.bounds.width) > bounds.x && ent.canCollide(false, this)) {
|
||||
face_BOTTOM_isTouching = true;
|
||||
}
|
||||
|
||||
if (Math.abs((bounds.y + bounds.height) - ent.bounds.y) < F_EPSILON && ent.bounds.x < (bounds.x + bounds.width) && (ent.bounds.x + ent.bounds.width) > bounds.x) {
|
||||
if (Math.abs((bounds.y + bounds.height) - ent.bounds.y) < F_EPSILON && ent.bounds.x < (bounds.x + bounds.width) && (ent.bounds.x + ent.bounds.width) > bounds.x && ent.canCollide(false, this)) {
|
||||
face_TOP_isTouching = true;
|
||||
}
|
||||
|
||||
if (Math.abs((bounds.x + bounds.width) - ent.bounds.x) < F_EPSILON && ent.bounds.y < (bounds.y + bounds.height) && (ent.bounds.y + ent.bounds.height) > bounds.y && ent.canCollide(false, this)) {
|
||||
face_RIGHT_isTouching = true;
|
||||
}
|
||||
|
||||
if (Math.abs((ent.bounds.x + ent.bounds.width) - bounds.x) < F_EPSILON && ent.bounds.y < (bounds.y + bounds.height) && (ent.bounds.y + ent.bounds.height) > bounds.y && ent.canCollide(false, this)) {
|
||||
face_LEFT_isTouching = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
package de.samdev.colorrunner.game.world.entities.gameentities;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import de.samdev.colorrunner.game.renderer.CRAssets;
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
import de.samdev.colorrunner.game.world.entities.StaticEntity;
|
||||
|
||||
public class FloorTileEntity extends StaticEntity {
|
||||
public final static float FLOORTILE_WIDTH = 32;
|
||||
public final static float FLOORTILE_HEIGHT = 32;
|
||||
|
||||
public FloorTileEntity(CRGameWorld _owner, float x, float y) {
|
||||
super(_owner, x, y, FLOORTILE_WIDTH, FLOORTILE_HEIGHT);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float delta) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture getTexture() {
|
||||
// TODO Auto-generated method stub
|
||||
return CRAssets.TEX_FLOORTILE;
|
||||
}
|
||||
|
||||
}
|
@ -4,8 +4,9 @@ import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import de.samdev.colorrunner.game.renderer.CRAssets;
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.GravityEntity;
|
||||
import de.samdev.colorrunner.input.SwipeDirection;
|
||||
|
||||
public class PlayerEntity extends GravityEntity {
|
||||
public final static float PLAYER_WIDTH = 32;
|
||||
@ -63,4 +64,13 @@ public class PlayerEntity extends GravityEntity {
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollide(boolean actualCollision, CRGameEntity collider) {
|
||||
return collider.canCollide(actualCollision, this);
|
||||
}
|
||||
|
||||
public SwipeDirection getPhase() {
|
||||
return phase;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package de.samdev.colorrunner.game.world.entities.gameentities.floor;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import de.samdev.colorrunner.game.renderer.CRAssets;
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
|
||||
public class DownStateFloorTileEntity extends FloorTileEntity {
|
||||
public final SwipeDirection PHASE = SwipeDirection.DOWN;
|
||||
|
||||
public DownStateFloorTileEntity(CRGameWorld _owner, float x, float y) {
|
||||
super(_owner, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture getTexture() {
|
||||
return CRAssets.TEX_FLOORTILE_DOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwipeDirection getPhase() {
|
||||
return PHASE;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package de.samdev.colorrunner.game.world.entities.gameentities.floor;
|
||||
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.StaticEntity;
|
||||
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
|
||||
|
||||
public abstract class FloorTileEntity extends StaticEntity {
|
||||
public final static float FLOORTILE_WIDTH = 32;
|
||||
public final static float FLOORTILE_HEIGHT = 32;
|
||||
|
||||
public FloorTileEntity(CRGameWorld _owner, float x, float y) {
|
||||
super(_owner, x, y, FLOORTILE_WIDTH, FLOORTILE_HEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float delta) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollide(boolean actualCollision, CRGameEntity collider) {
|
||||
if (collider instanceof PlayerEntity && ((PlayerEntity)collider).getPhase() == getPhase())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract SwipeDirection getPhase();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package de.samdev.colorrunner.game.world.entities.gameentities.floor;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import de.samdev.colorrunner.game.renderer.CRAssets;
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
|
||||
public class LeftStateFloorTileEntity extends FloorTileEntity {
|
||||
public final SwipeDirection PHASE = SwipeDirection.LEFT;
|
||||
|
||||
public LeftStateFloorTileEntity(CRGameWorld _owner, float x, float y) {
|
||||
super(_owner, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture getTexture() {
|
||||
return CRAssets.TEX_FLOORTILE_LEFT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwipeDirection getPhase() {
|
||||
return PHASE;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package de.samdev.colorrunner.game.world.entities.gameentities.floor;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import de.samdev.colorrunner.game.renderer.CRAssets;
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
|
||||
public class RightStateFloorTileEntity extends FloorTileEntity {
|
||||
public final SwipeDirection PHASE = SwipeDirection.RIGHT;
|
||||
|
||||
public RightStateFloorTileEntity(CRGameWorld _owner, float x, float y) {
|
||||
super(_owner, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture getTexture() {
|
||||
return CRAssets.TEX_FLOORTILE_RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwipeDirection getPhase() {
|
||||
return PHASE;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package de.samdev.colorrunner.game.world.entities.gameentities.floor;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import de.samdev.colorrunner.game.renderer.CRAssets;
|
||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
|
||||
public class UpStateFloorTileEntity extends FloorTileEntity {
|
||||
public final SwipeDirection PHASE = SwipeDirection.UP;
|
||||
|
||||
public UpStateFloorTileEntity(CRGameWorld _owner, float x, float y) {
|
||||
super(_owner, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture getTexture() {
|
||||
return CRAssets.TEX_FLOORTILE_UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwipeDirection getPhase() {
|
||||
return PHASE;
|
||||
}
|
||||
}
|
@ -6,6 +6,8 @@ import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.input.GestureDetector.GestureListener;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
|
||||
public class CRGameInputProcessor implements InputProcessor, GestureListener {
|
||||
private GameInputListener owner;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.samdev.colorrunner.input;
|
||||
|
||||
import de.samdev.colorrunner.game.world.SwipeDirection;
|
||||
|
||||
public interface GameInputListener {
|
||||
public void doJump();
|
||||
public void doFly();
|
||||
|
Loading…
Reference in New Issue
Block a user