summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c798d8)
raw | patch | inline | side by side (parent: 1c798d8)
author | fred-boy <fred-boy@protonmail.com> | |
Thu, 7 Feb 2019 20:09:50 +0000 (03:09 +0700) | ||
committer | fred-boy <fredboy@protonmail.com> | |
Sun, 29 Sep 2019 04:38:42 +0000 (11:38 +0700) |
diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java
index c77c9e08032e6efe725cb6be42d07f248873464d..0bbd9966f6a95af78c0f23313ede6657b053b102 100644 (file)
public static boolean SHOW_DEBUG = false;
public static int NEW_GAME_MODE = 0;
- private GameProc gp;
+ public static GameProc GP;
+
private Renderer renderer;
private MenuRenderer menuRenderer;
}
private void game(float delta) {
- gp.update(delta);
+ GP.update(delta);
}
private void menu() {
break;
case NEW_GAME:
- gp = new GameProc(NEW_GAME_MODE);
- renderer = gp.renderer;
- Gdx.input.setInputProcessor(new InputHandlerGame(gp));
+ GP = new GameProc();
+ GP.initGame(NEW_GAME_MODE);
+ renderer = GP.renderer;
+ Gdx.input.setInputProcessor(new InputHandlerGame());
CaveGame.STATE = AppState.GAME_PLAY;
break;
case LOAD_GAME:
- gp = GameSaver.load();
- renderer = gp.renderer;
- Gdx.input.setInputProcessor(new InputHandlerGame(gp));
+ GP = GameSaver.load();
+ renderer = GP.renderer;
+ Gdx.input.setInputProcessor(new InputHandlerGame());
CaveGame.STATE = AppState.GAME_PLAY;
break;
case SAVE_GAME:
- GameSaver.save(gp);
+ GameSaver.save(GP);
CaveGame.STATE = AppState.MENU_MAIN;
break;
break;
case GAME_PLAY:
case GAME_CREATIVE_INV:
- gp.resetRenderer();
- renderer = gp.renderer;
+ GP.resetRenderer();
+ renderer = GP.renderer;
break;
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java
index 8bfea89aad345ff07b257dba81527c258858bc2e..e2877e3d23c267ec4c7faea3442c0884f36f2d9c 100644 (file)
import ru.deadsoftware.cavecraft.misc.AppState;
import ru.deadsoftware.cavecraft.misc.Assets;
-public class GameInput {
-
- private GameProc gp;
+import static ru.deadsoftware.cavecraft.GameScreen.GP;
- public GameInput(GameProc gp) {
- this.gp = gp;
- }
+public class GameInput {
private boolean checkSwim() {
- return GameItems.isFluid(gp.world.getForeMap(gp.player.getMapX(), gp.player.getMapY()));
+ return GameItems.isFluid(GP.world.getForeMap(GP.player.getMapX(), GP.player.getMapY()));
}
private boolean insideCreativeInv(int screenX, int screenY) {
- return (screenX > gp.renderer.getWidth() / 2 - Assets.creativeInv.getRegionWidth() / 2 &&
- screenX < gp.renderer.getWidth() / 2 + Assets.creativeInv.getRegionWidth() / 2 &&
- screenY > gp.renderer.getHeight() / 2 - Assets.creativeInv.getRegionHeight() / 2 &&
- screenY < gp.renderer.getHeight() / 2 + Assets.creativeInv.getRegionHeight() / 2);
+ return (screenX > GP.renderer.getWidth() / 2 - Assets.creativeInv.getRegionWidth() / 2 &&
+ screenX < GP.renderer.getWidth() / 2 + Assets.creativeInv.getRegionWidth() / 2 &&
+ screenY > GP.renderer.getHeight() / 2 - Assets.creativeInv.getRegionHeight() / 2 &&
+ screenY < GP.renderer.getHeight() / 2 + Assets.creativeInv.getRegionHeight() / 2);
}
private void wasdPressed(int keycode) {
- if (gp.ctrlMode == 0 || !CaveGame.TOUCH) {
+ if (GP.ctrlMode == 0 || !CaveGame.TOUCH) {
switch (keycode) {
case Input.Keys.A:
- gp.player.mov.x = -GamePhysics.PL_SPEED;
- gp.player.setDir(0);
- if (CaveGame.TOUCH && checkSwim()) gp.player.swim = true;
+ GP.player.mov.x = -GamePhysics.PL_SPEED;
+ GP.player.setDir(0);
+ if (CaveGame.TOUCH && checkSwim()) GP.player.swim = true;
break;
case Input.Keys.D:
- gp.player.mov.x = GamePhysics.PL_SPEED;
- gp.player.setDir(1);
- if (CaveGame.TOUCH && checkSwim()) gp.player.swim = true;
+ GP.player.mov.x = GamePhysics.PL_SPEED;
+ GP.player.setDir(1);
+ if (CaveGame.TOUCH && checkSwim()) GP.player.swim = true;
break;
}
} else {
switch (keycode) {
case Input.Keys.A:
- gp.curX--;
+ GP.curX--;
break;
case Input.Keys.D:
- gp.curX++;
+ GP.curX++;
break;
case Input.Keys.W:
- gp.curY--;
+ GP.curY--;
break;
case Input.Keys.S:
- gp.curY++;
+ GP.curY++;
break;
}
- gp.blockDmg = 0;
+ GP.blockDmg = 0;
}
}
public void keyDown(int keycode) {
- gp.isKeyDown = true;
- gp.keyDownCode = keycode;
+ GP.isKeyDown = true;
+ GP.keyDownCode = keycode;
if (keycode == Input.Keys.W || keycode == Input.Keys.A ||
keycode == Input.Keys.S || keycode == Input.Keys.D) {
wasdPressed(keycode);
} else switch (keycode) {
case Input.Keys.ALT_LEFT:
if (CaveGame.TOUCH) {
- gp.ctrlMode++;
- if (gp.ctrlMode > 1) gp.ctrlMode = 0;
+ GP.ctrlMode++;
+ if (GP.ctrlMode > 1) GP.ctrlMode = 0;
}
break;
case Input.Keys.SPACE:
if (checkSwim()) {
- gp.player.swim = true;
- } else if (gp.player.canJump) {
- gp.player.mov.add(0, -7);
- } else if (!gp.player.flyMode && gp.player.gameMode == 1) {
- gp.player.flyMode = true;
- gp.player.mov.y = 0;
- } else if (gp.player.flyMode) {
- gp.player.mov.y = -GamePhysics.PL_SPEED;
+ GP.player.swim = true;
+ } else if (GP.player.canJump) {
+ GP.player.mov.add(0, -7);
+ } else if (!GP.player.flyMode && GP.player.gameMode == 1) {
+ GP.player.flyMode = true;
+ GP.player.mov.y = 0;
+ } else if (GP.player.flyMode) {
+ GP.player.mov.y = -GamePhysics.PL_SPEED;
}
break;
case Input.Keys.CONTROL_LEFT:
- gp.player.mov.y = GamePhysics.PL_SPEED;
+ GP.player.mov.y = GamePhysics.PL_SPEED;
break;
case Input.Keys.E:
- if (CaveGame.STATE == AppState.GAME_PLAY) switch (gp.player.gameMode) {
+ if (CaveGame.STATE == AppState.GAME_PLAY) switch (GP.player.gameMode) {
case 0:
//TODO survival inv
break;
break;
case Input.Keys.G:
- gp.mobs.add(new Pig(gp.curX * 16, gp.curY * 16));
+ GP.mobs.add(new Pig(GP.curX * 16, GP.curY * 16));
+ break;
+
+ case Input.Keys.Q:
+ GP.world.placeToForeground(GP.curX, GP.curY, 8);
break;
case Input.Keys.ESCAPE:
switch (keycode) {
case Input.Keys.A:
case Input.Keys.D:
- gp.player.mov.x = 0;
- if (CaveGame.TOUCH && gp.player.swim) gp.player.swim = false;
+ GP.player.mov.x = 0;
+ if (CaveGame.TOUCH && GP.player.swim) GP.player.swim = false;
break;
case Input.Keys.SPACE:
case Input.Keys.CONTROL_LEFT:
- if (gp.player.flyMode) gp.player.mov.y = 0;
- if (gp.player.swim) gp.player.swim = false;
+ if (GP.player.flyMode) GP.player.mov.y = 0;
+ if (GP.player.swim) GP.player.swim = false;
break;
}
}
public void touchDown(int screenX, int screenY, int button) {
- gp.touchDownTime = TimeUtils.millis();
- gp.isTouchDown = true;
- gp.touchDownBtn = button;
- gp.touchDownX = screenX;
- gp.touchDownY = screenY;
+ GP.touchDownTime = TimeUtils.millis();
+ GP.isTouchDown = true;
+ GP.touchDownBtn = button;
+ GP.touchDownX = screenX;
+ GP.touchDownY = screenY;
}
public void touchUp(int screenX, int screenY, int button) {
- if (CaveGame.TOUCH && gp.isKeyDown) {
- keyUp(gp.keyDownCode);
- gp.isKeyDown = false;
+ if (CaveGame.TOUCH && GP.isKeyDown) {
+ keyUp(GP.keyDownCode);
+ GP.isKeyDown = false;
}
- if (gp.isTouchDown) {
+ if (GP.isTouchDown) {
if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && insideCreativeInv(screenX, screenY)) {
- int ix = (int) (screenX - (gp.renderer.getWidth() / 2 - Assets.creativeInv.getRegionWidth() / 2 + 8)) / 18;
- int iy = (int) (screenY - (gp.renderer.getHeight() / 2 - Assets.creativeInv.getRegionHeight() / 2 + 18)) / 18;
- int item = gp.creativeScroll * 8 + (ix + iy * 8);
+ int ix = (int) (screenX - (GP.renderer.getWidth() / 2 - Assets.creativeInv.getRegionWidth() / 2 + 8)) / 18;
+ int iy = (int) (screenY - (GP.renderer.getHeight() / 2 - Assets.creativeInv.getRegionHeight() / 2 + 18)) / 18;
+ int item = GP.creativeScroll * 8 + (ix + iy * 8);
if (ix >= 8 || ix < 0 || iy < 0 || iy >= 5) item = -1;
if (item >= 0 && item < GameItems.getItemsSize()) {
for (int i = 8; i > 0; i--) {
- gp.player.inv[i] = gp.player.inv[i - 1];
+ GP.player.inv[i] = GP.player.inv[i - 1];
}
- gp.player.inv[0] = item;
+ GP.player.inv[0] = item;
}
} else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) {
CaveGame.STATE = AppState.GAME_PLAY;
} else if (screenY < Assets.invBar.getRegionHeight() &&
- screenX > gp.renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 &&
- screenX < gp.renderer.getWidth() / 2 + Assets.invBar.getRegionWidth() / 2) {
- gp.player.invSlot = (int) ((screenX - (gp.renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2)) / 20);
+ screenX > GP.renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 &&
+ screenX < GP.renderer.getWidth() / 2 + Assets.invBar.getRegionWidth() / 2) {
+ GP.player.invSlot = (int) ((screenX - (GP.renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2)) / 20);
} else if (button == Input.Buttons.RIGHT) {
- gp.useItem(gp.curX, gp.curY,
- gp.player.inv[gp.player.invSlot], false);
+ GP.useItem(GP.curX, GP.curY,
+ GP.player.inv[GP.player.invSlot], false);
} else if (button == Input.Buttons.LEFT) {
- gp.blockDmg = 0;
+ GP.blockDmg = 0;
}
}
- gp.isTouchDown = false;
+ GP.isTouchDown = false;
}
public void touchDragged(int screenX, int screenY) {
- if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && Math.abs(screenY - gp.touchDownY) > 16) {
+ if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && Math.abs(screenY - GP.touchDownY) > 16) {
if (insideCreativeInv(screenX, screenY)) {
- gp.creativeScroll -= (screenY - gp.touchDownY) / 16;
- gp.touchDownX = screenX;
- gp.touchDownY = screenY;
- if (gp.creativeScroll < 0) gp.creativeScroll = 0;
- if (gp.creativeScroll > gp.maxCreativeScroll)
- gp.creativeScroll = gp.maxCreativeScroll;
+ GP.creativeScroll -= (screenY - GP.touchDownY) / 16;
+ GP.touchDownX = screenX;
+ GP.touchDownY = screenY;
+ if (GP.creativeScroll < 0) GP.creativeScroll = 0;
+ if (GP.creativeScroll > GP.maxCreativeScroll)
+ GP.creativeScroll = GP.maxCreativeScroll;
}
}
}
public void scrolled(int amount) {
switch (CaveGame.STATE) {
case GAME_PLAY:
- gp.player.invSlot += amount;
- if (gp.player.invSlot < 0) gp.player.invSlot = 8;
- if (gp.player.invSlot > 8) gp.player.invSlot = 0;
+ GP.player.invSlot += amount;
+ if (GP.player.invSlot < 0) GP.player.invSlot = 8;
+ if (GP.player.invSlot > 8) GP.player.invSlot = 0;
break;
case GAME_CREATIVE_INV:
- gp.creativeScroll += amount;
- if (gp.creativeScroll < 0) gp.creativeScroll = 0;
- if (gp.creativeScroll > gp.maxCreativeScroll)
- gp.creativeScroll = gp.maxCreativeScroll;
+ GP.creativeScroll += amount;
+ if (GP.creativeScroll < 0) GP.creativeScroll = 0;
+ if (GP.creativeScroll > GP.maxCreativeScroll)
+ GP.creativeScroll = GP.maxCreativeScroll;
break;
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameItems.java b/core/src/ru/deadsoftware/cavecraft/game/GameItems.java
index 52c2e75a2af1cd52fa7bee88d710f3e0e6abac76..42b0a75f882df2082963859acbb4e34a21ede9ce 100644 (file)
private static ArrayList<Item> items = new ArrayList<Item>();
public static boolean isFluid(int bl) {
- return (bl == 8 || bl == 9 || bl == 60 || bl == 61 || bl == 62 || bl == 63 || bl == 64 || bl == 65 || bl == 66 || bl == 67);
+ return isWater(bl) || isLava(bl);
}
public static boolean isWater(int bl) {
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index 88791dc67a59d337235c8a79d55c9080cb117c04..80274ab459da9ea957ef42d3dc77a911540fbbaa 100644 (file)
import java.util.Iterator;
+import static ru.deadsoftware.cavecraft.GameScreen.GP;
+
class GamePhysics {
static final int PL_SPEED = 2;
- private GameProc gp;
-
- private Vector2 gravity;
-
- GamePhysics(GameProc gp) {
- this.gp = gp;
- gravity = new Vector2(0, .9f);
- }
+ private Vector2 gravity = new Vector2(0, .9f);;
private boolean checkJump(Rectangle rect, int dir) {
int bl;
int blX = (int) (rect.x + rect.width * dir - 8 + 16 * dir);
int blY = (int) (rect.y + rect.height - 8);
- bl = gp.world.getForeMap(blX / 16, blY / 16);
+ bl = GP.world.getForeMap(blX / 16, blY / 16);
if (checkColl(new Rectangle(blX, rect.y - 18, rect.width, rect.height))) bl = 0;
return (bl > 0 && GameItems.getBlock(bl).toJump() &&
int maxX = (int) ((rect.x + rect.width / 2) / 16) + 4;
int maxY = (int) ((rect.y + rect.height / 2) / 16) + 4;
if (minY < 0) minY = 0;
- if (maxY > gp.world.getHeight()) maxY = gp.world.getHeight();
+ if (maxY > GP.world.getHeight()) maxY = GP.world.getHeight();
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
- bl = gp.world.getForeMap(x, y);
+ bl = GP.world.getForeMap(x, y);
if (bl > 0 && GameItems.getBlock(bl).hasCollision()) {
if (Intersector.overlaps(rect, GameItems.getBlock(bl).getRect(x, y))) {
return true;
}
private int getBlock(Rectangle rect) {
- return gp.world.getForeMap((int) (rect.x + rect.width / 2) / 16, (int) (rect.y + rect.height / 8 * 7) / 16);
+ return GP.world.getForeMap((int) (rect.x + rect.width / 2) / 16, (int) (rect.y + rect.height / 8 * 7) / 16);
}
private void dropPhy(Drop drop) {
- if (drop.closeToPlayer(gp) > 0) {
- drop.moveToPlayer(gp);
+ if (drop.closeToPlayer() > 0) {
+ drop.moveToPlayer();
} else {
if (drop.move.x >= .5f) drop.move.x -= .5f;
else if (drop.move.x <= -.5f) drop.move.x += .5f;
if (drop.move.y < 9) drop.move.y += gravity.y / 4;
}
drop.pos.add(drop.move);
- if (drop.pos.x + 8 > gp.world.getWidthPx()) drop.pos.x -= gp.world.getWidthPx();
- else if (drop.pos.x < 0) drop.pos.x += gp.world.getWidthPx();
+ if (drop.pos.x + 8 > GP.world.getWidthPx()) drop.pos.x -= GP.world.getWidthPx();
+ else if (drop.pos.x < 0) drop.pos.x += GP.world.getWidthPx();
drop.pos.y = MathUtils.round(drop.pos.y);
while (checkColl(drop.getRect())) {
drop.pos.y--;
if (mob.canJump) mob.changeDir();
}
}
- if (mob.pos.x + mob.getWidth() / 2 < 0) mob.pos.x += gp.world.getWidthPx();
- if (mob.pos.x + mob.getWidth() / 2 > gp.world.getWidthPx()) mob.pos.x -= gp.world.getWidthPx();
+ if (mob.pos.x + mob.getWidth() / 2 < 0) mob.pos.x += GP.world.getWidthPx();
+ if (mob.pos.x + mob.getWidth() / 2 > GP.world.getWidthPx()) mob.pos.x -= GP.world.getWidthPx();
}
private void mobYColl(Mob mob) {
while (checkColl(mob.getRect())) mob.pos.y += d;
mob.mov.y = 0;
if (mob.getType() > 0) {
- gp.world.setForeMap(mob.getMapX(), mob.getMapY(), mob.getType());
+ GP.world.setForeMap(mob.getMapX(), mob.getMapY(), mob.getType());
mob.kill();
}
} else {
mob.canJump = false;
}
- if (mob.pos.y > gp.world.getHeightPx()) {
+ if (mob.pos.y > GP.world.getHeightPx()) {
mob.kill();
}
}
void update(float delta) {
//TODO use delta time
- for (Iterator<Drop> it = gp.drops.iterator(); it.hasNext(); ) {
+ for (Iterator<Drop> it = GP.drops.iterator(); it.hasNext(); ) {
Drop drop = it.next();
dropPhy(drop);
- if (Intersector.overlaps(drop.getRect(), gp.player.getRect())) drop.pickUpDrop(gp.player);
+ if (Intersector.overlaps(drop.getRect(), GP.player.getRect())) drop.pickUpDrop(GP.player);
if (drop.pickedUp) it.remove();
}
- for (Iterator<Mob> it = gp.mobs.iterator(); it.hasNext(); ) {
+ for (Iterator<Mob> it = GP.mobs.iterator(); it.hasNext(); ) {
Mob mob = it.next();
mob.ai();
mobPhy(mob);
if (mob.isDead()) it.remove();
}
- playerPhy(gp.player);
- if (gp.player.isDead()) gp.player.respawn(gp.world);
+ playerPhy(GP.player);
+ if (GP.player.isDead()) GP.player.respawn();
- gp.renderer.setCamPos(
- gp.player.pos.x + gp.player.getWidth() / 2 - gp.renderer.getWidth() / 2,
- gp.player.pos.y + gp.player.getHeight() / 2 - gp.renderer.getHeight() / 2);
+ GP.renderer.setCamPos(
+ GP.player.pos.x + GP.player.getWidth() / 2 - GP.renderer.getWidth() / 2,
+ GP.player.pos.y + GP.player.getHeight() / 2 - GP.renderer.getHeight() / 2);
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index 8910d498670f0ba295af780595406fa815289927..d946942fdfa53bfaa1a787288e0c98a3f965c0e9 100644 (file)
int creativeScroll, maxCreativeScroll;
int blockDmg = 0;
-
- public GameProc(int gameMode) {
+ public void initGame(int gameMode) {
world = new GameWorld();
world.generate(1024, 256);
- player = new Player(world, gameMode);
+ player = new Player(gameMode);
drops = new ArrayList<Drop>();
mobs = new ArrayList<Mob>();
for (int i = 0; i < 16; i++) {
mobs.add(new Pig(i * 256, 196 * 16));
}
- physics = new GamePhysics(this);
+ physics = new GamePhysics();
if (CaveGame.TOUCH) {
- renderer = new GameRenderer(this, 320,
+ renderer = new GameRenderer(320,
320 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
} else {
ctrlMode = 1;
- renderer = new GameRenderer(this, 480,
+ renderer = new GameRenderer(480,
480 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
}
maxCreativeScroll = GameItems.getItemsSize() / 8;
public void resetRenderer() {
if (CaveGame.TOUCH) {
- renderer = new GameRenderer(this, 320,
+ renderer = new GameRenderer(320,
320 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
} else {
- renderer = new GameRenderer(this, 480,
+ renderer = new GameRenderer(480,
480 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index 3d65ddc68faf2db0ed563a673991698b3ace6b8e..c5ec8df7aa5a7c842b9df33c2fa6916282226336 100644 (file)
import ru.deadsoftware.cavecraft.misc.Assets;
import ru.deadsoftware.cavecraft.misc.Renderer;
-public class GameRenderer extends Renderer {
+import static ru.deadsoftware.cavecraft.GameScreen.GP;
- private GameProc gp;
+public class GameRenderer extends Renderer {
- GameRenderer(GameProc gp, float width, float heigth) {
- super(width, heigth);
+ GameRenderer(float width, float height) {
+ super(width, height);
Gdx.gl.glClearColor(0f, .6f, .6f, 1f);
- this.gp = gp;
}
private float drawX(int x) {
}
private void drawWreck(int bl) {
- if (gp.blockDmg > 0) {
+ if (GP.blockDmg > 0) {
spriter.draw(Assets.wreck[
- 10 * gp.blockDmg /
+ 10 * GP.blockDmg /
GameItems.getBlock(bl).getHp()],
- gp.curX * 16 - getCamX(),
- gp.curY * 16 - getCamY());
+ GP.curX * 16 - getCamX(),
+ GP.curY * 16 - getCamY());
}
}
private void drawBlock(int x, int y, boolean drawBG) {
if (drawBG) {
- if ((gp.world.getForeMap(x, y) == 0 || GameItems.getBlock(gp.world.getForeMap(x, y)).isTransparent())
- && gp.world.getBackMap(x, y) > 0) {
+ if ((GP.world.getForeMap(x, y) == 0 || GameItems.getBlock(GP.world.getForeMap(x, y)).isTransparent())
+ && GP.world.getBackMap(x, y) > 0) {
spriter.draw(
- Assets.blockTex[GameItems.getBlock(gp.world.getBackMap(x, y)).getTex()],
+ Assets.blockTex[GameItems.getBlock(GP.world.getBackMap(x, y)).getTex()],
drawX(x), drawY(y));
- if (gp.world.getForeMap(x, y) == 0 && x == gp.curX && y == gp.curY)
- drawWreck(gp.world.getBackMap(gp.curX, gp.curY));
+ if (GP.world.getForeMap(x, y) == 0 && x == GP.curX && y == GP.curY)
+ drawWreck(GP.world.getBackMap(GP.curX, GP.curY));
}
}
- if (gp.world.getForeMap(x, y) > 0 && GameItems.getBlock(gp.world.getForeMap(x, y)).isBackground() == drawBG) {
+ if (GP.world.getForeMap(x, y) > 0 && GameItems.getBlock(GP.world.getForeMap(x, y)).isBackground() == drawBG) {
spriter.draw(
- Assets.blockTex[GameItems.getBlock(gp.world.getForeMap(x, y)).getTex()],
+ Assets.blockTex[GameItems.getBlock(GP.world.getForeMap(x, y)).getTex()],
drawX(x), drawY(y));
- if (x == gp.curX && y == gp.curY)
- drawWreck(gp.world.getForeMap(gp.curX, gp.curY));
+ if (x == GP.curX && y == GP.curY)
+ drawWreck(GP.world.getForeMap(GP.curX, GP.curY));
}
}
int maxX = (int) ((getCamX() + getWidth()) / 16) + 1;
int maxY = (int) ((getCamY() + getHeight()) / 16) + 1;
if (minY < 0) minY = 0;
- if (maxY > gp.world.getHeight()) maxY = gp.world.getHeight();
+ if (maxY > GP.world.getHeight()) maxY = GP.world.getHeight();
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
drawBlock(x, y, bg);
shaper.setColor(0f, 0f, 0f, .5f);
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
- if ((gp.world.getForeMap(x, y) == 0 || GameItems.getBlock(gp.world.getForeMap(x, y)).isTransparent())
- && gp.world.getBackMap(x, y) > 0) shaper.rect(drawX(x), drawY(y), 16, 16);
+ if ((GP.world.getForeMap(x, y) == 0 || GameItems.getBlock(GP.world.getForeMap(x, y)).isTransparent())
+ && GP.world.getBackMap(x, y) > 0) shaper.rect(drawX(x), drawY(y), 16, 16);
}
}
shaper.end();
float mobDrawX = mob.pos.x - getCamX();
float mobDrawY = mob.pos.y - getCamY();
- if (mobDrawX + mob.getWidth() - gp.world.getWidthPx() >= 0 && mobDrawX - gp.world.getWidthPx() <= getWidth())
- mob.draw(spriter, mobDrawX - gp.world.getWidthPx(), mobDrawY);
+ if (mobDrawX + mob.getWidth() - GP.world.getWidthPx() >= 0 && mobDrawX - GP.world.getWidthPx() <= getWidth())
+ mob.draw(spriter, mobDrawX - GP.world.getWidthPx(), mobDrawY);
if (mobDrawX + mob.getWidth() >= 0 && mobDrawX <= getWidth())
mob.draw(spriter, mobDrawX, mobDrawY);
- if (mobDrawX + mob.getWidth() + gp.world.getWidthPx() >= 0 && mobDrawX + gp.world.getWidthPx() <= getWidth())
- mob.draw(spriter, mobDrawX + gp.world.getWidthPx(), mobDrawY);
+ if (mobDrawX + mob.getWidth() + GP.world.getWidthPx() >= 0 && mobDrawX + GP.world.getWidthPx() <= getWidth())
+ mob.draw(spriter, mobDrawX + GP.world.getWidthPx(), mobDrawY);
}
private void drawDrop(Drop drop) {
switch (GameItems.getItem(drop.getId()).getType()) {
case 0:
Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition(
- drop.pos.x - getCamX() - gp.world.getWidthPx(),
+ drop.pos.x - getCamX() - GP.world.getWidthPx(),
drop.pos.y - getCamY());
Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter);
Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition(
drop.pos.y - getCamY());
Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter);
Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition(
- drop.pos.x - getCamX() + gp.world.getWidthPx(),
+ drop.pos.x - getCamX() + GP.world.getWidthPx(),
drop.pos.y - getCamY());
Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter);
}
float y = getHeight() / 2 - (float) Assets.creativeInv.getRegionHeight() / 2;
spriter.draw(Assets.creativeInv, x, y);
spriter.draw(Assets.creativeScr, x + 156,
- y + 18 + (gp.creativeScroll * (72f / gp.maxCreativeScroll)));
- for (int i = gp.creativeScroll * 8; i < gp.creativeScroll * 8 + 40; i++) {
+ y + 18 + (GP.creativeScroll * (72f / GP.maxCreativeScroll)));
+ for (int i = GP.creativeScroll * 8; i < GP.creativeScroll * 8 + 40; i++) {
if (i > 0 && i < GameItems.getItemsSize())
switch (GameItems.getItem(i).getType()) {
case 0:
spriter.draw(Assets.blockTex[GameItems.getItem(i).getTex()],
- x + 8 + ((i - gp.creativeScroll * 8) % 8) * 18,
- y + 18 + ((i - gp.creativeScroll * 8) / 8) * 18);
+ x + 8 + ((i - GP.creativeScroll * 8) % 8) * 18,
+ y + 18 + ((i - GP.creativeScroll * 8) / 8) * 18);
break;
case 1:
spriter.draw(Assets.itemTex[GameItems.getItem(i).getTex()],
- x + 8 + ((i - gp.creativeScroll * 8) % 8) * 18,
- y + 18 + ((i - gp.creativeScroll * 8) / 8) * 18);
+ x + 8 + ((i - GP.creativeScroll * 8) % 8) * 18,
+ y + 18 + ((i - GP.creativeScroll * 8) / 8) * 18);
break;
}
}
for (int i = 0; i < 9; i++) {
- if (gp.player.inv[i] > 0)
- switch (GameItems.getItem(gp.player.inv[i]).getType()) {
+ if (GP.player.inv[i] > 0)
+ switch (GameItems.getItem(GP.player.inv[i]).getType()) {
case 0:
- spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inv[i]).getTex()],
+ spriter.draw(Assets.blockTex[GameItems.getItem(GP.player.inv[i]).getTex()],
x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24);
break;
case 1:
- spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inv[i]).getTex()],
+ spriter.draw(Assets.itemTex[GameItems.getItem(GP.player.inv[i]).getTex()],
x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24);
break;
}
}
private void drawGUI() {
- if (gp.world.getForeMap(gp.curX, gp.curY) > 0 ||
- gp.world.getBackMap(gp.curX, gp.curY) > 0 ||
- gp.ctrlMode == 1 ||
+ if (GP.world.getForeMap(GP.curX, GP.curY) > 0 ||
+ GP.world.getBackMap(GP.curX, GP.curY) > 0 ||
+ GP.ctrlMode == 1 ||
!CaveGame.TOUCH)
spriter.draw(Assets.guiCur,
- gp.curX * 16 - getCamX(),
- gp.curY * 16 - getCamY());
+ GP.curX * 16 - getCamX(),
+ GP.curY * 16 - getCamY());
spriter.draw(Assets.invBar, getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2, 0);
for (int i = 0; i < 9; i++) {
- if (gp.player.inv[i] > 0) {
- switch (GameItems.getItem(gp.player.inv[i]).getType()) {
+ if (GP.player.inv[i] > 0) {
+ switch (GameItems.getItem(GP.player.inv[i]).getType()) {
case 0:
- spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inv[i]).getTex()],
+ spriter.draw(Assets.blockTex[GameItems.getItem(GP.player.inv[i]).getTex()],
getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 + 3 + i * 20,
3);
break;
case 1:
- spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inv[i]).getTex()],
+ spriter.draw(Assets.itemTex[GameItems.getItem(GP.player.inv[i]).getTex()],
getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 + 3 + i * 20,
3);
break;
}
}
spriter.draw(Assets.invBarCur,
- getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 - 1 + 20 * gp.player.invSlot,
+ getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 - 1 + 20 * GP.player.invSlot,
-1);
}
spriter.draw(Assets.touchLMB, getWidth() - 52, getHeight() - 26);
spriter.draw(Assets.touchRMB, getWidth() - 26, getHeight() - 26);
spriter.draw(Assets.touchMode, 78, getHeight() - 26);
- if (gp.ctrlMode == 1) {
+ if (GP.ctrlMode == 1) {
Assets.shade.setPosition(83, getHeight() - 21);
Assets.shade.draw(spriter);
}
private void drawGamePlay() {
drawWorld(true);
- gp.player.draw(spriter, gp.player.pos.x - getCamX() - 2, gp.player.pos.y - getCamY());
- for (Mob mob : gp.mobs) drawMob(mob);
- for (Drop drop : gp.drops) drawDrop(drop);
+ GP.player.draw(spriter, GP.player.pos.x - getCamX() - 2, GP.player.pos.y - getCamY());
+ for (Mob mob : GP.mobs) drawMob(mob);
+ for (Drop drop : GP.drops) drawDrop(drop);
drawWorld(false);
drawGUI();
}
if (GameScreen.SHOW_DEBUG) {
drawString("FPS: " + GameScreen.FPS, 0, 0);
- drawString("X: " + (int) (gp.player.pos.x / 16), 0, 10);
- drawString("Y: " + (int) (gp.player.pos.y / 16), 0, 20);
- drawString("CurX: " + gp.curX, 0, 30);
- drawString("CurY: " + gp.curY, 0, 40);
- drawString("Mobs: " + gp.mobs.size(), 0, 50);
- drawString("Drops: " + gp.drops.size(), 0, 60);
- drawString("Block: " + GameItems.getBlockKey(gp.world.getForeMap(gp.curX, gp.curY)), 0, 70);
- drawString("Game mode: " + gp.player.gameMode, 0, 80);
+ drawString("X: " + (int) (GP.player.pos.x / 16), 0, 10);
+ drawString("Y: " + (int) (GP.player.pos.y / 16), 0, 20);
+ drawString("CurX: " + GP.curX, 0, 30);
+ drawString("CurY: " + GP.curY, 0, 40);
+ drawString("Mobs: " + GP.mobs.size(), 0, 50);
+ drawString("Drops: " + GP.drops.size(), 0, 60);
+ drawString("Block: " + GameItems.getBlockKey(GP.world.getForeMap(GP.curX, GP.curY)), 0, 70);
+ drawString("Game mode: " + GP.player.gameMode, 0, 80);
}
spriter.end();
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java
index 00d91bf3b4ec9f50860cdcbb1969c44c8dbc5f64..5f8743dc8710a3f054b597fea29a9be5a19e6538 100644 (file)
loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav")),
loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav"))
);
- gameProc.physics = new GamePhysics(gameProc);
+ gameProc.physics = new GamePhysics();
gameProc.resetRenderer();
} catch (Exception e) {
Gdx.app.error("GameSaver", e.getMessage(), e);
diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java
index d2139c76bef1008a45b8bee9916099d77bf90fba..f541daa2090b2855ec4fc102262f5944a6d9a16c 100644 (file)
import java.io.Serializable;
+import static ru.deadsoftware.cavecraft.GameScreen.GP;
+
public class Drop implements Serializable {
private int id;
move = new Vector2(0, -1);
}
- public int closeToPlayer(GameProc gp) {
- boolean c1 = Intersector.overlaps(new Rectangle(gp.player.pos.x - 16, gp.player.pos.y - 16, gp.player.getWidth() + 32, gp.player.getHeight() + 32), getRect());
- boolean c2 = Intersector.overlaps(new Rectangle((gp.player.pos.x + gp.world.getWidthPx()) - 16, gp.player.pos.y - 16, gp.player.getWidth() + 32, gp.player.getHeight() + 32), getRect());
- boolean c3 = Intersector.overlaps(new Rectangle((gp.player.pos.x - gp.world.getWidthPx()) - 16, gp.player.pos.y - 16, gp.player.getWidth() + 32, gp.player.getHeight() + 32), getRect());
+ public int closeToPlayer() {
+ boolean c1 = Intersector.overlaps(new Rectangle(GP.player.pos.x - 16, GP.player.pos.y - 16, GP.player.getWidth() + 32, GP.player.getHeight() + 32), getRect());
+ boolean c2 = Intersector.overlaps(new Rectangle((GP.player.pos.x + GP.world.getWidthPx()) - 16, GP.player.pos.y - 16, GP.player.getWidth() + 32, GP.player.getHeight() + 32), getRect());
+ boolean c3 = Intersector.overlaps(new Rectangle((GP.player.pos.x - GP.world.getWidthPx()) - 16, GP.player.pos.y - 16, GP.player.getWidth() + 32, GP.player.getHeight() + 32), getRect());
if (c1) return 1;
if (c2) return 2;
if (c3) return 3;
return 0;
}
- public void moveToPlayer(GameProc gp) {
- int ctp = closeToPlayer(gp);
+ public void moveToPlayer() {
+ int ctp = closeToPlayer();
if (ctp > 0) {
- float px = gp.player.pos.x;
- float py = gp.player.pos.y;
+ float px = GP.player.pos.x;
+ float py = GP.player.pos.y;
switch (ctp) {
case 2:
- px += gp.world.getWidthPx();
+ px += GP.world.getWidthPx();
break;
case 3:
- px -= gp.world.getWidthPx();
+ px -= GP.world.getWidthPx();
break;
}
float dx = 0, dy = 0;
- if (px + gp.player.getWidth() < pos.x + 4) dx = -.5f;
+ if (px + GP.player.getWidth() < pos.x + 4) dx = -.5f;
else if (px > pos.x + 4) dx = .5f;
- if (py + gp.player.getHeight() < pos.y + 4) dy = -.5f;
+ if (py + GP.player.getHeight() < pos.y + 4) dy = -.5f;
else if (py > pos.y + 4) dy = .5f;
move.add(dx, dy);
if (move.x > 2) move.x = 1;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java
index 5810eb55a047e86b8977341e32256c3ecd491b3c..93f68b5d43243e09c11251fb3d19f018d7218a8a 100644 (file)
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import ru.deadsoftware.cavecraft.game.GameItems;
-import ru.deadsoftware.cavecraft.game.GameWorld;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
import ru.deadsoftware.cavecraft.misc.Assets;
import java.io.Serializable;
+import static ru.deadsoftware.cavecraft.GameScreen.GP;
+
public class Player extends Mob implements Serializable {
public int[] inv;
public int gameMode;
public boolean swim;
- public Player(GameWorld world, int gameMode) {
+ public Player(int gameMode) {
super(0, 0, 4, 30, 1, true);
this.gameMode = gameMode;
inv = new int[9];
- pos = getSpawnPoint(world).cpy();
+ pos = getSpawnPoint().cpy();
swim = false;
}
- public void respawn(GameWorld world) {
- pos.set(getSpawnPoint(world));
+ public void respawn() {
+ pos.set(getSpawnPoint());
mov.setZero();
}
- private Vector2 getSpawnPoint(GameWorld world) {
+ private Vector2 getSpawnPoint() {
int x = 0, y;
- for (y = 0; y < world.getHeight(); y++) {
- if (y == world.getHeight() - 1) {
+ for (y = 0; y < GP.world.getHeight(); y++) {
+ if (y == GP.world.getHeight() - 1) {
y = 60;
- world.setForeMap(x, y, 1);
+ GP.world.setForeMap(x, y, 1);
break;
}
- if (world.getForeMap(x, y) > 0 && GameItems.getBlock(world.getForeMap(x, y)).hasCollision()) break;
+ if (GP.world.getForeMap(x, y) > 0 && GameItems.getBlock(GP.world.getForeMap(x, y)).hasCollision()) break;
}
return new Vector2(x * 16 + 8 - (float) getWidth() / 2, (float) y * 16 - getHeight());
}
diff --git a/core/src/ru/deadsoftware/cavecraft/misc/InputHandlerGame.java b/core/src/ru/deadsoftware/cavecraft/misc/InputHandlerGame.java
index 6a912ac355f4d5145e144d68d84b6d785cfc8ebf..b8460e018de1eab888bf21fe902043ba853c0c4b 100644 (file)
import com.badlogic.gdx.InputProcessor;
import ru.deadsoftware.cavecraft.CaveGame;
import ru.deadsoftware.cavecraft.game.GameInput;
-import ru.deadsoftware.cavecraft.game.GameProc;
import static ru.deadsoftware.cavecraft.GameScreen.getHeight;
import static ru.deadsoftware.cavecraft.GameScreen.getWidth;
+import static ru.deadsoftware.cavecraft.GameScreen.GP;
public class InputHandlerGame implements InputProcessor {
- private GameProc gp;
private GameInput gameInput;
- public InputHandlerGame(GameProc gp) {
- this.gp = gp;
- this.gameInput = new GameInput(gp);
+ public InputHandlerGame() {
+ this.gameInput = new GameInput();
}
@Override
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
- screenX *= gp.renderer.getWidth() / getWidth();
- screenY *= gp.renderer.getHeight() / getHeight();
+ screenX *= GP.renderer.getWidth() / getWidth();
+ screenY *= GP.renderer.getHeight() / getHeight();
if (CaveGame.TOUCH) {
- if (screenX > 26 && screenX < 52 && screenY > gp.renderer.getHeight() - 52 &&
- screenY < gp.renderer.getHeight() - 26) {
- if (gp.ctrlMode == 1) gameInput.keyDown(Input.Keys.W);
+ if (screenX > 26 && screenX < 52 && screenY > GP.renderer.getHeight() - 52 &&
+ screenY < GP.renderer.getHeight() - 26) {
+ if (GP.ctrlMode == 1) gameInput.keyDown(Input.Keys.W);
else gameInput.keyDown(Input.Keys.SPACE);
- } else if (screenX > 0 && screenX < 26 && screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > 0 && screenX < 26 && screenY > GP.renderer.getHeight() - 26) {
gameInput.keyDown(Input.Keys.A);
- } else if (screenX > 26 && screenX < 52 && screenY > gp.renderer.getHeight() - 26) {
- if (gp.ctrlMode == 1) gameInput.keyDown(Input.Keys.S);
+ } else if (screenX > 26 && screenX < 52 && screenY > GP.renderer.getHeight() - 26) {
+ if (GP.ctrlMode == 1) gameInput.keyDown(Input.Keys.S);
else gameInput.keyDown(Input.Keys.CONTROL_LEFT);
- } else if (screenX > 52 && screenX < 78 && screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > 52 && screenX < 78 && screenY > GP.renderer.getHeight() - 26) {
gameInput.keyDown(Input.Keys.D);
- } else if (screenX > 78 && screenX < 104 && screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > 78 && screenX < 104 && screenY > GP.renderer.getHeight() - 26) {
gameInput.keyDown(Input.Keys.ALT_LEFT);
- } else if (screenX > gp.renderer.getWidth() - 52 && screenX < gp.renderer.getWidth() - 26 &&
- screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > GP.renderer.getWidth() - 52 && screenX < GP.renderer.getWidth() - 26 &&
+ screenY > GP.renderer.getHeight() - 26) {
gameInput.touchDown(screenX, screenY, Input.Buttons.LEFT);
- } else if (screenX > gp.renderer.getWidth() - 26 && screenY > screenY - 26) {
+ } else if (screenX > GP.renderer.getWidth() - 26 && screenY > screenY - 26) {
gameInput.touchDown(screenX, screenY, Input.Buttons.RIGHT);
} else {
gameInput.touchDown(screenX, screenY, -1);
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
- screenX *= gp.renderer.getWidth() / getWidth();
- screenY *= gp.renderer.getHeight() / getHeight();
+ screenX *= GP.renderer.getWidth() / getWidth();
+ screenY *= GP.renderer.getHeight() / getHeight();
if (CaveGame.TOUCH) {
- if (screenX > 26 && screenX < 52 && screenY > gp.renderer.getHeight() - 52 &&
- screenY < gp.renderer.getHeight() - 26) {
- if (gp.ctrlMode == 1) gameInput.keyUp(Input.Keys.W);
+ if (screenX > 26 && screenX < 52 && screenY > GP.renderer.getHeight() - 52 &&
+ screenY < GP.renderer.getHeight() - 26) {
+ if (GP.ctrlMode == 1) gameInput.keyUp(Input.Keys.W);
else gameInput.keyUp(Input.Keys.SPACE);
- } else if (screenX > 0 && screenX < 26 && screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > 0 && screenX < 26 && screenY > GP.renderer.getHeight() - 26) {
gameInput.keyUp(Input.Keys.A);
- } else if (screenX > 26 && screenX < 52 && screenY > gp.renderer.getHeight() - 26) {
- if (gp.ctrlMode == 1) gameInput.keyUp(Input.Keys.S);
+ } else if (screenX > 26 && screenX < 52 && screenY > GP.renderer.getHeight() - 26) {
+ if (GP.ctrlMode == 1) gameInput.keyUp(Input.Keys.S);
else gameInput.keyUp(Input.Keys.CONTROL_LEFT);
- } else if (screenX > 52 && screenX < 78 && screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > 52 && screenX < 78 && screenY > GP.renderer.getHeight() - 26) {
gameInput.keyUp(Input.Keys.D);
- } else if (screenX > 78 && screenX < 104 && screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > 78 && screenX < 104 && screenY > GP.renderer.getHeight() - 26) {
gameInput.keyUp(Input.Keys.ALT_LEFT);
- } else if (screenX > gp.renderer.getWidth() - 52 && screenX < gp.renderer.getWidth() - 26 &&
- screenY > gp.renderer.getHeight() - 26) {
+ } else if (screenX > GP.renderer.getWidth() - 52 && screenX < GP.renderer.getWidth() - 26 &&
+ screenY > GP.renderer.getHeight() - 26) {
gameInput.touchUp(screenX, screenY, Input.Buttons.LEFT);
- } else if (screenX > gp.renderer.getWidth() - 26 && screenY > screenY - 26) {
+ } else if (screenX > GP.renderer.getWidth() - 26 && screenY > screenY - 26) {
gameInput.touchUp(screenX, screenY, Input.Buttons.RIGHT);
} else {
gameInput.touchUp(screenX, screenY, -1);
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
- screenX *= gp.renderer.getWidth() / getWidth();
- screenY *= gp.renderer.getHeight() / getHeight();
- if (gp.isKeyDown && (screenX > 78 || screenY < gp.renderer.getHeight() - 52)) {
- gameInput.keyUp(gp.keyDownCode);
+ screenX *= GP.renderer.getWidth() / getWidth();
+ screenY *= GP.renderer.getHeight() / getHeight();
+ if (GP.isKeyDown && (screenX > 78 || screenY < GP.renderer.getHeight() - 52)) {
+ gameInput.keyUp(GP.keyDownCode);
} else {
gameInput.touchDragged(screenX, screenY);
}
gameInput.scrolled(amount);
return false;
}
-}
\ No newline at end of file
+}