summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0e2f1d3)
raw | patch | inline | side by side (parent: 0e2f1d3)
author | fredboy <fredboy@protonmail.com> | |
Sun, 14 Apr 2024 17:55:02 +0000 (00:55 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Sun, 14 Apr 2024 19:53:40 +0000 (02:53 +0700) |
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java
index 594f8cc64d16df74b1c1dca1b7f032ad1a6b1be7..3f9b77322431e0275640edd3f12f6bf7d9b71626 100644 (file)
if (checkSwim()) {
mPlayer.swim = true;
} else if (mPlayer.canJump()) {
- mPlayer.getMove().add(0, -7);
+ mPlayer.getVelocity().add(0, -7);
} else if (!mPlayer.isFlyMode() && mPlayer.gameMode == 1) {
mPlayer.setFlyMode(true);
- mPlayer.getMove().y = 0;
+ mPlayer.getVelocity().y = 0;
} else if (mPlayer.isFlyMode()) {
- mPlayer.getMove().y = -GamePhysics.PL_SPEED;
+ mPlayer.getVelocity().y = -GamePhysics.PL_SPEED;
}
}
if (mControlMode == ControlMode.WALK || !mMainConfig.isTouch()) {
switch (keycode) {
case Input.Keys.A:
- mPlayer.getMove().x = -GamePhysics.PL_SPEED;
+ mPlayer.getVelocity().x = -GamePhysics.PL_SPEED;
mPlayer.setDir(Mob.Direction.LEFT);
if (mMainConfig.isTouch() && checkSwim()) {
mPlayer.swim = true;
}
break;
case Input.Keys.D:
- mPlayer.getMove().x = GamePhysics.PL_SPEED;
+ mPlayer.getVelocity().x = GamePhysics.PL_SPEED;
mPlayer.setDir(Mob.Direction.RIGHT);
if (mMainConfig.isTouch() && checkSwim()) {
mPlayer.swim = true;
break;
case Input.Keys.S:
case Input.Keys.CONTROL_LEFT:
- mPlayer.getMove().y = GamePhysics.PL_SPEED;
+ mPlayer.getVelocity().y = GamePhysics.PL_SPEED;
break;
}
} else {
switch (keycode) {
case Input.Keys.A:
case Input.Keys.D:
- mPlayer.getMove().x = 0;
+ mPlayer.getVelocity().x = 0;
if (mMainConfig.isTouch() && mPlayer.swim) {
mPlayer.swim = false;
}
case Input.Keys.SPACE:
case Input.Keys.CONTROL_LEFT:
if (mPlayer.isFlyMode()) {
- mPlayer.getMove().y = 0;
+ mPlayer.getVelocity().y = 0;
}
if (mPlayer.swim) {
mPlayer.swim = false;
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java
index d6b5a9aa5da8e907c07430e1670cce350a61a757..6572cf558a9551692f67155b419f5e6d9cbaab51 100644 (file)
if (dropToPlayer > 0) {
drop.moveToPlayer(mGameWorld, mMobsController.getPlayer(), dropToPlayer);
} else {
- if (drop.getMove().x >= .5f) {
- drop.getMove().x -= .5f;
- } else if (drop.getMove().x <= -.5f) {
- drop.getMove().x += .5f;
+ if (drop.getVelocity().x >= .5f) {
+ drop.getVelocity().x -= .5f;
+ } else if (drop.getVelocity().x <= -.5f) {
+ drop.getVelocity().x += .5f;
} else {
- drop.getMove().x = 0;
+ drop.getVelocity().x = 0;
}
- if (drop.getMove().y < 9) {
- drop.getMove().y += gravity.y / 4;
+ if (drop.getVelocity().y < 9) {
+ drop.getVelocity().y += gravity.y / 4;
}
}
drop.move();
if (checkColl(drop)) {
- drop.getMove().set(0, -1);
+ drop.getVelocity().set(0, -1);
do {
drop.move();
} while (checkColl(drop));
- drop.getMove().setZero();
+ drop.getVelocity().setZero();
}
}
int d = 0;
- if (mob.getMove().x < 0) {
+ if (mob.getVelocity().x < 0) {
d = 1;
- } else if (mob.getMove().x > 0) {
+ } else if (mob.getVelocity().x > 0) {
d = -1;
}
if (checkColl(mob)) {
int d = -1;
- if (mob.getMove().y < 0) {
+ if (mob.getVelocity().y < 0) {
d = 1;
}
mob.y += d;
}
- mob.getMove().y = 0;
+ mob.getVelocity().y = 0;
} else {
mob.setCanJump(false);
}
private void playerPhy(Player player) {
- player.y += player.getMove().y;
+ player.y += player.getVelocity().y;
mobYColl(player);
if (player.isDead()) {
}
if (GameItems.isFluid(getBlock(player))) {
- if (mMainConfig.isTouch() && player.getMove().x != 0 && !player.swim && !player.isFlyMode()) {
+ if (mMainConfig.isTouch() && player.getVelocity().x != 0 && !player.swim && !player.isFlyMode()) {
player.swim = true;
}
if (!player.swim) {
- if (!player.isFlyMode() && player.getMove().y < 4.5f) {
- player.getMove().add(gravity.x / 4, gravity.y / 4);
+ if (!player.isFlyMode() && player.getVelocity().y < 4.5f) {
+ player.getVelocity().add(gravity.x / 4, gravity.y / 4);
}
- if (!player.isFlyMode() && player.getMove().y > 4.5f) {
- player.getMove().add(0, -1f);
+ if (!player.isFlyMode() && player.getVelocity().y > 4.5f) {
+ player.getVelocity().add(0, -1f);
}
} else {
- player.getMove().add(0, -.5f);
- if (player.getMove().y < -3) {
- player.getMove().y = -3;
+ player.getVelocity().add(0, -.5f);
+ if (player.getVelocity().y < -3) {
+ player.getVelocity().y = -3;
}
}
} else {
- if (!player.isFlyMode() && player.getMove().y < 18) {
- player.getMove().add(gravity);
+ if (!player.isFlyMode() && player.getVelocity().y < 18) {
+ player.getVelocity().add(gravity);
}
}
- player.x += player.getMove().x * (player.isFlyMode() ? 1.5f : 1) *
+ player.x += player.getVelocity().x * (player.isFlyMode() ? 1.5f : 1) *
(GameItems.isFluid(getBlock(player)) && !player.isFlyMode() ? .8f : 1);
mobXColl(player);
- if (mMainConfig.isTouch() && !player.isFlyMode() && player.canJump() && player.getMove().x != 0 && checkJump(player)) {
- player.getMove().add(0, -8);
+ if (mMainConfig.isTouch() && !player.isFlyMode() && player.canJump() && player.getVelocity().x != 0 && checkJump(player)) {
+ player.getVelocity().add(0, -8);
player.setCanJump(false);
}
}
private void mobPhy(Mob mob) {
if (mob.getType() == Mob.Type.MOB && GameItems.isFluid(getBlock(mob))) {
- if (mob.getMove().y > 9) {
- mob.getMove().add(0, -.9f);
+ if (mob.getVelocity().y > 9) {
+ mob.getVelocity().add(0, -.9f);
}
- mob.getMove().add(0, -.5f);
+ mob.getVelocity().add(0, -.5f);
- if (mob.getMove().y < -3) {
- mob.getMove().y = -3;
+ if (mob.getVelocity().y < -3) {
+ mob.getVelocity().y = -3;
}
- } else if (!mob.isFlyMode() && mob.getMove().y < 18) {
- mob.getMove().add(gravity);
+ } else if (!mob.isFlyMode() && mob.getVelocity().y < 18) {
+ mob.getVelocity().add(gravity);
}
- mob.y += mob.getMove().y;
+ mob.y += mob.getVelocity().y;
mobYColl(mob);
if (mob.isDead()) {
return;
}
- mob.x += mob.getMove().x;
+ mob.x += mob.getVelocity().x;
mobXColl(mob);
- if (mob.canJump() && mob.getMove().x != 0 && checkJump(mob)) {
- mob.getMove().add(0, -8);
+ if (mob.canJump() && mob.getVelocity().x != 0 && checkJump(mob)) {
+ mob.getVelocity().add(0, -8);
mob.setCanJump(false);
}
}
- void update() {
+ void update(float delta) {
Player player = mMobsController.getPlayer();
for (Iterator<Drop> it = mDropController.getIterator(); it.hasNext(); ) {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java
index 44a46878cff367a12cc83ed0b8b8619be6b16c54..d8925f9dfc81f861e5b6a975c006d52e0b12e01d 100644 (file)
}
public void update(float delta) {
- mGamePhysics.update();
+ mGamePhysics.update(delta);
mGameInput.update();
mGameWorld.update();
mGameRenderer.render(delta);
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java
index 23cf1dcc836de3b434aa7e9deea52ca53b691568..359a74b59bd2e4beceeaa99d43ccede790574243 100644 (file)
*/
public FallingGravel(float x, float y) {
super(x, y, 16, 16, Direction.LEFT, Type.GRAVEL);
- mMove = new Vector2(0, 1);
+ mVelocity = new Vector2(0, 1);
}
@Override
public void ai(GameWorld gameWorld) {
- if (mMove.isZero()) {
+ if (mVelocity.isZero()) {
gameWorld.setForeMap(getMapX(), getMiddleMapY(), 11);
kill();
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java
index 9a383a21315cce839145870231c0e6f9bbb8cb35..a8d9ce27b0ccac5bdd6bf437582f5c1b5e6e29ca 100644 (file)
*/
public FallingSand(float x, float y) {
super(x, y, 16, 16, Direction.LEFT, Type.SAND);
- mMove = new Vector2(0, 1);
+ mVelocity = new Vector2(0, 1);
}
@Override
public void ai(GameWorld gameWorld) {
- if (mMove.isZero()) {
+ if (mVelocity.isZero()) {
gameWorld.setForeMap(getMapX(), getMiddleMapY(), 10);
kill();
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java
index 0f765925bc1679bed83830f29011a5f0bd88def8..3bc3b5b413dc620cb353ff7c351c7ea0a010d270 100644 (file)
RIGHT
}
- protected Vector2 mMove;
+ protected Vector2 mVelocity;
protected Type mType;
protected int mAnimDelta = 6;
protected int mAnim;
*/
protected Mob(float x, float y, float width, float height, Direction mDirection, Type type) {
super(x, y, width, height);
- mMove = new Vector2(0, 0);
+ mVelocity = new Vector2(0, 0);
mCanJump = false;
mDead = false;
this.mDirection = mDirection;
mDead = true;
}
- public final void move() {
- x += mMove.x;
- y += mMove.y;
+ public final void move(float delta) {
+ x += mVelocity.x * delta;
+ y += mVelocity.y * delta;
}
- public final Vector2 getMove() {
- return mMove;
+ public final Vector2 getVelocity() {
+ return mVelocity;
}
public final boolean canJump() {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java
index b362da73a38f6d831aa1fa54b9f2a2e6a9679a58..b2760c24624a7d0c402f4727f6101fd4bf23f561 100644 (file)
public Pig(float x, float y) {
super(x, y, 25, 18, randomDir(), Type.MOB);
- mMove = new Vector2(looksLeft() ? -1 : 1, 0);
+ mVelocity = new Vector2(looksLeft() ? -1 : 1, 0);
}
@Override
public void changeDir() {
switchDir();
- mMove.x = -1 + 2 * dirMultiplier();
+ mVelocity.x = -1 + 2 * dirMultiplier();
}
@Override
public void ai(GameWorld gameWorld) {
if (MathUtils.randomBoolean(.0025f)) {
- if (mMove.x != 0f) {
- mMove.x = 0;
+ if (mVelocity.x != 0f) {
+ mVelocity.x = 0;
} else {
changeDir();
}
}
- if (mMove.x != 0f) {
+ if (mVelocity.x != 0f) {
mAnim += mAnimDelta;
} else {
mAnim = 0;
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java
index 0b7ab8bc8148c48a24b02a3d7d266ec43e7cd3de..f373dc3ad598785e1d8430229c10a87f3f2c24d9 100644 (file)
Vector2 pos = getSpawnPoint(gameWorld);
this.x = pos.x;
this.y = pos.y;
- mMove.setZero();
+ mVelocity.setZero();
}
private Vector2 getSpawnPoint(GameWorld gameWorld) {
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
- if (mMove.x != 0 || Assets.playerSprite[0][2].getRotation() != 0) {
+ if (mVelocity.x != 0 || Assets.playerSprite[0][2].getRotation() != 0) {
Assets.playerSprite[0][2].rotate(mAnimDelta);
Assets.playerSprite[1][2].rotate(-mAnimDelta);
Assets.playerSprite[0][3].rotate(-mAnimDelta);
diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Drop.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Drop.java
index 3b5c76031d5a41b8a78861f48b2648441431cbcb..07a2f6cf68b9ea8f6ecaeefbfbd0b604a4b48df3 100644 (file)
public class Drop extends Rectangle implements Serializable {
private final int id;
- private final Vector2 move;
+ private final Vector2 velocity;
private boolean pickedUp = false;
Drop(float x, float y, int id) {
super(x, y, 8, 8);
this.id = id;
- this.move = new Vector2(0, -1);
+ this.velocity = new Vector2(0, -1);
}
- public Vector2 getMove() {
- return move;
+ public Vector2 getVelocity() {
+ return velocity;
}
public int closeToPlayer(GameWorld gameWorld, Player player) {
dy = .5f;
}
- move.add(dx, dy);
+ velocity.add(dx, dy);
- if (move.x > 2) {
- move.x = 1;
- } else if (move.x < -2) {
- move.x = -1;
+ if (velocity.x > 2) {
+ velocity.x = 1;
+ } else if (velocity.x < -2) {
+ velocity.x = -1;
}
- if (move.y > 2) {
- move.y = 1;
- } else if (move.y < -2) {
- move.y = -1;
+ if (velocity.y > 2) {
+ velocity.y = 1;
+ } else if (velocity.y < -2) {
+ velocity.y = -1;
}
}
}
}
public void move() {
- x += move.x;
- y += move.y;
+ x += velocity.x;
+ y += velocity.y;
checkWorldBounds();
y = MathUtils.round(y);
}