summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bea2a3c)
raw | patch | inline | side by side (parent: bea2a3c)
author | fred-boy <fred-boy@protonmail.com> | |
Sun, 30 Sep 2018 12:55:45 +0000 (19:55 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Sun, 30 Sep 2018 12:55:45 +0000 (19:55 +0700) |
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java
index 63cf93debf25046cb21e4345f1a75a532b43e325..7cac744d3b8d4403d0f29effeaea4fb268e21492 100644 (file)
if (gameProc.ctrlMode == 0 || !CaveGame.TOUCH) {
switch (keycode) {
case Input.Keys.A:
- gameProc.player.moveX.x = -GamePhysics.PL_SPEED;
+ gameProc.player.move.x = -GamePhysics.PL_SPEED;
gameProc.player.dir = 0;
if (CaveGame.TOUCH && checkSwim()) gameProc.swim = true;
break;
case Input.Keys.D:
- gameProc.player.moveX.x = GamePhysics.PL_SPEED;
+ gameProc.player.move.x = GamePhysics.PL_SPEED;
gameProc.player.dir = 1;
if (CaveGame.TOUCH && checkSwim()) gameProc.swim = true;
break;
if (checkSwim()) {
gameProc.swim = true;
} else if (gameProc.player.canJump) {
- gameProc.player.moveY.add(0, -7);
+ gameProc.player.move.add(0, -7);
} else if (!gameProc.player.flyMode) {
gameProc.player.flyMode = true;
- gameProc.player.moveY.setZero();
+ gameProc.player.move.y = 0;
} else {
- gameProc.player.moveY.y = -GamePhysics.PL_SPEED;
+ gameProc.player.move.y = -GamePhysics.PL_SPEED;
}
break;
case Input.Keys.CONTROL_LEFT:
- gameProc.player.moveY.y = GamePhysics.PL_SPEED;
+ gameProc.player.move.y = GamePhysics.PL_SPEED;
break;
case Input.Keys.E:
switch (keycode) {
case Input.Keys.A:
case Input.Keys.D:
- gameProc.player.moveX.x = 0;
+ gameProc.player.move.x = 0;
if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false;
break;
case Input.Keys.SPACE:
case Input.Keys.CONTROL_LEFT:
- if (gameProc.player.flyMode) gameProc.player.moveY.setZero();
+ if (gameProc.player.flyMode) gameProc.player.move.y = 0;
if (gameProc.swim) gameProc.swim = false;
break;
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index 66f4236924db1e93f5612c25190492e861d74e6a..142e959a1a3c97a17b2bd18c8f3864b416b14585 100644 (file)
}
private void playerPhy(Player pl) {
- pl.position.add(pl.moveY);
+ pl.position.y += pl.move.y;
if (checkColl(pl.getRect())) {
int d = -1;
- if (pl.moveY.y < 0) d = 1;
+ if (pl.move.y < 0) d = 1;
if (d == -1) {
pl.flyMode = false;
pl.canJump = true;
}
pl.position.y = MathUtils.round(pl.position.y);
while (checkColl(pl.getRect())) pl.position.y += d;
- pl.moveY.setZero();
+ pl.move.y = 0;
} else {
pl.canJump = false;
}
if (Items.isFluid(getBlock(pl.getRect()))) {
- if (CaveGame.TOUCH && pl.moveX.x != 0 && !gameProc.swim && !pl.flyMode) gameProc.swim = true;
+ if (CaveGame.TOUCH && pl.move.x != 0 && !gameProc.swim && !pl.flyMode) gameProc.swim = true;
if (!gameProc.swim) {
- if (!pl.flyMode && pl.moveY.y < 4.5f) pl.moveY.add(gravity.x / 4, gravity.y / 4);
- if (!pl.flyMode && pl.moveY.y > 4.5f) pl.moveY.add(0, -1f);
+ if (!pl.flyMode && pl.move.y < 4.5f) pl.move.add(gravity.x / 4, gravity.y / 4);
+ if (!pl.flyMode && pl.move.y > 4.5f) pl.move.add(0, -1f);
} else {
- pl.moveY.add(0, -.5f);
- if (pl.moveY.y < -3) pl.moveY.y = -3;
+ pl.move.add(0, -.5f);
+ if (pl.move.y < -3) pl.move.y = -3;
}
} else {
- if (!pl.flyMode && pl.moveY.y < 18) pl.moveY.add(gravity);
+ if (!pl.flyMode && pl.move.y < 18) pl.move.add(gravity);
}
- pl.position.add(pl.moveX);
+ pl.position.x += pl.move.x;
if (checkColl(pl.getRect())) {
if (pl.canJump && !pl.flyMode) pl.position.y -= 8;
if (checkColl(pl.getRect())) {
if (pl.canJump && !pl.flyMode) pl.position.y += 8;
int d = 0;
- if (pl.moveX.x < 0) d = 1;
- else if (pl.moveX.x > 0) d = -1;
+ if (pl.move.x < 0) d = 1;
+ else if (pl.move.x > 0) d = -1;
pl.position.x = MathUtils.round(pl.position.x);
while (checkColl(pl.getRect())) pl.position.x += d;
}
if (pl.position.y > gameProc.world.getHeight() * 16) {
pl.position = gameProc.world.getSpawnPoint().cpy();
}
- if (CaveGame.TOUCH && checkJump(pl.getRect(), pl.dir) && !pl.flyMode && pl.canJump && !pl.moveX.equals(Vector2.Zero)) {
- pl.moveY.add(0, -8);
+ if (CaveGame.TOUCH && checkJump(pl.getRect(), pl.dir) && !pl.flyMode && pl.canJump && pl.move.x != 0) {
+ pl.move.add(0, -8);
pl.canJump = false;
}
}
private void mobPhy(Mob mob) {
- mob.position.add(mob.moveY);
+ mob.position.y += mob.move.y;
if (checkColl(mob.getRect())) {
int d = -1;
- if (mob.moveY.y < 0) d = 1;
+ if (mob.move.y < 0) d = 1;
if (d == -1) mob.canJump = true;
mob.position.y = MathUtils.round(mob.position.y);
while (checkColl(mob.getRect())) mob.position.y += d;
- mob.moveY.setZero();
+ mob.move.y = 0;
if (mob.getType() > 0) {
gameProc.world.setForeMap((int) mob.position.x / 16, (int) mob.position.y / 16, mob.getType());
mob.position.y = -1;
}
if (mob.getType() == 0 && Items.isFluid(getBlock(mob.getRect()))) {
- if (mob.moveY.y > 9) mob.moveY.add(0, -.9f);
- mob.moveY.add(0, -.5f);
- if (mob.moveY.y < -3) mob.moveY.y = -3;
- } else if (mob.moveY.y < 18) mob.moveY.add(gravity);
+ if (mob.move.y > 9) mob.move.add(0, -.9f);
+ mob.move.add(0, -.5f);
+ if (mob.move.y < -3) mob.move.y = -3;
+ } else if (mob.move.y < 18) mob.move.add(gravity);
- mob.position.add(mob.moveX);
+ mob.position.x += mob.move.x;
if (checkColl(mob.getRect())) {
if (mob.canJump) {
mob.position.y -= 8;
if (checkColl(mob.getRect())) {
if (mob.canJump) mob.position.y += 8;
int d = 0;
- if (mob.moveX.x < 0) d = 1;
- else if (mob.moveX.x > 0) d = -1;
+ if (mob.move.x < 0) d = 1;
+ else if (mob.move.x > 0) d = -1;
mob.position.x = MathUtils.round(mob.position.x);
while (checkColl(mob.getRect())) mob.position.x += d;
if (mob.canJump) mob.changeDir();
if (mob.position.y > gameProc.world.getHeight() * 16) {
mob.position.y = 0;
}
- if (checkJump(mob.getRect(), mob.dir) && mob.canJump && !mob.moveX.equals(Vector2.Zero)) {
- mob.moveY.add(0, -8);
+ if (checkJump(mob.getRect(), mob.dir) && mob.canJump && mob.move.x != 0) {
+ mob.move.add(0, -8);
mob.canJump = false;
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index 5a8ab943a1b5c18691497a2f6523f1e9d47d45b7..8ed1ebd430ac64d6d20e18ca858da52223563b96 100644 (file)
}
private void drawPlayer(Player pl) {
- if (!pl.moveX.equals(Vector2.Zero) || Assets.playerSprite[0][2].getRotation() != 0) {
+ if (pl.move.x != 0 || Assets.playerSprite[0][2].getRotation() != 0) {
Assets.playerSprite[0][2].rotate(Player.ANIM_SPEED);
Assets.playerSprite[1][2].rotate(-Player.ANIM_SPEED);
Assets.playerSprite[0][3].rotate(-Player.ANIM_SPEED);
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java
index 11d02d2d72b29fa5f0b35f2134713959906c9872..441d75f0f3940afb3b510b9d9acf1d29355c0128 100644 (file)
public FallingGravel(int x, int y) {
dir = 0;
position = new Vector2(x, y);
- moveX = new Vector2(0, 0);
- moveY = new Vector2(0, 1);
+ move = new Vector2(0, 1);
width = 16;
height = 16;
canJump = false;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java
index 37f8a59c366527c6946f5d2c3e9a96e26a1be29c..a410eb3541a2cfc36d8108a3d6257d03865245c5 100644 (file)
public FallingSand(int x, int y) {
dir = 0;
position = new Vector2(x, y);
- moveX = new Vector2(0, 0);
- moveY = new Vector2(0, 1);
+ move = new Vector2(0, 1);
width = 16;
height = 16;
canJump = false;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java
index fbab3970d5c52f3adb3c39e35b0fe45f911a93be..137e7cad913516e1cced168e7a9328986b0065e9 100644 (file)
public int ANIM_SPEED = 6;
public Vector2 position;
- public Vector2 moveX, moveY;
+ public Vector2 move;
public int width, height, dir, animation;
public boolean canJump;
public boolean dead;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java
index 0fa08bd2a6c928ba3b049ea73e1e5bad73dd3f07..c615fcb0191c2828c58877b03454770d192e9dea 100644 (file)
public Pig(int x, int y) {
dir = MathUtils.random(1);
position = new Vector2(x, y);
- moveX = new Vector2(-1 + dir * 2, 0);
- moveY = new Vector2(0, 0);
+ move = new Vector2(-1 + dir * 2, 0);
width = 25;
height = 18;
canJump = false;
@Override
public void changeDir() {
dir = -dir + 1;
- moveX.set(-1 + 2 * dir, 0);
+ move.x = -1 + 2 * dir;
}
@Override
public void ai() {
if (MathUtils.randomBoolean(.0025f)) changeDir();
else if (MathUtils.randomBoolean(.0025f)) {
- if (moveX.x != 0f) moveX.setZero();
- else moveX.set(-1 + 2 * dir, 0);
+ if (move.x != 0f) move.x = 0;
+ else move.x = -1 + 2 * dir;
}
- if (moveX.x != 0f) animation += ANIM_SPEED;
+ if (move.x != 0f) animation += ANIM_SPEED;
else animation = 0;
if (animation >= 60 || animation <= -60) {
ANIM_SPEED = -ANIM_SPEED;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java
index 546fb6ef7aaa307b2a98b4ad686cfbcb894f1832..4a6c4d41682c36eca08ea7c288d3938df9f66acb 100644 (file)
public static int ANIM_SPEED = 6;
public Vector2 position;
- public Vector2 moveX, moveY;
+ public Vector2 move;
public int width, height, dir, texWidth;
public boolean canJump;
public int[] inventory;
public Player(Vector2 spawnPoint) {
position = spawnPoint.cpy();
- moveX = new Vector2(0, 0);
- moveY = new Vector2(0, 0);
+ move = new Vector2(0, 0);
width = 4;
height = 30;
texWidth = 8;