parent
5fd5a60307
commit
1bac4713ed
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,12 @@
|
||||||
package de.samdev.colorrunner.game.world.entities;
|
package de.samdev.colorrunner.game.world.entities;
|
||||||
|
|
||||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||||
import de.samdev.colorrunner.game.world.entities.gameentities.GetTriggerType;
|
import de.samdev.colorrunner.game.world.entities.gameentities.ControllingType;
|
||||||
|
|
||||||
public abstract class GravityEntity extends MovingEntity {
|
public abstract class GravityEntity extends MovingEntity {
|
||||||
public float GRAVITY_FORCE = 700f;
|
public float GRAVITY_FORCE = 700f;
|
||||||
public final static float TERMINAL_VELOCITY = 900f;
|
public final static float TERMINAL_VELOCITY = 900f;
|
||||||
public GetTriggerType getType = GetTriggerType.RUNBOTTOM;
|
public ControllingType ctrlType = ControllingType.RUNBOTTOM;
|
||||||
|
|
||||||
public GravityEntity(CRGameWorld _owner, float width, float height) {
|
public GravityEntity(CRGameWorld _owner, float width, float height) {
|
||||||
this(_owner, 0, 0, width, height);
|
this(_owner, 0, 0, width, height);
|
||||||
|
@ -19,7 +19,7 @@ public abstract class GravityEntity extends MovingEntity {
|
||||||
@Override
|
@Override
|
||||||
public void update(float delta) {
|
public void update(float delta) {
|
||||||
|
|
||||||
switch (getType){
|
switch (ctrlType){
|
||||||
case RUNTOP:
|
case RUNTOP:
|
||||||
GRAVITY_FORCE = -700;
|
GRAVITY_FORCE = -700;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -10,8 +10,8 @@ import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||||
public abstract class MovingEntity extends CRGameEntity {
|
public abstract class MovingEntity extends CRGameEntity {
|
||||||
protected Vector2 velocity = new Vector2();
|
protected Vector2 velocity = new Vector2();
|
||||||
|
|
||||||
public final static float EPSILON = 1e-8f;
|
public final static float EPSILON = 1e-4f;
|
||||||
public final static float EPSILON_TOUCH = 5e-8f;
|
public final static float EPSILON_TOUCH = 5e-4f;
|
||||||
|
|
||||||
private boolean face_TOP_isTouching = false;
|
private boolean face_TOP_isTouching = false;
|
||||||
private boolean face_LEFT_isTouching = false;
|
private boolean face_LEFT_isTouching = false;
|
||||||
|
@ -134,26 +134,29 @@ public abstract class MovingEntity extends CRGameEntity {
|
||||||
|
|
||||||
if (isTouching_LEFT() && ! isTouching_RIGHT()) {
|
if (isTouching_LEFT() && ! isTouching_RIGHT()) {
|
||||||
next.width += add;
|
next.width += add;
|
||||||
next.x -= add;
|
|
||||||
} else if (! isTouching_LEFT() && isTouching_RIGHT()) {
|
} else if (! isTouching_LEFT() && isTouching_RIGHT()) {
|
||||||
next.width += add;
|
next.width += add;
|
||||||
|
next.x -= add;
|
||||||
|
next.x -= EPSILON;
|
||||||
} else {
|
} else {
|
||||||
next.width += add;
|
next.width += add;
|
||||||
next.x -= add/2;
|
next.x -= add/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add < 0) {
|
if (add < 0) {
|
||||||
bounds.set(next);
|
|
||||||
|
|
||||||
for (CRGameEntity ent2 : world.entities) { //TODO rem me
|
if (CRGame.DEBUG) {
|
||||||
if (ent2 == this) continue;
|
for (CRGameEntity ent2 : world.entities) {
|
||||||
|
if (ent2 == this) continue;
|
||||||
|
|
||||||
if (overlaps(next, ent2.bounds) && ent2.canCollide(false, this)) {
|
if (overlaps(next, ent2.bounds) && ent2.canCollide(false, this)) {
|
||||||
Gdx.app.log("Entity Hitbox", "Expand failed X- || WTF");
|
Gdx.app.log("Entity Hitbox", "Expand failed X- || WTF");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bounds.set(next);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (CRGameEntity ent : world.entities) {
|
for (CRGameEntity ent : world.entities) {
|
||||||
|
@ -206,24 +209,27 @@ public abstract class MovingEntity extends CRGameEntity {
|
||||||
next.height += add;
|
next.height += add;
|
||||||
} else if (! isTouching_BOTTOM() && isTouching_TOP()) {
|
} else if (! isTouching_BOTTOM() && isTouching_TOP()) {
|
||||||
next.height += add;
|
next.height += add;
|
||||||
next.y -= add - EPSILON;
|
next.y -= add;
|
||||||
|
next.y -= EPSILON;
|
||||||
} else {
|
} else {
|
||||||
next.height += add;
|
next.height += add;
|
||||||
next.y -= add/2;
|
next.y -= add/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add < 0) {
|
if (add < 0) {
|
||||||
bounds.set(next);
|
|
||||||
|
|
||||||
for (CRGameEntity ent2 : world.entities) { //TODO rem me
|
if (CRGame.DEBUG) {
|
||||||
if (ent2 == this) continue;
|
for (CRGameEntity ent2 : world.entities) {
|
||||||
|
if (ent2 == this) continue;
|
||||||
|
|
||||||
if (overlaps(next, ent2.bounds) && ent2.canCollide(false, this)) {
|
if (overlaps(next, ent2.bounds) && ent2.canCollide(false, this)) {
|
||||||
Gdx.app.log("Entity Hitbox", "Expand failed Y- || WTF");
|
Gdx.app.log("Entity Hitbox", "Expand failed Y- || WTF");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bounds.set(next);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (CRGameEntity ent : world.entities) {
|
for (CRGameEntity ent : world.entities) {
|
||||||
|
|
|
@ -4,6 +4,6 @@ package de.samdev.colorrunner.game.world.entities.gameentities;
|
||||||
* Created by benza on 23.04.2017.
|
* Created by benza on 23.04.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum GetTriggerType {
|
public enum ControllingType {
|
||||||
RUNBOTTOM, RUNTOP, FLY, NOTHING
|
RUNBOTTOM, RUNTOP, FLY, NOTHING
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package de.samdev.colorrunner.game.world.entities.gameentities;
|
package de.samdev.colorrunner.game.world.entities.gameentities;
|
||||||
|
|
||||||
import com.badlogic.gdx.Game;
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
|
||||||
|
@ -11,14 +10,10 @@ import de.samdev.colorrunner.game.world.entities.CRGameEntity;
|
||||||
import de.samdev.colorrunner.game.world.entities.GravityEntity;
|
import de.samdev.colorrunner.game.world.entities.GravityEntity;
|
||||||
import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
|
import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
|
||||||
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
|
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
|
||||||
import de.samdev.colorrunner.screens.menu.MainMenu;
|
|
||||||
|
|
||||||
import static de.samdev.colorrunner.game.world.map.provider.TriggerType.RUNBOTTOM;
|
|
||||||
import static de.samdev.colorrunner.game.world.map.provider.TriggerType.RUNTOP;
|
|
||||||
|
|
||||||
public class PlayerEntity extends GravityEntity {
|
public class PlayerEntity extends GravityEntity {
|
||||||
public final static float PLAYER_WIDTH = 32;
|
public final static float PLAYER_WIDTH = 31.9f;
|
||||||
public final static float PLAYER_HEIGHT = 32;
|
public final static float PLAYER_HEIGHT = 31.9f;
|
||||||
|
|
||||||
public final static float PLAYER_JUMP_FORCE = 356f;
|
public final static float PLAYER_JUMP_FORCE = 356f;
|
||||||
public final static float PLAYER_FLY_FORCE = 250f;
|
public final static float PLAYER_FLY_FORCE = 250f;
|
||||||
|
@ -30,10 +25,7 @@ public class PlayerEntity extends GravityEntity {
|
||||||
|
|
||||||
private SwipeDirection phase = SwipeDirection.UP;
|
private SwipeDirection phase = SwipeDirection.UP;
|
||||||
|
|
||||||
|
|
||||||
private boolean doFly = false;
|
private boolean doFly = false;
|
||||||
private TriggerType triggerType;
|
|
||||||
|
|
||||||
|
|
||||||
public PlayerEntity(CRGameWorld _owner, float x, float y) {
|
public PlayerEntity(CRGameWorld _owner, float x, float y) {
|
||||||
super(_owner, x, y, PLAYER_WIDTH, PLAYER_HEIGHT);
|
super(_owner, x, y, PLAYER_WIDTH, PLAYER_HEIGHT);
|
||||||
|
@ -45,35 +37,33 @@ public class PlayerEntity extends GravityEntity {
|
||||||
velocity.x += PLAYER_SPEED_FORCE * delta;
|
velocity.x += PLAYER_SPEED_FORCE * delta;
|
||||||
|
|
||||||
if (doFly) {
|
if (doFly) {
|
||||||
if ( getType == GetTriggerType.RUNBOTTOM)
|
if ( ctrlType == ControllingType.RUNBOTTOM)
|
||||||
velocity.y += PLAYER_FLY_FORCE * delta;
|
velocity.y += PLAYER_FLY_FORCE * delta;
|
||||||
else if(getType == GetTriggerType.RUNTOP)
|
else if(ctrlType == ControllingType.RUNTOP)
|
||||||
velocity.y += -PLAYER_FLY_FORCE * delta;
|
velocity.y += -PLAYER_FLY_FORCE * delta;
|
||||||
}
|
}
|
||||||
doFly = false;
|
doFly = false;
|
||||||
|
|
||||||
updateRotation(delta);
|
updateRotation(delta);
|
||||||
|
|
||||||
triggerType = world.mapprovider.getTrigger((int)(bounds.x / FloorTileEntity.FLOORTILE_WIDTH), (int)(bounds.y / FloorTileEntity.FLOORTILE_HEIGHT));
|
TriggerType trigger = world.mapprovider.getTrigger((int)((bounds.x + bounds.width/2f) / FloorTileEntity.FLOORTILE_WIDTH), (int)((bounds.y + bounds.height/2f) / FloorTileEntity.FLOORTILE_HEIGHT));
|
||||||
|
switch (trigger){
|
||||||
switch (triggerType){
|
|
||||||
case RUNTOP:
|
case RUNTOP:
|
||||||
getType = GetTriggerType.RUNTOP;
|
ctrlType = ControllingType.RUNTOP;
|
||||||
break;
|
break;
|
||||||
case RUNBOTTOM:
|
case RUNBOTTOM:
|
||||||
getType = GetTriggerType.RUNBOTTOM;
|
ctrlType = ControllingType.RUNBOTTOM;
|
||||||
break;
|
break;
|
||||||
case FLY:
|
case FLY:
|
||||||
getType = GetTriggerType.FLY;
|
ctrlType = ControllingType.FLY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
super.update(delta);
|
super.update(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRotation(float delta) {
|
private void updateRotation(float delta) {
|
||||||
boolean touch = false; //isTouching_ANY(); //TODO comment me to force bug
|
boolean touch = isTouching_ANY();
|
||||||
boolean aligned = (visualRotation % 90 == 0);
|
boolean aligned = (visualRotation % 90 == 0);
|
||||||
|
|
||||||
if (!touch)
|
if (!touch)
|
||||||
|
@ -109,9 +99,9 @@ public class PlayerEntity extends GravityEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void jump() {
|
public void jump() {
|
||||||
if (isTouching_BOTTOM() && getType == GetTriggerType.RUNBOTTOM)
|
if (isTouching_BOTTOM() && ctrlType == ControllingType.RUNBOTTOM)
|
||||||
velocity.y = PLAYER_JUMP_FORCE;
|
velocity.y = PLAYER_JUMP_FORCE;
|
||||||
else if(isTouching_TOP() && getType == GetTriggerType.RUNTOP)
|
else if(isTouching_TOP() && ctrlType == ControllingType.RUNTOP)
|
||||||
velocity.y = -PLAYER_JUMP_FORCE;
|
velocity.y = -PLAYER_JUMP_FORCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,9 +119,9 @@ public class PlayerEntity extends GravityEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fly() {
|
public void fly() {
|
||||||
if (!isTouching_BOTTOM() && getType == GetTriggerType.RUNBOTTOM)
|
if (!isTouching_BOTTOM() && ctrlType == ControllingType.RUNBOTTOM)
|
||||||
doFly = true;
|
doFly = true;
|
||||||
else if(isTouching_TOP() && getType == GetTriggerType.RUNTOP)
|
else if(isTouching_TOP() && ctrlType == ControllingType.RUNTOP)
|
||||||
doFly = true;
|
doFly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,25 +133,25 @@ public class CRGameInputProcessor implements InputProcessor, GestureListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pan(float x, float y, float deltaX, float deltaY) {
|
public boolean pan(float x, float y, float deltaX, float deltaY) {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean panStop(float x, float y, int pointer, int button) {
|
public boolean panStop(float x, float y, int pointer, int button) {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean zoom(float initialDistance, float distance) {
|
public boolean zoom(float initialDistance, float distance) {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) {
|
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
|
|
||||||
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
|
|
||||||
|
|
||||||
public class OptionMenuScreen implements Screen{
|
public class OptionMenuScreen implements Screen{
|
||||||
|
|
||||||
private Preferences prefs = Gdx.app.getPreferences("settings");
|
private Preferences prefs = Gdx.app.getPreferences("settings");
|
||||||
|
@ -58,8 +56,7 @@ public class OptionMenuScreen implements Screen{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) {
|
public void resize(int width, int height) {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,13 +113,13 @@ public class OptionMenuScreen implements Screen{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() {
|
public void pause() {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() {
|
public void resume() {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@ import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
import de.samdev.colorrunner.CRGame;
|
|
||||||
|
|
||||||
|
|
||||||
public class SplashScreen implements Screen {
|
public class SplashScreen implements Screen {
|
||||||
|
|
||||||
|
@ -47,7 +45,7 @@ public class SplashScreen implements Screen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) {
|
public void resize(int width, int height) {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,13 +69,13 @@ public class SplashScreen implements Screen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() {
|
public void pause() {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() {
|
public void resume() {
|
||||||
// TODO Auto-generated method stub
|
// NOP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue