From d5e611f9fb8deb93a9403b41f17dc000b9fa63ce Mon Sep 17 00:00:00 2001 From: fred-boy Date: Sun, 9 Sep 2018 18:10:31 +0700 Subject: [PATCH 01/16] Improve autojump and AI --- .../ru/deadsoftware/cavecraft/GameScreen.java | 1 + .../cavecraft/game/GameInput.java | 5 +++++ .../cavecraft/game/GamePhysics.java | 3 +++ .../cavecraft/game/GameRenderer.java | 10 ++++++++- .../deadsoftware/cavecraft/game/mobs/Mob.java | 15 +++---------- .../deadsoftware/cavecraft/game/mobs/Pig.java | 22 +++++++++++++++---- 6 files changed, 39 insertions(+), 17 deletions(-) diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java index d359fe9..dc7bb60 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameScreen.java +++ b/core/src/ru/deadsoftware/cavecraft/GameScreen.java @@ -11,6 +11,7 @@ import ru.deadsoftware.cavecraft.misc.*; public class GameScreen implements Screen { public static int FPS; + public static boolean SHOW_DEBUG = false; private GameProc gameProc; private Renderer renderer; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index 9aa90f2..e44e005 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -3,6 +3,7 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Input; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavecraft.CaveGame; +import ru.deadsoftware.cavecraft.GameScreen; import ru.deadsoftware.cavecraft.game.mobs.Pig; import ru.deadsoftware.cavecraft.misc.AppState; import ru.deadsoftware.cavecraft.misc.Assets; @@ -86,6 +87,10 @@ public class GameInput { case Input.Keys.ESCAPE: case Input.Keys.BACK: CaveGame.STATE = AppState.GOTO_MENU; break; + + case Input.Keys.F1: + GameScreen.SHOW_DEBUG = !GameScreen.SHOW_DEBUG; + break; } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index 34c4df1..c335908 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -26,9 +26,11 @@ public class GamePhysics { switch (dir) { case 0: bl = gameProc.world.getForeMap((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16)); + if (checkColl(new Rectangle(rect.x-16, rect.y-18, rect.width, rect.height))) bl=0; break; case 1: bl = gameProc.world.getForeMap((int)((rect.x+rect.width+8)/16),(int)((rect.y+rect.height-8)/16)); + if (checkColl(new Rectangle(rect.x+16, rect.y-18, rect.width, rect.height))) bl=0; break; default: bl=0; @@ -121,6 +123,7 @@ public class GamePhysics { else if (mob.moveX.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.x+mob.width/2<0) mob.position.x+=gameProc.world.getWidth()*16; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 38680f9..b528972 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.math.Vector2; import ru.deadsoftware.cavecraft.CaveGame; +import ru.deadsoftware.cavecraft.GameScreen; import ru.deadsoftware.cavecraft.game.mobs.Mob; import ru.deadsoftware.cavecraft.game.objects.Player; import ru.deadsoftware.cavecraft.misc.Assets; @@ -171,7 +172,7 @@ public class GameRenderer extends Renderer { private void drawGamePlay() { drawWorldBackground(); - Mob.animateMobs(); + //Mob.animateMobs(); for (Mob mob : gameProc.mobs) drawMob(mob); drawPlayer(gameProc.player); drawWorldForeground(); @@ -195,6 +196,13 @@ public class GameRenderer extends Renderer { if (CaveGame.TOUCH) drawTouchGui(); + if (GameScreen.SHOW_DEBUG) { + drawString("FPS: "+GameScreen.FPS,0, 0); + drawString("X: "+(int)(gameProc.player.position.x/16),0, 10); + drawString("Y: "+(int)(gameProc.player.position.y/16),0, 20); + drawString("Mobs: "+gameProc.mobs.size(), 0, 30); + } + spriteBatch.end(); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java index 7b773d0..0b0f9b3 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java @@ -9,24 +9,15 @@ import java.io.Serializable; public abstract class Mob implements Serializable{ - public static int ANIM_SPEED = 6; - public static int ANIMATION = 0; + public int ANIM_SPEED = 6; public Vector2 position; public Vector2 moveX, moveY; - public int width, height, dir; + public int width, height, dir, animation; public boolean canJump; public boolean agressive; - public static void animateMobs() { - Assets.pigSprite[0][1].setRotation(ANIMATION); - Assets.pigSprite[1][1].setRotation(-ANIMATION); - ANIMATION+=ANIM_SPEED; - if (ANIMATION>=60 || ANIMATION<=-60) { - ANIM_SPEED = -ANIM_SPEED; - } - } - public abstract void ai(); + public abstract void changeDir(); public abstract void draw(SpriteBatch spriteBatch, float x, float y); public abstract Rectangle getRect(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java index aaa3019..10c4242 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java @@ -11,24 +11,38 @@ import ru.deadsoftware.cavecraft.game.GameProc; public class Pig extends Mob{ public Pig(int x, int y) { + dir = MathUtils.random(1); position = new Vector2(x, y); - moveX = new Vector2(0, 0); + moveX = new Vector2(-1+dir*2, 0); moveY = new Vector2(0, 0); width = 25; height = 18; - dir = 0; canJump = false; agressive = false; } @Override - public void ai() { - if (MathUtils.randomBoolean(.0025f)) dir=-dir+1; + public void changeDir() { + dir=-dir+1; moveX.set(-1+2*dir,0); + if (MathUtils.randomBoolean(.0025f)) { + moveX.set(0, 0); + } + } + + @Override + public void ai() { + if (MathUtils.randomBoolean(.0025f)) changeDir(); + if (moveX.x != 0f) animation+=ANIM_SPEED; else animation=0; + if (animation>=60 || animation<=-60) { + ANIM_SPEED = -ANIM_SPEED; + } } @Override public void draw(SpriteBatch spriteBatch, float x, float y) { + Assets.pigSprite[0][1].setRotation(animation); + Assets.pigSprite[1][1].setRotation(-animation); //back legs Assets.pigSprite[1][1].setPosition(x-4+(9-dir*9),y+6); Assets.pigSprite[1][1].draw(spriteBatch); -- 2.29.2 From a2d04a40dddc471fef220ef38b2f5e2229b9d250 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Sun, 9 Sep 2018 19:33:31 +0700 Subject: [PATCH 02/16] Add more blocks --- android/assets/terrain.png | Bin 24015 -> 33441 bytes .../ru/deadsoftware/cavecraft/game/Items.java | 11 +++++++++++ .../deadsoftware/cavecraft/misc/Assets.java | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/android/assets/terrain.png b/android/assets/terrain.png index 28bfb43f168fd1dd8a6593b75a2ec532f4615db1..73cb45ab0f7f2f5a215e3f8d071e3a409e8ceef0 100644 GIT binary patch delta 17506 zcmV*EKx@Cxy8)qv0+1tr7T*4)xH{S1?`G@7a|4;21;`8P|{yR5JQ_Rs~<9CcZrsrBuEsnUKq-1@E8ym?u zj$FjF$y(xa{G3a8o;#lB?a+Dh3EUY2g9YC4r*HSGi~r4k_vb+Os&qr}{WDg~E2;pQ zhBBw0+(kmdeaEys@qNDC4|U^zNNgg5!GE$%I4(e5IH}4Zg+LLLiQv{7hyZQ;v%agi_)O?vk67D#__l&*nWXJom;DUzdRv z5>Zl3jnvS8E+i}GLjAPdsi9d?$*z=AODnyMGHa^2mRf78!l>C&%dNE9TI+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jjN*^ahg{Iu85q9%VF>CE&P1tI+ zP)hOa#S7v%W@mew$z;Ob!2xj`v$3{DUCItYnY zw{Yo{{Nl*>{`XfcmDw$nq0G5N)jUka{l`W(cc`Z3?NIT}0m&2t3Jd|$-7&% Date: Sun, 9 Sep 2018 19:38:27 +0700 Subject: [PATCH 03/16] Add desert --- .../cavecraft/game/GameRenderer.java | 2 +- .../cavecraft/game/GameWorld.java | 3 +- .../deadsoftware/cavecraft/game/WorldGen.java | 52 +++++++++++++++---- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index b528972..58564bf 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -123,7 +123,7 @@ public class GameRenderer extends Renderer { spriteBatch.draw(Assets.creativeInv, x, y); spriteBatch.draw(Assets.creativeScroll, x+156, y+18+(gameProc.creativeScroll*(72/gameProc.maxCreativeScroll))); - for (int i=gameProc.creativeScroll*8; i<(gameProc.creativeScroll+1)*40; i++) { + for (int i=gameProc.creativeScroll*8; i0 && i-3 && t<3) t=0; else t/=Math.abs(t); if (i>width-(max-min)) { @@ -33,6 +37,12 @@ public class WorldGen { return res; } + private static void genCactus(int x, int y) { + foreMap[x][y] = 59; + foreMap[x][y-1] = 59; + foreMap[x][y-2] = 59; + } + private static void genOak(int x, int y) { backMap[x][y] = 15; backMap[x][y-1] = 15; @@ -68,21 +78,42 @@ public class WorldGen { dirtH = 4+rand.nextInt(2); for (int y = height- hMap[x]; y2 && x Date: Mon, 10 Sep 2018 17:58:28 +0700 Subject: [PATCH 04/16] Add logic to some blocks and fluids --- android/assets/terrain.png | Bin 33441 -> 35686 bytes .../cavecraft/game/GameInput.java | 9 +- .../cavecraft/game/GamePhysics.java | 44 ++- .../deadsoftware/cavecraft/game/GameProc.java | 282 +++++++++++++++++- .../cavecraft/game/GameRenderer.java | 2 + .../cavecraft/game/GameWorld.java | 13 +- .../ru/deadsoftware/cavecraft/game/Items.java | 92 +++++- .../deadsoftware/cavecraft/game/WorldGen.java | 26 +- .../cavecraft/game/mobs/FallingGravel.java | 45 +++ .../cavecraft/game/mobs/FallingSand.java | 46 +++ .../deadsoftware/cavecraft/game/mobs/Mob.java | 5 +- .../deadsoftware/cavecraft/game/mobs/Pig.java | 8 +- .../cavecraft/game/objects/Block.java | 4 + .../deadsoftware/cavecraft/misc/Assets.java | 2 +- 14 files changed, 551 insertions(+), 27 deletions(-) create mode 100644 core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java create mode 100644 core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java diff --git a/android/assets/terrain.png b/android/assets/terrain.png index 73cb45ab0f7f2f5a215e3f8d071e3a409e8ceef0..f17c02ae889fdef80eb081494919962b0f28b360 100644 GIT binary patch delta 20158 zcmV)(K#RYjg#zZ50+1sD8C#JhAAeVpWI1w0|FH@#0a`2v4q-Ms;PQDcB1`pjji3$9 z_|cW!Sy_=0?*T5Za6EVZ`)}9%7k_H6(dE*59kqJ?iPQAwz{tL~CmLF#Gp_u#vJqgNU~ zN50-Ge;zycyWssUc7A@no_-C5^Y!Zu^$#)ndOegskKK#V&npT)?)=LytcBr!{_|7p z?%n;~^V!|Zl}J_hwW)7gd4E6gMkAEzeXR1;_`mRTdtZaE&K4Iz-(=JHS}u$biQo-6 z>@dR(=l#9HVu?AP*!Vlf71MjIrxr(CFDY4H;l@T{wj)O|EwYw)IeuSDc=sLeek*kD zyaVryfs2Kg!9RStKYQ_i^Y#5g_o{S5@cnzNSXWd5vJ7QT-+31a3265#rsc)=eYv0N z#{ZPqLjH#`dlwcH5*hF{q!McIEyflC zaqQ%0vhtX6G%^rMi95JUZc?fwr$^nJ&$RH~8%zAW478Alk}9pz)jE?P0zQ9kI=S@Z z)0211Y0;8pD^{&pw_$TpJ}a-X>T0X6vF46DZQ6g=-Q4bb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Zyw35B(6I``qX1MCKDuJi+PdDPR2J z7rAof3P1kiKTe+eip$^s{om(X-})9Wzx*;vDR#g3yDT>Szj1H&bLTmMfZfw%?JoYyI%wA#rv#CN=`s^?lmC|M%`KQMz>>lA3!TEBb%AeaBw1(8Mz`M=j*A=IH}VG;UhR zU7LF-b5{Mu*}1xVrDpxw_oVWlhlKt4=N8Z9DmR_?Zmr&XZ}&CM8td!Et65aaUWBon z`Zejk2lF*`#^1BD46F;6OE0Kydy~*&^6z^p$ApD%7~X2xe+}0P;93*Uy%Y=t%yk5~I^!!dTFXOqk_lF;DSof$pU8T@$%KY%3XY14D<(^k9o-XNIvslLW zPkYY)2WF?efG*H-^&LN5YA0J;j#nrxf<98eR zf@?r#{Ey4}`(NKX+n$;JJ{UMEJf-~G*2*K_-^TsV-v2Fo)yI|lyz3V9cO8@qU9s(u zT;!(peF62n9{;k$=N#knD)E23X7MeZ6x{{^Cl19HIuZ4BvkALJ^>p$lcH0G<>ggBM gFef|`{IB1*%wox+?CEg~+zbp1p00i_>zopr07qQS0RR91 diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index e44e005..d151ec6 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.GameScreen; +import ru.deadsoftware.cavecraft.game.mobs.FallingSand; import ru.deadsoftware.cavecraft.game.mobs.Pig; import ru.deadsoftware.cavecraft.misc.AppState; import ru.deadsoftware.cavecraft.misc.Assets; @@ -61,7 +62,10 @@ public class GameInput { break; case Input.Keys.SPACE: - if (gameProc.player.canJump) { + if (Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16, + (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16))) { + gameProc.swim = true; + } else if (gameProc.player.canJump) { gameProc.player.moveY.add(0, -7); } else if (!gameProc.player.flyMode) { gameProc.player.flyMode = true; @@ -102,6 +106,7 @@ public class GameInput { case Input.Keys.SPACE: case Input.Keys.CONTROL_LEFT: if (gameProc.player.flyMode) gameProc.player.moveY.setZero(); + gameProc.swim = false; break; } } @@ -118,7 +123,7 @@ public class GameInput { } public void touchUp(int screenX, int screenY, int button) { - if (gameProc.isKeyDown) { + if (CaveGame.TOUCH && gameProc.isKeyDown) { keyUp(gameProc.keyDownCode); gameProc.isKeyDown = false; } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index c335908..244875d 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -1,5 +1,6 @@ package ru.deadsoftware.cavecraft.game; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Intersector; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Rectangle; @@ -8,6 +9,8 @@ import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.game.mobs.Mob; import ru.deadsoftware.cavecraft.game.objects.Player; +import java.util.Iterator; + public class GamePhysics { public static final int PL_SPEED = 2; @@ -26,16 +29,17 @@ public class GamePhysics { switch (dir) { case 0: bl = gameProc.world.getForeMap((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16)); - if (checkColl(new Rectangle(rect.x-16, rect.y-18, rect.width, rect.height))) bl=0; + if (checkColl(new Rectangle(rect.x+rect.width/2, rect.y-18, rect.width, rect.height))) bl=0; break; case 1: bl = gameProc.world.getForeMap((int)((rect.x+rect.width+8)/16),(int)((rect.y+rect.height-8)/16)); - if (checkColl(new Rectangle(rect.x+16, rect.y-18, rect.width, rect.height))) bl=0; + if (checkColl(new Rectangle(rect.x+rect.width/2, rect.y-18, rect.width, rect.height))) bl=0; break; default: bl=0; } - return (bl>0 && Items.BLOCKS.getValueAt(bl).collision); + return (bl>0 && Items.BLOCKS.getValueAt(bl).toJump() && + (rect.y+rect.height)-Items.BLOCKS.getValueAt(bl).getRect((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16)).y>8); } private boolean checkColl(Rectangle rect) { @@ -59,6 +63,10 @@ public class GamePhysics { return false; } + private int getBlock(Rectangle rect) { + return gameProc.world.getForeMap((int)(rect.x+rect.width/2)/16, (int)(rect.y+rect.height/8*7)/16); + } + private void playerPhy(Player pl) { pl.position.add(pl.moveY); if (checkColl(pl.getRect())) { @@ -74,7 +82,17 @@ public class GamePhysics { } else { pl.canJump = false; } - if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity); + + if (Items.isFluid(getBlock(pl.getRect()))) { + if (!gameProc.swim) { + if (!pl.flyMode && pl.moveY.y < 9) pl.moveY.add(gravity.x / 2, gravity.y / 2); + if (!pl.flyMode && pl.moveY.y > 9) pl.moveY.add(0, -.9f); + } else { + pl.moveY.add(0, -.5f); + if (pl.moveY.y<-3) pl.moveY.y = -3; + } + } else if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity); + pl.position.add(pl.moveX); if (checkColl(pl.getRect())) { if (pl.canJump && !pl.flyMode) pl.position.y-=8; @@ -107,10 +125,21 @@ public class GamePhysics { mob.position.y = MathUtils.round(mob.position.y); while (checkColl(mob.getRect())) mob.position.y+=d; mob.moveY.setZero(); + if (mob.getType() > 0) { + gameProc.world.setForeMap((int)mob.position.x/16, (int)mob.position.y/16, mob.getType()); + mob.position.y = -1; + mob.dead = true; + } } else { mob.canJump = false; } - if (mob.moveY.y<18) mob.moveY.add(gravity); + + 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); + mob.position.add(mob.moveX); if (checkColl(mob.getRect())) { if (mob.canJump) { @@ -142,6 +171,11 @@ public class GamePhysics { mob.ai(); mobPhy(mob); } + for (Iterator it = gameProc.mobs.iterator(); it.hasNext();) { + Mob m = it.next(); + if (m.dead) + it.remove(); + } playerPhy(gameProc.player); gameProc.renderer.camera.position.set( diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index 4b841bd..5d20e62 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -5,6 +5,8 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.GameScreen; +import ru.deadsoftware.cavecraft.game.mobs.FallingGravel; +import ru.deadsoftware.cavecraft.game.mobs.FallingSand; import ru.deadsoftware.cavecraft.game.mobs.Mob; import ru.deadsoftware.cavecraft.game.mobs.Pig; import ru.deadsoftware.cavecraft.game.objects.Player; @@ -18,6 +20,10 @@ public class GameProc implements Serializable{ public static double RUN_TIME = 0; + public static boolean DO_UPD = false; + public static int UPD_X = -1, UPD_Y = -1; + public static int FUPD_X, FUPD_Y; + public Player player; public ArrayList mobs; @@ -31,7 +37,7 @@ public class GameProc implements Serializable{ public int ctrlMode; public int creativeScroll, maxCreativeScroll; - public boolean isTouchDown, isKeyDown; + public boolean isTouchDown, isKeyDown, swim; public int touchDownX, touchDownY, keyDownCode; public int touchDownButton; public long touchDownTime; @@ -110,9 +116,283 @@ public class GameProc implements Serializable{ } } + private void updateFluids(int x, int y) { + if (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y)!=8) { + if ((!Items.isWater(world.getForeMap(x-1,y)) || + (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) && + (!Items.isWater(world.getForeMap(x+1,y)) || + (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){ + world.setForeMap(x, y, world.getForeMap(x, y)+1); + if (world.getForeMap(x, y)>62) world.setForeMap(x, y, 0); + } + } + + if (world.getForeMap(x, y) == 8) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,8); + updateBlock(x, y+2); + } else if (Items.isLava(world.getForeMap(x, y+1))) { + if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); + else world.setForeMap(x, y+1, 66); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { + if (world.getForeMap(x+1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || + (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>60)) { + world.setForeMap(x+1,y,60); + updateBlock(x+1, y+1); + } else if (Items.isLava(world.getForeMap(x+1, y))) { + if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); + else world.setForeMap(x+1, y, 66); + } else if (world.getForeMap(x+1, y)==60 && world.getForeMap(x+2, y)==8) world.setForeMap(x+1, y, 8); + + if (world.getForeMap(x-1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || + (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>60)) { + world.setForeMap(x-1,y,60); + updateBlock(x-1, y+1); + } else if (Items.isLava(world.getForeMap(x-1, y))) { + if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); + else world.setForeMap(x-1, y, 66); + } else if (world.getForeMap(x-1, y)==60 && world.getForeMap(x-2, y)==8) world.setForeMap(x-1, y, 8); + } + return; + } + if (world.getForeMap(x, y) == 60) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,8); + updateBlock(x, y+2); + } else if (Items.isLava(world.getForeMap(x, y+1))) { + if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); + else world.setForeMap(x, y+1, 66); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { + if (world.getForeMap(x+1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || + (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>61)){ + world.setForeMap(x+1,y,61); + updateBlock(x+1, y+1); + } else if (Items.isLava(world.getForeMap(x+1, y))) { + if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); + else world.setForeMap(x+1, y, 66); + } + + if (world.getForeMap(x-1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || + (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>61)){ + world.setForeMap(x-1,y,61); + updateBlock(x-1, y+1); + } else if (Items.isLava(world.getForeMap(x-1, y))) { + if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); + else world.setForeMap(x-1, y, 66); + } + } + return; + } + if (world.getForeMap(x, y) == 61) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,8); + updateBlock(x, y+2); + } else if (Items.isLava(world.getForeMap(x, y+1))) { + if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); + else world.setForeMap(x, y+1, 66); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { + if (world.getForeMap(x+1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){ + world.setForeMap(x+1,y,62); + updateBlock(x+1, y+1); + } else if (Items.isLava(world.getForeMap(x+1, y))) { + if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); + else world.setForeMap(x+1, y, 66); + } + + if (world.getForeMap(x-1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){ + world.setForeMap(x-1,y,62); + updateBlock(x-1, y+1); + } else if (Items.isLava(world.getForeMap(x-1, y))) { + if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); + else world.setForeMap(x-1, y, 66); + } + } + return; + } + if (world.getForeMap(x, y) == 62) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,8); + updateBlock(x, y+2); + } else if (Items.isLava(world.getForeMap(x, y+1))) { + if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); + else world.setForeMap(x, y+1, 66); + } + return; + } + + if (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x, y)!=9) { + if ((!Items.isLava(world.getForeMap(x-1,y)) || + (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) && + (!Items.isLava(world.getForeMap(x+1,y)) || + (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){ + world.setForeMap(x, y, world.getForeMap(x, y)+1); + if (world.getForeMap(x, y)>65) world.setForeMap(x, y, 0); + } + } + + if (world.getForeMap(x, y) == 9) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,9); + updateBlock(x, y+2); + } else if (Items.isWater(world.getForeMap(x, y+1))) { + world.setForeMap(x, y+1, 1); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { + if (world.getForeMap(x+1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || + (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>63)) { + world.setForeMap(x+1,y,63); + updateBlock(x+1, y+1); + } else if (Items.isWater(world.getForeMap(x+1, y))) { + world.setForeMap(x+1, y, 1); + } + + if (world.getForeMap(x-1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || + (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>63)) { + world.setForeMap(x-1,y,63); + updateBlock(x-1, y+1); + } else if (Items.isWater(world.getForeMap(x-1, y))) { + world.setForeMap(x-1, y, 1); + } + } + return; + } + if (world.getForeMap(x, y) == 63) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,9); + updateBlock(x, y+2); + } else if (Items.isWater(world.getForeMap(x, y+1))) { + world.setForeMap(x, y+1, 1); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { + if (world.getForeMap(x+1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || + (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>64)){ + world.setForeMap(x+1,y,64); + updateBlock(x+1, y+1); + } else if (Items.isWater(world.getForeMap(x+1, y))) { + world.setForeMap(x+1, y, 1); + } + + if (world.getForeMap(x-1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || + (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>64)){ + world.setForeMap(x-1,y,64); + updateBlock(x-1, y+1); + } else if (Items.isWater(world.getForeMap(x-1, y))) { + world.setForeMap(x-1, y, 1); + } + } + return; + } + if (world.getForeMap(x, y) == 64) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,9); + updateBlock(x, y+2); + } else if (Items.isWater(world.getForeMap(x, y+1))) { + world.setForeMap(x, y+1, 1); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { + if (world.getForeMap(x+1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){ + world.setForeMap(x+1,y,65); + updateBlock(x+1, y+1); + } else if (Items.isWater(world.getForeMap(x+1, y))) { + world.setForeMap(x+1, y, 1); + } + + if (world.getForeMap(x-1, y)==0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){ + world.setForeMap(x-1,y,65); + updateBlock(x-1, y+1); + } else if (Items.isWater(world.getForeMap(x-1, y))) { + world.setForeMap(x-1, y, 1); + } + } + return; + } + if (world.getForeMap(x, y) == 65) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { + world.setForeMap(x,y+1,9); + updateBlock(x, y+2); + } else if (Items.isWater(world.getForeMap(x, y+1))) { + world.setForeMap(x, y+1, 1); + } + return; + } + } + + private void updateBlock(int x, int y) { + if (world.getForeMap(x, y) == 10) { + if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x,y+1)).collision) { + world.setForeMap(x, y, 0); + mobs.add(new FallingSand(x*16, y*16)); + updateBlock(x, y-1); + } + } + + if (world.getForeMap(x, y) == 11) { + if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x,y+1)).collision) { + world.setForeMap(x, y, 0); + mobs.add(new FallingGravel(x*16, y*16)); + updateBlock(x, y-1); + } + } + + if (world.getForeMap(x, y) == 59) { + if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { + world.setForeMap(x,y,0); + updateBlock(x, y-1); + } + } + + if (world.getForeMap(x, y) == 2) { + if (world.getForeMap(x, y-1)>0 && (Items.BLOCKS.getValueAt(world.getForeMap(x, y-1)).collision || + Items.isFluid(world.getForeMap(x, y-1)))) { + world.setForeMap(x, y, 3); + } + } + } + public void update(float delta) { RUN_TIME += delta; + if (DO_UPD) { + for (int y=UPD_Y; y=(int)(renderer.camera.position.x+renderer.camera.viewportWidth)/16+1) { + FUPD_X = (int) renderer.camera.position.x / 16 - 1; + FUPD_Y++; + if (FUPD_Y>=(int)(renderer.camera.position.y+renderer.camera.viewportHeight)/16+1) { + FUPD_Y = (int) renderer.camera.position.y / 16 - 1; + } + } + physics.update(delta); moveCursor(); checkCursorBounds(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 58564bf..fac4ba2 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -1,7 +1,9 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector2; import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.GameScreen; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java index 65c9d03..42050e2 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -37,7 +37,7 @@ public class GameWorld { x = transformX(x); map = foreMap[x][y]; } catch (ArrayIndexOutOfBoundsException e) { - Gdx.app.error("GameWorld",e.toString()); + //Gdx.app.error("GameWorld",e.toString()); } return map; } @@ -47,7 +47,7 @@ public class GameWorld { x = transformX(x); foreMap[x][y] = value; } catch (ArrayIndexOutOfBoundsException e) { - Gdx.app.error("GameWorld", e.toString()); + //Gdx.app.error("GameWorld", e.toString()); } } @@ -57,7 +57,7 @@ public class GameWorld { x = transformX(x); map = backMap[x][y]; } catch (ArrayIndexOutOfBoundsException e) { - Gdx.app.error("GameWorld",e.toString()); + //Gdx.app.error("GameWorld",e.toString()); } return map; } @@ -67,13 +67,16 @@ public class GameWorld { x = transformX(x); backMap[x][y] = value; } catch (ArrayIndexOutOfBoundsException e) { - Gdx.app.error("GameWorld", e.toString()); + //Gdx.app.error("GameWorld", e.toString()); } } public void placeToForeground(int x, int y, int value) { - if (getForeMap(x,y) == 0 || value == 0) { + if (getForeMap(x,y) == 0 || value == 0 || !Items.BLOCKS.getValueAt(getForeMap(x, y)).collision) { setForeMap(x, y, value); + GameProc.UPD_X = x-8; + GameProc.UPD_Y = y-8; + GameProc.DO_UPD = true; } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index ca0c949..9987cbe 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -7,67 +7,153 @@ public class Items { public static ArrayMap BLOCKS = new ArrayMap(); + public static boolean isFluid(int bl) { + return (bl == 8 || bl == 9 || bl == 60 || bl == 61 || bl == 62 || bl == 63 || bl == 64 || bl == 65); + } + + public static boolean isWater(int bl) { + return (bl == 8 || bl == 60 || bl == 61 || bl == 62); + } + + public static boolean isLava(int bl) { + return (bl == 9 || bl == 63 || bl == 64 || bl == 65); + } + public static void loadBlocks() { + //0 BLOCKS.put("none", null); + //1 BLOCKS.put("stone", new Block(0)); + //2 BLOCKS.put("grass", new Block(1)); + //3 BLOCKS.put("dirt", new Block(2)); + //4 BLOCKS.put("cobblestone", new Block(3)); + //5 BLOCKS.put("planks", new Block(4)); + //6 BLOCKS.put("sapling", new Block(5,false,false,true)); + //7 BLOCKS.put("bedrock", new Block(6)); + //8 BLOCKS.put("water", new Block(7,false,false,true)); + //9 BLOCKS.put("lava", new Block(8,false,false,false)); + //10 BLOCKS.put("sand", new Block(9)); + //11 BLOCKS.put("gravel", new Block(10)); + //12 BLOCKS.put("gold_ore", new Block(11)); + //13 BLOCKS.put("iron_ore", new Block(12)); + //14 BLOCKS.put("coal_ore", new Block(13)); + //15 BLOCKS.put("log", new Block(14)); + //16 BLOCKS.put("leaves", new Block(15)); + //17 BLOCKS.put("sponge", new Block(16)); + //18 BLOCKS.put("glass", new Block(17,true,false,true)); + //19 BLOCKS.put("lapis_ore", new Block(18)); + //20 BLOCKS.put("lapis_block", new Block(19)); + //21 BLOCKS.put("sandstone", new Block(20)); + //22 BLOCKS.put("noteblock", new Block(21)); + //23 BLOCKS.put("bed_l", new Block(22,false,true,true)); + //24 BLOCKS.put("bed_r", new Block(23, false,true, true)); + //25 BLOCKS.put("cobweb", new Block(24,false,false,true)); + //26 BLOCKS.put("tallgrass", new Block(25,false,false,true)); + //27 BLOCKS.put("deadbush", new Block(26,false,false,true)); + //28 BLOCKS.put("brick_block", new Block(27)); + //29 BLOCKS.put("dandelion", new Block(28,false,false,true)); + //30 BLOCKS.put("rose", new Block(29,false,false,true)); + //31 BLOCKS.put("brown_mushroom", new Block(30,false,false,true)); + //32 BLOCKS.put("red_mushroom", new Block(31,false,false,true)); + //33 BLOCKS.put("wool_while", new Block(32,true,false,false)); + //34 BLOCKS.put("wool_orange", new Block(33,true,false,false)); + //35 BLOCKS.put("wool_magenta", new Block(34,true,false,false)); + //36 BLOCKS.put("wool_lightblue", new Block(35,true,false,false)); + //37 BLOCKS.put("wool_yellow", new Block(36,true,false,false)); + //38 BLOCKS.put("wool_lime", new Block(37,true,false,false)); + //39 BLOCKS.put("wool_pink", new Block(38,true,false,false)); + //40 BLOCKS.put("wool_gray", new Block(39,true,false,false)); + //41 BLOCKS.put("wool_lightgray", new Block(40,true,false,false)); + //42 BLOCKS.put("wool_cyan", new Block(41,true,false,false)); + //43 BLOCKS.put("wool_purple", new Block(42,true,false,false)); + //44 BLOCKS.put("wool_blue", new Block(43,true,false,false)); + //45 BLOCKS.put("wool_brown", new Block(44,true,false,false)); + //46 BLOCKS.put("wool_green", new Block(45,true,false,false)); + //47 BLOCKS.put("wool_red", new Block(46,true,false,false)); + //48 BLOCKS.put("wool_black", new Block(47,true,false,false)); + //49 BLOCKS.put("gold_block", new Block(48)); + //50 BLOCKS.put("iron_block", new Block(49)); + //51 BLOCKS.put("stone_slab", new Block(0, 8, 16,8, 50, true, false, true)); + //52 BLOCKS.put("double_stone_slab", new Block(51)); + //53 BLOCKS.put("sandstone_slab", new Block(0, 8, 16,8, 52, true, false, true)); + //54 BLOCKS.put("wooden_slab", new Block(0, 8, 16,8, 53, true, false, true)); + //55 BLOCKS.put("cobblestone_slab", new Block(0, 8, 16,8, 54, true, false, true)); + //56 BLOCKS.put("brick_slab", new Block(0, 8, 16,8, 55, true, false, true)); - BLOCKS.put("stonebrick", new Block(56)); - BLOCKS.put("stone_brick_slab", new Block(0, 8, 16,8, 57, true, false, true)); - BLOCKS.put("cactus", new Block(1, 0, 14, 16, 58, true, false, true)); + //57 + BLOCKS.put("stonebrick", new Block(64)); + //58 + BLOCKS.put("stone_brick_slab", new Block(0, 8, 16,8, 56, true, false, true)); + //59 + BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, true, false, true)); + //60 + BLOCKS.put("water_12", new Block(58,false,false,true)); + //61 + BLOCKS.put("water_8", new Block(59,false,false,true)); + //62 + BLOCKS.put("water_4", new Block(60,false,false,true)); + //63 + BLOCKS.put("lava_12", new Block(61,false,false,true)); + //64 + BLOCKS.put("lava_8", new Block(62,false,false,true)); + //65 + BLOCKS.put("lava_4", new Block(63,false,false,true)); + //66 + BLOCKS.put("obsidian", new Block(65)); } public static void load() { diff --git a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java index 8c0f4ca..97b5481 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java +++ b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java @@ -23,7 +23,6 @@ public class WorldGen { int t; res[0] = mid; for (int i=1; i-3 && t<3) t=0; else t/=Math.abs(t); if (i>width-(max-min)) { @@ -33,6 +32,12 @@ public class WorldGen { res[i] = res[i-1] + t; if (res[i]max) res[i] = max; + if (i>=width/2) { + bMap [i] = 1; + if (res[i] < 60) res[i] = 60; + } else { + bMap[i] = 0; + } } return res; } @@ -73,7 +78,7 @@ public class WorldGen { rand = new RandomXS128(seed); foreMap = new int[width][height]; backMap = new int[width][height]; - hMap = genLandscape(width, height/8*3, height/8, height/2); + hMap = genLandscape(width, height/4, height/8, height/2); for (int x=0; x Date: Mon, 10 Sep 2018 18:34:47 +0700 Subject: [PATCH 05/16] Autoswim on touch screen --- .../src/ru/deadsoftware/cavecraft/game/GameInput.java | 11 ++++++++--- .../ru/deadsoftware/cavecraft/game/GamePhysics.java | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index d151ec6..c868a8a 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -17,6 +17,11 @@ public class GameInput { this.gameProc = gameProc; } + private boolean checkSwim() { + return (CaveGame.TOUCH && Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16, + (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16))); + } + private void wasdPressed(int keycode) { if (gameProc.ctrlMode==0 || !CaveGame.TOUCH) { switch (keycode) { @@ -62,8 +67,7 @@ public class GameInput { break; case Input.Keys.SPACE: - if (Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16, - (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16))) { + if (checkSwim()) { gameProc.swim = true; } else if (gameProc.player.canJump) { gameProc.player.moveY.add(0, -7); @@ -102,11 +106,12 @@ public class GameInput { switch (keycode) { case Input.Keys.A: case Input.Keys.D: gameProc.player.moveX.x = 0; + if (gameProc.swim) gameProc.swim = false; break; case Input.Keys.SPACE: case Input.Keys.CONTROL_LEFT: if (gameProc.player.flyMode) gameProc.player.moveY.setZero(); - gameProc.swim = false; + 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 244875d..28a8333 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -84,6 +84,7 @@ public class GamePhysics { } if (Items.isFluid(getBlock(pl.getRect()))) { + if (CaveGame.TOUCH && pl.moveX.x!=0 && !gameProc.swim && !pl.flyMode) gameProc.swim = true; if (!gameProc.swim) { if (!pl.flyMode && pl.moveY.y < 9) pl.moveY.add(gravity.x / 2, gravity.y / 2); if (!pl.flyMode && pl.moveY.y > 9) pl.moveY.add(0, -.9f); @@ -91,7 +92,10 @@ public class GamePhysics { pl.moveY.add(0, -.5f); if (pl.moveY.y<-3) pl.moveY.y = -3; } - } else if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity); + } else { + if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity); + if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false; + } pl.position.add(pl.moveX); if (checkColl(pl.getRect())) { -- 2.29.2 From 878489009db3feb875e4a0f05de955386b7afd7d Mon Sep 17 00:00:00 2001 From: fred-boy Date: Mon, 10 Sep 2018 18:47:50 +0700 Subject: [PATCH 06/16] Minor changes --- core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java | 3 +-- core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index fac4ba2..93618f2 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -174,9 +174,8 @@ public class GameRenderer extends Renderer { private void drawGamePlay() { drawWorldBackground(); - //Mob.animateMobs(); - for (Mob mob : gameProc.mobs) drawMob(mob); drawPlayer(gameProc.player); + for (Mob mob : gameProc.mobs) drawMob(mob); drawWorldForeground(); drawGUI(); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java index 44333ab..04a96f6 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java @@ -25,14 +25,15 @@ public class Pig extends Mob{ public void changeDir() { dir=-dir+1; moveX.set(-1+2*dir,0); - if (MathUtils.randomBoolean(.0025f)) { - moveX.set(0, 0); - } } @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 (moveX.x != 0f) animation+=ANIM_SPEED; else animation=0; if (animation>=60 || animation<=-60) { ANIM_SPEED = -ANIM_SPEED; -- 2.29.2 From 755ddc2f16f28a493969c22cd3513acddc6e67cd Mon Sep 17 00:00:00 2001 From: fred-boy Date: Mon, 10 Sep 2018 21:14:48 +0700 Subject: [PATCH 07/16] Minor fixes --- core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java | 4 ++-- core/src/ru/deadsoftware/cavecraft/game/WorldGen.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index 28a8333..a3410c2 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -29,11 +29,11 @@ public class GamePhysics { switch (dir) { case 0: bl = gameProc.world.getForeMap((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16)); - if (checkColl(new Rectangle(rect.x+rect.width/2, rect.y-18, rect.width, rect.height))) bl=0; + if (checkColl(new Rectangle(rect.x-8, rect.y-18, rect.width, rect.height))) bl=0; break; case 1: bl = gameProc.world.getForeMap((int)((rect.x+rect.width+8)/16),(int)((rect.y+rect.height-8)/16)); - if (checkColl(new Rectangle(rect.x+rect.width/2, rect.y-18, rect.width, rect.height))) bl=0; + if (checkColl(new Rectangle(rect.x+rect.width+8, rect.y-18, rect.width, rect.height))) bl=0; break; default: bl=0; diff --git a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java index 97b5481..4b4f0e8 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java +++ b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java @@ -39,6 +39,7 @@ public class WorldGen { bMap[i] = 0; } } + if (res[0] Date: Mon, 10 Sep 2018 23:06:28 +0700 Subject: [PATCH 08/16] Minor enhancements --- .../cavecraft/game/GameInput.java | 6 +- .../cavecraft/game/GamePhysics.java | 6 +- .../deadsoftware/cavecraft/game/GameProc.java | 129 +++++++++--------- .../cavecraft/game/GameRenderer.java | 4 +- .../cavecraft/game/GameWorld.java | 31 ++++- .../ru/deadsoftware/cavecraft/game/Items.java | 26 ++-- .../deadsoftware/cavecraft/game/WorldGen.java | 32 ++++- 7 files changed, 152 insertions(+), 82 deletions(-) diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index c868a8a..7a66d99 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -18,7 +18,7 @@ public class GameInput { } private boolean checkSwim() { - return (CaveGame.TOUCH && Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16, + return (Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16, (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16))); } @@ -28,10 +28,12 @@ public class GameInput { case Input.Keys.A: gameProc.player.moveX.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.dir = 1; + if (CaveGame.TOUCH && checkSwim()) gameProc.swim = true; break; } } else if (CaveGame.TOUCH){ @@ -106,7 +108,7 @@ public class GameInput { switch (keycode) { case Input.Keys.A: case Input.Keys.D: gameProc.player.moveX.x = 0; - if (gameProc.swim) gameProc.swim = false; + if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false; break; case Input.Keys.SPACE: case Input.Keys.CONTROL_LEFT: diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index a3410c2..372bf6e 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -86,15 +86,15 @@ public class GamePhysics { if (Items.isFluid(getBlock(pl.getRect()))) { if (CaveGame.TOUCH && pl.moveX.x!=0 && !gameProc.swim && !pl.flyMode) gameProc.swim = true; if (!gameProc.swim) { - if (!pl.flyMode && pl.moveY.y < 9) pl.moveY.add(gravity.x / 2, gravity.y / 2); - if (!pl.flyMode && pl.moveY.y > 9) pl.moveY.add(0, -.9f); + 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); } else { pl.moveY.add(0, -.5f); if (pl.moveY.y<-3) pl.moveY.y = -3; } } else { if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity); - if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false; + //if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false; } pl.position.add(pl.moveX); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index 5d20e62..49fe705 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -118,140 +118,147 @@ public class GameProc implements Serializable{ private void updateFluids(int x, int y) { if (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y)!=8) { - if ((!Items.isWater(world.getForeMap(x-1,y)) || + if (world.getForeMap(x, y)==60) { + if (!Items.isWater(world.getForeMap(x, y - 1))) + world.setForeMap(x, y, world.getForeMap(x, y) + 1); + } else if ((!Items.isWater(world.getForeMap(x-1,y)) || (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) && (!Items.isWater(world.getForeMap(x+1,y)) || (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){ world.setForeMap(x, y, world.getForeMap(x, y)+1); - if (world.getForeMap(x, y)>62) world.setForeMap(x, y, 0); } + if (world.getForeMap(x, y)>63) world.setForeMap(x, y, 0); } - if (world.getForeMap(x, y) == 8) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + if (world.getForeMap(x, y) == 8 || world.getForeMap(x, y) == 60) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,8); + world.setForeMap(x,y+1,60); updateBlock(x, y+2); } else if (Items.isLava(world.getForeMap(x, y+1))) { if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 66); + else world.setForeMap(x, y+1, 68); } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { if (world.getForeMap(x+1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>60)) { - world.setForeMap(x+1,y,60); + (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>61)) { + world.setForeMap(x+1,y,61); updateBlock(x+1, y+1); } else if (Items.isLava(world.getForeMap(x+1, y))) { if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); - else world.setForeMap(x+1, y, 66); - } else if (world.getForeMap(x+1, y)==60 && world.getForeMap(x+2, y)==8) world.setForeMap(x+1, y, 8); + else world.setForeMap(x+1, y, 68); + } else if (world.getForeMap(x+1, y)==61 && (world.getForeMap(x+2, y)==8 || world.getForeMap(x+2, y)==60)) world.setForeMap(x+1, y, 8); if (world.getForeMap(x-1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>60)) { - world.setForeMap(x-1,y,60); + (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>61)) { + world.setForeMap(x-1,y,61); updateBlock(x-1, y+1); } else if (Items.isLava(world.getForeMap(x-1, y))) { if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); - else world.setForeMap(x-1, y, 66); - } else if (world.getForeMap(x-1, y)==60 && world.getForeMap(x-2, y)==8) world.setForeMap(x-1, y, 8); + else world.setForeMap(x-1, y, 68); + } else if (world.getForeMap(x-1, y)==61 && (world.getForeMap(x-2, y)==8 || world.getForeMap(x-2, y)==60)) world.setForeMap(x-1, y, 8); } return; } - if (world.getForeMap(x, y) == 60) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + if (world.getForeMap(x, y) == 61) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,8); + world.setForeMap(x,y+1,60); updateBlock(x, y+2); } else if (Items.isLava(world.getForeMap(x, y+1))) { if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 66); + else world.setForeMap(x, y+1, 68); } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { if (world.getForeMap(x+1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>61)){ - world.setForeMap(x+1,y,61); + (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>62)){ + world.setForeMap(x+1,y,62); updateBlock(x+1, y+1); } else if (Items.isLava(world.getForeMap(x+1, y))) { if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); - else world.setForeMap(x+1, y, 66); + else world.setForeMap(x+1, y, 68); } if (world.getForeMap(x-1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>61)){ - world.setForeMap(x-1,y,61); + (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>62)){ + world.setForeMap(x-1,y,62); updateBlock(x-1, y+1); } else if (Items.isLava(world.getForeMap(x-1, y))) { if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); - else world.setForeMap(x-1, y, 66); + else world.setForeMap(x-1, y, 68); } } return; } - if (world.getForeMap(x, y) == 61) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + if (world.getForeMap(x, y) == 62) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,8); + world.setForeMap(x,y+1,60); updateBlock(x, y+2); } else if (Items.isLava(world.getForeMap(x, y+1))) { if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 66); + else world.setForeMap(x, y+1, 68); } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { if (world.getForeMap(x+1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){ - world.setForeMap(x+1,y,62); + world.setForeMap(x+1,y,63); updateBlock(x+1, y+1); } else if (Items.isLava(world.getForeMap(x+1, y))) { if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); - else world.setForeMap(x+1, y, 66); + else world.setForeMap(x+1, y, 68); } if (world.getForeMap(x-1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){ - world.setForeMap(x-1,y,62); + world.setForeMap(x-1,y,63); updateBlock(x-1, y+1); } else if (Items.isLava(world.getForeMap(x-1, y))) { if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); - else world.setForeMap(x-1, y, 66); + else world.setForeMap(x-1, y, 68); } } return; } - if (world.getForeMap(x, y) == 62) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=60 && world.getForeMap(x, y+1)<=62) || + if (world.getForeMap(x, y) == 63) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,8); + world.setForeMap(x,y+1,60); updateBlock(x, y+2); } else if (Items.isLava(world.getForeMap(x, y+1))) { if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 66); + else world.setForeMap(x, y+1, 68); } return; } if (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x, y)!=9) { - if ((!Items.isLava(world.getForeMap(x-1,y)) || + if (world.getForeMap(x, y)==64) { + if (!Items.isLava(world.getForeMap(x, y - 1))) + world.setForeMap(x, y, world.getForeMap(x, y) + 1); + } else if ((!Items.isLava(world.getForeMap(x,y-1))) && + (!Items.isLava(world.getForeMap(x-1,y)) || (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) && (!Items.isLava(world.getForeMap(x+1,y)) || (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){ world.setForeMap(x, y, world.getForeMap(x, y)+1); - if (world.getForeMap(x, y)>65) world.setForeMap(x, y, 0); } + if (world.getForeMap(x, y)>67) world.setForeMap(x, y, 0); } - if (world.getForeMap(x, y) == 9) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + if (world.getForeMap(x, y) == 9 || world.getForeMap(x, y) == 64) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,9); + world.setForeMap(x,y+1,64); updateBlock(x, y+2); } else if (Items.isWater(world.getForeMap(x, y+1))) { world.setForeMap(x, y+1, 1); } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { if (world.getForeMap(x+1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>63)) { - world.setForeMap(x+1,y,63); + (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>65)) { + world.setForeMap(x+1,y,65); updateBlock(x+1, y+1); } else if (Items.isWater(world.getForeMap(x+1, y))) { world.setForeMap(x+1, y, 1); @@ -259,8 +266,8 @@ public class GameProc implements Serializable{ if (world.getForeMap(x-1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>63)) { - world.setForeMap(x-1,y,63); + (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>65)) { + world.setForeMap(x-1,y,65); updateBlock(x-1, y+1); } else if (Items.isWater(world.getForeMap(x-1, y))) { world.setForeMap(x-1, y, 1); @@ -268,18 +275,18 @@ public class GameProc implements Serializable{ } return; } - if (world.getForeMap(x, y) == 63) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + if (world.getForeMap(x, y) == 65) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,9); + world.setForeMap(x,y+1,64); updateBlock(x, y+2); } else if (Items.isWater(world.getForeMap(x, y+1))) { world.setForeMap(x, y+1, 1); } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { if (world.getForeMap(x+1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>64)){ - world.setForeMap(x+1,y,64); + (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>66)){ + world.setForeMap(x+1,y,66); updateBlock(x+1, y+1); } else if (Items.isWater(world.getForeMap(x+1, y))) { world.setForeMap(x+1, y, 1); @@ -287,8 +294,8 @@ public class GameProc implements Serializable{ if (world.getForeMap(x-1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>64)){ - world.setForeMap(x-1,y,64); + (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>66)){ + world.setForeMap(x-1,y,66); updateBlock(x-1, y+1); } else if (Items.isWater(world.getForeMap(x-1, y))) { world.setForeMap(x-1, y, 1); @@ -296,17 +303,17 @@ public class GameProc implements Serializable{ } return; } - if (world.getForeMap(x, y) == 64) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + if (world.getForeMap(x, y) == 66) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,9); + world.setForeMap(x,y+1,64); updateBlock(x, y+2); } else if (Items.isWater(world.getForeMap(x, y+1))) { world.setForeMap(x, y+1, 1); } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { if (world.getForeMap(x+1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){ - world.setForeMap(x+1,y,65); + world.setForeMap(x+1,y,67); updateBlock(x+1, y+1); } else if (Items.isWater(world.getForeMap(x+1, y))) { world.setForeMap(x+1, y, 1); @@ -314,7 +321,7 @@ public class GameProc implements Serializable{ if (world.getForeMap(x-1, y)==0 || (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){ - world.setForeMap(x-1,y,65); + world.setForeMap(x-1,y,67); updateBlock(x-1, y+1); } else if (Items.isWater(world.getForeMap(x-1, y))) { world.setForeMap(x-1, y, 1); @@ -322,10 +329,10 @@ public class GameProc implements Serializable{ } return; } - if (world.getForeMap(x, y) == 65) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=63 && world.getForeMap(x, y+1)<=65) || + if (world.getForeMap(x, y) == 67) { + if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,9); + world.setForeMap(x,y+1,64); updateBlock(x, y+2); } else if (Items.isWater(world.getForeMap(x, y+1))) { world.setForeMap(x, y+1, 1); @@ -377,7 +384,7 @@ public class GameProc implements Serializable{ DO_UPD = false; } - for (int y=(int)renderer.camera.position.y/16-1; y<(int)(renderer.camera.position.y+renderer.camera.viewportHeight)/16+1; y++) { + for (int y=0; y0 || gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY)>0 || - gameProc.ctrlMode==1) + gameProc.ctrlMode==1 || + !CaveGame.TOUCH) spriteBatch.draw(Assets.guiCur, gameProc.cursorX*16-camera.position.x, gameProc.cursorY*16-camera.position.y); @@ -202,6 +203,7 @@ public class GameRenderer extends Renderer { drawString("X: "+(int)(gameProc.player.position.x/16),0, 10); drawString("Y: "+(int)(gameProc.player.position.y/16),0, 20); drawString("Mobs: "+gameProc.mobs.size(), 0, 30); + drawString("Block: "+Items.BLOCKS.getKeyAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)), 0, 40); } spriteBatch.end(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java index 42050e2..88f435b 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -71,13 +71,38 @@ public class GameWorld { } } + private void placeSlab(int x, int y, int value) { + switch (value) { + case 51: + setForeMap(x, y, 52); + break; + case 53: + setForeMap(x, y, 21); + break; + case 54: + setForeMap(x, y, 5); + break; + case 55: + setForeMap(x, y, 4); + break; + case 56: + setForeMap(x, y, 28); + break; + case 58: + setForeMap(x, y, 57); + break; + } + } + public void placeToForeground(int x, int y, int value) { if (getForeMap(x,y) == 0 || value == 0 || !Items.BLOCKS.getValueAt(getForeMap(x, y)).collision) { setForeMap(x, y, value); - GameProc.UPD_X = x-8; - GameProc.UPD_Y = y-8; - GameProc.DO_UPD = true; + } else if (Items.isSlab(value) && getForeMap(x, y) == value) { + placeSlab(x, y, value); } + GameProc.UPD_X = x-8; + GameProc.UPD_Y = y-8; + GameProc.DO_UPD = true; } public void placeToBackground(int x, int y, int value) { diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index 9987cbe..cb2f736 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -8,15 +8,19 @@ public class Items { public static ArrayMap BLOCKS = new ArrayMap(); public static boolean isFluid(int bl) { - return (bl == 8 || bl == 9 || bl == 60 || bl == 61 || bl == 62 || bl == 63 || bl == 64 || bl == 65); + return (bl == 8 || bl == 9 || bl == 60 || bl == 61 || bl == 62 || bl == 63 || bl == 64 || bl == 65 || bl == 66 || bl == 67); } public static boolean isWater(int bl) { - return (bl == 8 || bl == 60 || bl == 61 || bl == 62); + return (bl == 8 || bl == 60 || bl == 61 || bl == 62 || bl == 63); } public static boolean isLava(int bl) { - return (bl == 9 || bl == 63 || bl == 64 || bl == 65); + return (bl == 9 || bl == 64 || bl == 65 || bl == 66 || bl == 67); + } + + public static boolean isSlab(int bl) { + return (bl == 51 || bl == 53 || bl == 54 || bl == 55 || bl == 56 || bl == 58); } public static void loadBlocks() { @@ -141,18 +145,22 @@ public class Items { //59 BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, true, false, true)); //60 - BLOCKS.put("water_12", new Block(58,false,false,true)); + BLOCKS.put("water_16", new Block(7,false,false,true)); //61 - BLOCKS.put("water_8", new Block(59,false,false,true)); + BLOCKS.put("water_12", new Block(58,false,false,true)); //62 - BLOCKS.put("water_4", new Block(60,false,false,true)); + BLOCKS.put("water_8", new Block(59,false,false,true)); //63 - BLOCKS.put("lava_12", new Block(61,false,false,true)); + BLOCKS.put("water_4", new Block(60,false,false,true)); //64 - BLOCKS.put("lava_8", new Block(62,false,false,true)); + BLOCKS.put("lava_16", new Block(8,false,false,true)); //65 - BLOCKS.put("lava_4", new Block(63,false,false,true)); + BLOCKS.put("lava_12", new Block(61,false,false,true)); //66 + BLOCKS.put("lava_8", new Block(62,false,false,true)); + //67 + BLOCKS.put("lava_4", new Block(63,false,false,true)); + //68 BLOCKS.put("obsidian", new Block(65)); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java index 4b4f0e8..bf9eadf 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java +++ b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java @@ -132,12 +132,38 @@ public class WorldGen { } } } - if (x>2 && x2 && x Date: Tue, 11 Sep 2018 00:02:01 +0700 Subject: [PATCH 09/16] Add items --- .../cavecraft/game/GameInput.java | 6 +- .../deadsoftware/cavecraft/game/GameProc.java | 12 +- .../cavecraft/game/GameRenderer.java | 21 ++-- .../ru/deadsoftware/cavecraft/game/Items.java | 115 ++++++++++++++++++ .../cavecraft/game/objects/Item.java | 29 +++++ 5 files changed, 168 insertions(+), 15 deletions(-) create mode 100644 core/src/ru/deadsoftware/cavecraft/game/objects/Item.java diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index 7a66d99..672c4c9 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -144,7 +144,7 @@ public class GameInput { int iy = (int) (screenY - (gameProc.renderer.camera.viewportHeight / 2 - Assets.creativeInv.getRegionHeight() / 2 + 18)) / 18; int item = gameProc.creativeScroll*8+(ix + iy * 8); if (ix>=8 || ix<0 || iy<0 || iy>=5) item=-1; - if (item >= 0 && item < Items.BLOCKS.size) { + if (item >= 0 && item < Items.ITEMS.size()) { for (int i = 8; i > 0; i--) { gameProc.player.inventory[i] = gameProc.player.inventory[i - 1]; } @@ -157,8 +157,8 @@ public class GameInput { screenX 0) { gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY, 0); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index 49fe705..45c62b8 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -59,7 +59,7 @@ public class GameProc implements Serializable{ renderer = new GameRenderer(this,480, 480*((float)GameScreen.getHeight()/GameScreen.getWidth())); } - maxCreativeScroll = Items.BLOCKS.size/8; + maxCreativeScroll = Items.ITEMS.size()/8; GameSaver.save(this); } @@ -373,6 +373,13 @@ public class GameProc implements Serializable{ } } + public void useItem(int x, int y, int id, boolean bg) { + if (Items.ITEMS.get(id).getType()==0) { + if (!bg) world.placeToForeground(x, y, Items.ITEMS.get(id).getBlock()); + else world.placeToBackground(x, y, Items.ITEMS.get(id).getBlock()); + } + } + public void update(float delta) { RUN_TIME += delta; @@ -406,8 +413,7 @@ public class GameProc implements Serializable{ if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) { if (touchDownButton== Input.Buttons.RIGHT) { - world.placeToBackground(cursorX, cursorY, - player.inventory[invSlot]); + useItem(cursorX, cursorY, player.inventory[invSlot], true); } else if (touchDownY< Assets.invBar.getRegionHeight() && touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 && touchDownX0 && i0 && i0) - spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture()], - x+8+i*18, y+Assets.creativeInv.getRegionHeight()-24); + if (Items.ITEMS.get(i).getType() == 0) + spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(i).getTexture()], + x+8+i*18, y+Assets.creativeInv.getRegionHeight()-24); } } @@ -149,9 +151,10 @@ public class GameRenderer extends Renderer { spriteBatch.draw(Assets.invBar, camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2, 0); for (int i=0; i<9; i++) { if (gameProc.player.inventory[i]>0) { - spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture()], - camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2+3+i*20, - 3); + if (Items.ITEMS.get(gameProc.player.inventory[i]).getType()==0) + spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], + camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2+3+i*20, + 3); } } spriteBatch.draw(Assets.invBarCur, diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index cb2f736..2a8c532 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -2,10 +2,14 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.utils.ArrayMap; import ru.deadsoftware.cavecraft.game.objects.Block; +import ru.deadsoftware.cavecraft.game.objects.Item; + +import java.util.ArrayList; public class Items { public static ArrayMap BLOCKS = new ArrayMap(); + public static ArrayList ITEMS = new ArrayList(); 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); @@ -23,6 +27,116 @@ public class Items { return (bl == 51 || bl == 53 || bl == 54 || bl == 55 || bl == 56 || bl == 58); } + public static void loadItems() { + //0 + ITEMS.add(new Item("Stone", 0, 0, 1)); + //1 + ITEMS.add(new Item("Grass", 1, 0, 2)); + //2 + ITEMS.add(new Item("Dirt", 2, 0, 3)); + //3 + ITEMS.add(new Item("Cobblestone", 3, 0, 4)); + //4 + ITEMS.add(new Item("Planks", 4, 0, 5)); + //5 + ITEMS.add(new Item("Sapling", 5, 0, 6)); + //6 + ITEMS.add(new Item("Bedrock", 6, 0, 7)); + //7 + ITEMS.add(new Item("Sand", 9, 0, 10)); + //8 + ITEMS.add(new Item("Gravel", 10, 0, 11)); + //9 + ITEMS.add(new Item("Golden Ore", 11, 0, 12)); + //10 + ITEMS.add(new Item("Iron Ore", 12, 0, 13)); + //11 + ITEMS.add(new Item("Coal Ore", 13, 0, 14)); + //12 + ITEMS.add(new Item("Wood", 14, 0, 15)); + //13 + ITEMS.add(new Item("Leaves", 15, 0, 16)); + //14 + ITEMS.add(new Item("Glass", 17, 0, 18)); + //15 + ITEMS.add(new Item("Lapis Ore", 18, 0, 19)); + //16 + ITEMS.add(new Item("Lapis Block", 19, 0, 20)); + //17 + ITEMS.add(new Item("Sandstone", 20, 0, 21)); + //18 + ITEMS.add(new Item("Cobweb", 24, 0, 25)); + //19 + ITEMS.add(new Item("Tall Grass", 25, 0, 26)); + //20 + ITEMS.add(new Item("Dead Bush", 26, 0, 27)); + //21 + ITEMS.add(new Item("Bricks", 27, 0, 28)); + //22 + ITEMS.add(new Item("Dandelion", 28, 0, 29)); + //23 + ITEMS.add(new Item("Rose", 29, 0, 30)); + //24 + ITEMS.add(new Item("Mushroom", 30, 0, 31)); + //25 + ITEMS.add(new Item("Mushroom", 31, 0, 32)); + //26 + ITEMS.add(new Item("White Wool", 32, 0, 33)); + //27 + ITEMS.add(new Item("Orange Wool", 33, 0, 34)); + //28 + ITEMS.add(new Item("Magenta Wool", 34, 0, 35)); + //29 + ITEMS.add(new Item("Light Blue Wool", 35, 0, 36)); + //30 + ITEMS.add(new Item("Yellow Wool", 36, 0, 37)); + //31 + ITEMS.add(new Item("Lime Wool", 37, 0, 38)); + //32 + ITEMS.add(new Item("Pink Wool", 38, 0, 39)); + //33 + ITEMS.add(new Item("Gray Wool", 39, 0, 40)); + //34 + ITEMS.add(new Item("Light Gray Wool", 40, 0, 41)); + //35 + ITEMS.add(new Item("Cyan Wool", 41, 0, 42)); + //36 + ITEMS.add(new Item("Purple Wool", 42, 0, 43)); + //37 + ITEMS.add(new Item("Blue Wool", 43, 0, 44)); + //38 + ITEMS.add(new Item("Brown Wool", 44, 0, 45)); + //39 + ITEMS.add(new Item("Green Wool", 45, 0, 46)); + //40 + ITEMS.add(new Item("Red Wool", 46, 0, 47)); + //41 + ITEMS.add(new Item("Black Wool", 47, 0, 48)); + //42 + ITEMS.add(new Item("Golden Block", 48, 0, 49)); + //43 + ITEMS.add(new Item("Iron Block", 49, 0, 50)); + //44 + ITEMS.add(new Item("Stone Slab", 50, 0, 51)); + //45 + ITEMS.add(new Item("Sandstone Slab", 52, 0, 53)); + //46 + ITEMS.add(new Item("Wooden Slab", 53, 0, 54)); + //47 + ITEMS.add(new Item("Cobblestone Slab", 54, 0, 55)); + //48 + ITEMS.add(new Item("Brick Slab", 55, 0, 56)); + //49 + ITEMS.add(new Item("Stone Brick", 64, 0, 57)); + //50 + ITEMS.add(new Item("Stone Brick Slab", 56, 0, 58)); + //51 + ITEMS.add(new Item("Cactus", 57, 0, 59)); + //52 + ITEMS.add(new Item("Obsidian", 65, 0, 68)); + + } + public static void loadBlocks() { //0 BLOCKS.put("none", null); @@ -166,6 +280,7 @@ public class Items { public static void load() { loadBlocks(); + loadItems(); } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java new file mode 100644 index 0000000..5e6fdeb --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java @@ -0,0 +1,29 @@ +package ru.deadsoftware.cavecraft.game.objects; + +public class Item { + + private int texture, type; + private int block; + private String name; + + public Item(String name, int texture, int type, int block) { + this.name = name; + this.texture = texture; + this.type = type; + this.block = block; + } + + public int getTexture() { + return texture; + } + public int getType() { + return type; + } + public int getBlock() { + return block; + } + public String getName() { + return name; + } + +} -- 2.29.2 From 1cc111dfe31e7f7098e01afeaa025e19f91aa624 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Fri, 14 Sep 2018 17:20:34 +0700 Subject: [PATCH 10/16] Add item in player's hand --- android/assets/items.png | Bin 0 -> 1349 bytes .../cavecraft/game/GamePhysics.java | 1 - .../deadsoftware/cavecraft/game/GameProc.java | 2 +- .../cavecraft/game/GameRenderer.java | 64 ++++++++-- .../ru/deadsoftware/cavecraft/game/Items.java | 116 ++++++++++-------- .../cavecraft/game/objects/Item.java | 7 +- .../cavecraft/game/objects/Player.java | 9 -- .../deadsoftware/cavecraft/misc/Assets.java | 19 ++- .../cavecraft/desktop/DesktopLauncher.java | 7 +- 9 files changed, 148 insertions(+), 77 deletions(-) create mode 100644 android/assets/items.png diff --git a/android/assets/items.png b/android/assets/items.png new file mode 100644 index 0000000000000000000000000000000000000000..cecb5e8cc63369f91734298023b6aa0a34898973 GIT binary patch literal 1349 zcmd^8`7_%I6#r_C)LlD0Y+Wn6R3)0F2204+d`VGhC!$oTHrneNsVRLo8_h@(<$v1GF(nL*IF`bCnB@n`IN^XBvUyf^daeSUa(H*r`)y$gB( z02umR1MvW$rJ-8DDIE=jC%zTuH8-o0Hda((h6_3HPtj> z$$o)8uzz)pP9bdHLr5$DXbb(otAvy}`K&0mjA{T`{o46IBcn_^f0m9_ z;9O9&AMvkxUh8v;7lPGUKZGPWp-A;zPvCdu-Zrt>b|&B#UG1TQX5BmOEqU*|^iyYM z-4e!ApAN`(dfZ(%lB)A%O3w+|)){!tn+P-fF4XJ6J9}Zw*vROz6pO{0jT;*nAf=pe zu8_h|s;UPMHzJuLN`Du9p2&E#cGvo!FFR~+K*nWrL{Y2*mqDRWzP0emaNFPCPn5uP zbc7NCdue&NgsWKH+pCw$Ff0cvW;sGM-|G<3-G0$axfV<}Ze9h3Mlh~wx3J2Zi3k;! z%Y7IfJshDL9v=S4O^RAqp#DCvsqCaKUsiKIu!sQ%`su#LXrLaT)$ zd;a4z0mjLx7+2+1B;mzdrpLqY!0L?XPQ^jPhoyQ^uL>0a_wif3@4*3L5~iDtLZ z4UsA`y+BLzcCc~yiY=&Tdb(;q-z*z zht_~6hu|5vN^AlK#^M5tEKUf{GuZEfAU>b3-+;eFrPHyX zbGRxmFV7pS7mLMqY=I%0DPAX7!}0Tzzm|WO*(O%7SPPdx&|R@8&CN{~3*#kGR8K8J zO#NZ-mSHKc(sv|s=lh4XhtqbLX4?79c(tH$4p(cbS#RM%Lk7?5PSt752ED*F#CT+- zImc~Wm)B&JHp#VDdQ^*T+k^1uT|pDQ|Zv-w};A?;?u|n?pFHrK=0jYx)eRIs9|1LRPMp zrny*7F_lTE!J<7E{?t@m_wID|BlP34-jk+l(Sey9a>13ly$8ho`x?7%O9t}7;r zO^l}k3nsUt!_$=NbBm?}E9KDEG9pTahDItdH~JH$6IA8dE4<#UX;L8gwzWoDvl0-$ y*as1yMD8I0s`wzQwrB2+X3|e+-u{0So4f0 && Items.ITEMS.get(id).getType()==0) { if (!bg) world.placeToForeground(x, y, Items.ITEMS.get(id).getBlock()); else world.placeToBackground(x, y, Items.ITEMS.get(id).getBlock()); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 1eef325..ee9d6d4 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.GameScreen; @@ -112,6 +113,26 @@ public class GameRenderer extends Renderer { //body spriteBatch.draw(Assets.playerSprite[pl.dir][1], pl.position.x - camera.position.x - 2, pl.position.y - camera.position.y + 8); + //item in hand + if (pl.inventory[gameProc.invSlot]>0) + switch (Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getType()) { + case 0: + Assets.blockTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setPosition( + pl.position.x - camera.position.x - 8*MathUtils.sin(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()), + pl.position.y - camera.position.y + 6 + 8*MathUtils.cos(MathUtils.degRad*Assets.playerSprite[0][2].getRotation())); + Assets.blockTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].draw(spriteBatch); + break; + default: + Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir==0), false); + Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setRotation( + -45+pl.dir*90+Assets.playerSprite[0][2].getRotation()); + Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setPosition( + pl.position.x - camera.position.x -10+(12*pl.dir) - 8*MathUtils.sin(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()), + pl.position.y - camera.position.y + 2 + 8*MathUtils.cos(MathUtils.degRad*Assets.playerSprite[0][2].getRotation())); + Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].draw(spriteBatch); + Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir==0), false); + break; + } //front hand Assets.playerSprite[0][2].setPosition( pl.position.x - camera.position.x - 6, @@ -127,16 +148,31 @@ public class GameRenderer extends Renderer { y+18+(gameProc.creativeScroll*(72/gameProc.maxCreativeScroll))); for (int i=gameProc.creativeScroll*8; i0 && i0) - if (Items.ITEMS.get(i).getType() == 0) - spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(i).getTexture()], - x+8+i*18, y+Assets.creativeInv.getRegionHeight()-24); + switch (Items.ITEMS.get(gameProc.player.inventory[i]).getType()) { + case 0: + spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], + x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); + break; + case 1: + spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], + x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); + break; + } } } @@ -151,10 +187,18 @@ public class GameRenderer extends Renderer { spriteBatch.draw(Assets.invBar, camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2, 0); for (int i=0; i<9; i++) { if (gameProc.player.inventory[i]>0) { - if (Items.ITEMS.get(gameProc.player.inventory[i]).getType()==0) - spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], - camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2+3+i*20, + switch (Items.ITEMS.get(gameProc.player.inventory[i]).getType()) { + case 0: + spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], + camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, 3); + break; + case 1: + spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], + camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, + 3); + break; + } } } spriteBatch.draw(Assets.invBarCur, diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index 2a8c532..db32ad1 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -29,111 +29,123 @@ public class Items { public static void loadItems() { //0 - ITEMS.add(new Item("Stone", 0, 0, 1)); + ITEMS.add(null); //1 - ITEMS.add(new Item("Grass", 1, 0, 2)); + ITEMS.add(new Item("Stone", 0, 0, 1)); //2 - ITEMS.add(new Item("Dirt", 2, 0, 3)); + ITEMS.add(new Item("Grass", 1, 0, 2)); //3 - ITEMS.add(new Item("Cobblestone", 3, 0, 4)); + ITEMS.add(new Item("Dirt", 2, 0, 3)); //4 - ITEMS.add(new Item("Planks", 4, 0, 5)); + ITEMS.add(new Item("Cobblestone", 3, 0, 4)); //5 - ITEMS.add(new Item("Sapling", 5, 0, 6)); + ITEMS.add(new Item("Planks", 4, 0, 5)); //6 - ITEMS.add(new Item("Bedrock", 6, 0, 7)); + ITEMS.add(new Item("Sapling", 5, 0, 6)); //7 - ITEMS.add(new Item("Sand", 9, 0, 10)); + ITEMS.add(new Item("Bedrock", 6, 0, 7)); //8 - ITEMS.add(new Item("Gravel", 10, 0, 11)); + ITEMS.add(new Item("Sand", 9, 0, 10)); //9 - ITEMS.add(new Item("Golden Ore", 11, 0, 12)); + ITEMS.add(new Item("Gravel", 10, 0, 11)); //10 - ITEMS.add(new Item("Iron Ore", 12, 0, 13)); + ITEMS.add(new Item("Golden Ore", 11, 0, 12)); //11 - ITEMS.add(new Item("Coal Ore", 13, 0, 14)); + ITEMS.add(new Item("Iron Ore", 12, 0, 13)); //12 - ITEMS.add(new Item("Wood", 14, 0, 15)); + ITEMS.add(new Item("Coal Ore", 13, 0, 14)); //13 - ITEMS.add(new Item("Leaves", 15, 0, 16)); + ITEMS.add(new Item("Wood", 14, 0, 15)); //14 - ITEMS.add(new Item("Glass", 17, 0, 18)); + ITEMS.add(new Item("Leaves", 15, 0, 16)); //15 - ITEMS.add(new Item("Lapis Ore", 18, 0, 19)); + ITEMS.add(new Item("Glass", 17, 0, 18)); //16 - ITEMS.add(new Item("Lapis Block", 19, 0, 20)); + ITEMS.add(new Item("Lapis Ore", 18, 0, 19)); //17 - ITEMS.add(new Item("Sandstone", 20, 0, 21)); + ITEMS.add(new Item("Lapis Block", 19, 0, 20)); //18 - ITEMS.add(new Item("Cobweb", 24, 0, 25)); + ITEMS.add(new Item("Sandstone", 20, 0, 21)); //19 - ITEMS.add(new Item("Tall Grass", 25, 0, 26)); + ITEMS.add(new Item("Cobweb", 24, 0, 25)); //20 - ITEMS.add(new Item("Dead Bush", 26, 0, 27)); + ITEMS.add(new Item("Tall Grass", 25, 0, 26)); //21 - ITEMS.add(new Item("Bricks", 27, 0, 28)); + ITEMS.add(new Item("Dead Bush", 26, 0, 27)); //22 - ITEMS.add(new Item("Dandelion", 28, 0, 29)); + ITEMS.add(new Item("Bricks", 27, 0, 28)); //23 - ITEMS.add(new Item("Rose", 29, 0, 30)); + ITEMS.add(new Item("Dandelion", 28, 0, 29)); //24 - ITEMS.add(new Item("Mushroom", 30, 0, 31)); + ITEMS.add(new Item("Rose", 29, 0, 30)); //25 - ITEMS.add(new Item("Mushroom", 31, 0, 32)); + ITEMS.add(new Item("Mushroom", 30, 0, 31)); //26 - ITEMS.add(new Item("White Wool", 32, 0, 33)); + ITEMS.add(new Item("Mushroom", 31, 0, 32)); //27 - ITEMS.add(new Item("Orange Wool", 33, 0, 34)); + ITEMS.add(new Item("White Wool", 32, 0, 33)); //28 - ITEMS.add(new Item("Magenta Wool", 34, 0, 35)); + ITEMS.add(new Item("Orange Wool", 33, 0, 34)); //29 - ITEMS.add(new Item("Light Blue Wool", 35, 0, 36)); + ITEMS.add(new Item("Magenta Wool", 34, 0, 35)); //30 - ITEMS.add(new Item("Yellow Wool", 36, 0, 37)); + ITEMS.add(new Item("Light Blue Wool", 35, 0, 36)); //31 - ITEMS.add(new Item("Lime Wool", 37, 0, 38)); + ITEMS.add(new Item("Yellow Wool", 36, 0, 37)); //32 - ITEMS.add(new Item("Pink Wool", 38, 0, 39)); + ITEMS.add(new Item("Lime Wool", 37, 0, 38)); //33 - ITEMS.add(new Item("Gray Wool", 39, 0, 40)); + ITEMS.add(new Item("Pink Wool", 38, 0, 39)); //34 - ITEMS.add(new Item("Light Gray Wool", 40, 0, 41)); + ITEMS.add(new Item("Gray Wool", 39, 0, 40)); //35 - ITEMS.add(new Item("Cyan Wool", 41, 0, 42)); + ITEMS.add(new Item("Light Gray Wool", 40, 0, 41)); //36 - ITEMS.add(new Item("Purple Wool", 42, 0, 43)); + ITEMS.add(new Item("Cyan Wool", 41, 0, 42)); //37 - ITEMS.add(new Item("Blue Wool", 43, 0, 44)); + ITEMS.add(new Item("Purple Wool", 42, 0, 43)); //38 - ITEMS.add(new Item("Brown Wool", 44, 0, 45)); + ITEMS.add(new Item("Blue Wool", 43, 0, 44)); //39 - ITEMS.add(new Item("Green Wool", 45, 0, 46)); + ITEMS.add(new Item("Brown Wool", 44, 0, 45)); //40 - ITEMS.add(new Item("Red Wool", 46, 0, 47)); + ITEMS.add(new Item("Green Wool", 45, 0, 46)); //41 - ITEMS.add(new Item("Black Wool", 47, 0, 48)); + ITEMS.add(new Item("Red Wool", 46, 0, 47)); //42 - ITEMS.add(new Item("Golden Block", 48, 0, 49)); + ITEMS.add(new Item("Black Wool", 47, 0, 48)); //43 - ITEMS.add(new Item("Iron Block", 49, 0, 50)); + ITEMS.add(new Item("Golden Block", 48, 0, 49)); //44 - ITEMS.add(new Item("Stone Slab", 50, 0, 51)); + ITEMS.add(new Item("Iron Block", 49, 0, 50)); //45 - ITEMS.add(new Item("Sandstone Slab", 52, 0, 53)); + ITEMS.add(new Item("Stone Slab", 50, 0, 51)); //46 - ITEMS.add(new Item("Wooden Slab", 53, 0, 54)); + ITEMS.add(new Item("Sandstone Slab", 52, 0, 53)); //47 - ITEMS.add(new Item("Cobblestone Slab", 54, 0, 55)); + ITEMS.add(new Item("Wooden Slab", 53, 0, 54)); //48 - ITEMS.add(new Item("Brick Slab", 55, 0, 56)); + ITEMS.add(new Item("Cobblestone Slab", 54, 0, 55)); //49 - ITEMS.add(new Item("Stone Brick", 64, 0, 57)); + ITEMS.add(new Item("Brick Slab", 55, 0, 56)); //50 - ITEMS.add(new Item("Stone Brick Slab", 56, 0, 58)); + ITEMS.add(new Item("Stone Brick", 64, 0, 57)); //51 - ITEMS.add(new Item("Cactus", 57, 0, 59)); + ITEMS.add(new Item("Stone Brick Slab", 56, 0, 58)); //52 + ITEMS.add(new Item("Cactus", 57, 0, 59)); + //53 ITEMS.add(new Item("Obsidian", 65, 0, 68)); + //54 + ITEMS.add(new Item("Wooden Sword", 0, 1)); + //55 + ITEMS.add(new Item("Stone Sword", 1, 1)); + //56 + ITEMS.add(new Item("Iron Sword", 2, 1)); + //57 + ITEMS.add(new Item("Diamond Sword", 3, 1)); + //58 + ITEMS.add(new Item("Golden Sword", 4, 1)); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java index 5e6fdeb..bc2ed8f 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java @@ -2,10 +2,15 @@ package ru.deadsoftware.cavecraft.game.objects; public class Item { - private int texture, type; + private int texture; + private int type; // 0 - block, 1 - tool, 2 - other private int block; private String name; + public Item(String name, int texture, int type) { + this(name, texture, type, -1); + } + public Item(String name, int texture, int type, int block) { this.name = name; this.texture = texture; diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java index 9e2f3dd..2d5ffe8 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java @@ -24,15 +24,6 @@ public class Player implements Serializable { height = 30; texWidth = 8; inventory = new int[9]; - inventory[0] = 1; - inventory[1] = 2; - inventory[2] = 3; - inventory[3] = 4; - inventory[4] = 5; - inventory[5] = 6; - inventory[6] = 7; - inventory[7] = 8; - inventory[8] = 9; } public Rectangle getRect() { diff --git a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java index 15031d0..14575a3 100644 --- a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java @@ -11,6 +11,7 @@ import ru.deadsoftware.cavecraft.CaveGame; public class Assets { public static final int BLOCK_TEXTURES = 66; + public static final int ITEM_TEXTURES = 5; private static GlyphLayout layout; @@ -30,7 +31,10 @@ public class Assets { public static Sprite shade; public static Texture terrain; - public static TextureRegion[] blockTextures = new TextureRegion[BLOCK_TEXTURES]; + public static Sprite[] blockTextures = new Sprite[BLOCK_TEXTURES]; + + public static Texture items; + public static Sprite[] itemTextures = new Sprite[ITEM_TEXTURES]; public static Texture gui; public static TextureRegion invBar; @@ -138,10 +142,21 @@ public class Assets { terrain = new Texture(Gdx.files.internal("terrain.png")); for (int i=0; i Date: Fri, 28 Sep 2018 18:49:59 +0700 Subject: [PATCH 11/16] Add drop and block breaking --- android/assets/break.png | Bin 0 -> 750 bytes android/assets/items.png | Bin 1349 -> 1704 bytes .../cavecraft/game/GameInput.java | 8 +- .../cavecraft/game/GamePhysics.java | 12 ++ .../deadsoftware/cavecraft/game/GameProc.java | 33 ++-- .../cavecraft/game/GameRenderer.java | 24 ++- .../ru/deadsoftware/cavecraft/game/Items.java | 146 ++++++++++-------- .../cavecraft/game/objects/Block.java | 22 ++- .../cavecraft/game/objects/Drop.java | 35 +++++ .../deadsoftware/cavecraft/misc/Assets.java | 10 +- 10 files changed, 196 insertions(+), 94 deletions(-) create mode 100644 android/assets/break.png create mode 100644 core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java diff --git a/android/assets/break.png b/android/assets/break.png new file mode 100644 index 0000000000000000000000000000000000000000..1af7a40c7ea69785f8788432f16aae5d78d44e06 GIT binary patch literal 750 zcmV000mO1^@s6kp*;E00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY4yFJA4yFNz+^KH>000McNliru;t384As=>^n5zH)02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00LG?L_t(&-tC$}j>8}fMV%A_$&W65I~f}PHkc7l{e5v#5#mcwz%@w}Y2TxTNKIdF14Qf2M*Y3SMPq`j`n>G48qtUM8W3h~j zcuQ2|{d;)t_sNz=7tZt4EYoz1(ap;UXXUqdN~fb*h-|eKaklu9)p*S@EZ=_xkBESX zMes#)bPM0wB%}ONYh8XLiXF#M5D`cSTl?4Hf{`q4C_6Vd5S5);x{!tvZ>9=VRe~ zFQ8cY);KME&bh80A#5#2{D;QpNz;*|^ThR@r9aLiqN>SKN~>HCtxk8w%Y%fMPbsZk z4LHNWV?=cKgt&+23qAvH4FnobP9ZfI*V>~z*YsEUsZYUP=kqR{7PYCO?=4=!JpEO<0zx$Bh8M=O1+IGOHbB_%1b5O(KTM%2wwjFGr~lXyk$4S%i?k`BA-O= gGLjLrsP5sv0Q(wyftb6Bc>n+a07*qoM6N<$g1LEQ-~a#s literal 0 HcmV?d00001 diff --git a/android/assets/items.png b/android/assets/items.png index cecb5e8cc63369f91734298023b6aa0a34898973..d4ca336da12bf638f97aee84ed09210ef7adac54 100644 GIT binary patch delta 1406 zcmV-^1%dj-3aAZ`RDTK^Cwn~pOaK4|HAzH4RCwC$*k5ebcNGBea~XzufyFkKV!E}R z!ng#p(GaU9x2y~0;rcR(Cd>z;K9D6!NR08%gE8^J#i|bmk%wxWuS+mwPdorRfn-r6 z&Siw+mIdp0pv>0Ds1S5tAC`Ol^=8of`xb?!pU=~MIq9$8e1FgRo^vXZ;p1CBkea`L zcj51qvhj^ZqZNPb*s;>_z+O4YBj_?yNu9Xf)EEJ$qtoY%D8&e0)3|KYlz89Xga1|KJlNY4eev#>3zLMppdj z=%)0m7k0#te}D2(w})kKbx!inUAq))51{Bv`2(cRsho%|OsUW_eUwqz&&jo1GY zU7H58lmD;NH{;=fH99Aq)5<9T?aBYbnVC|TxIOug9z9y>61OM+?%lgfUE=oSf9k$-Z|FCya9sZ$XVDd+qmBHn)K zj}Z|m=lmifUis5}eD^z%6oF+@03`q2N&dNOw_^V0JJJ8aHSvec&S`#rKKlFnvpc6N zSFXg)ojbETr+;0YjdhSJ#wVyR;{NwOU*Dfzp*ACPtTk=8}tHnc89M4Z3$b|okI>-Bnyh&XfROeH7zYqeU6h?tt1 zs^lbp*XE%V5pm4Dua9nh_xn#@sNAjOZ=J(PZ~Ab5HL7b?&q&ljgj8;#<#y0t9yI0ihpQhq&IzS;uF!`{lJpWk^gZA@X&^? zRw2lF`3D9DT7@9z<=?eySE~@@y!`8Teymjpa$f$iCwp6k;BF@W*l(&590Q>|7@ zDWxJ!WTTV|sde!D6tJ_!s|NjROY`#QF2*<=GvOB-1Db9A;Kum{@r8s>i?#gk#=o;5zL4-~v6ep~Vpy>I`oi!3 zZ^C!f#xC{puk?8CgPA`kzBu#e#207&ocQ9*pY{EPnSZHg*%;|v(%ie!(n&-?RCwC$+23oGbsPuq&yk{8PMok|pxeS< zXBf7S=FOQ-HZOK%Qn0$S3$K#hRsVrxS8*~gW~8@*B3|u6C2NBy5kwNVv{=il30t(R ziO{zTdDhuDan5;!!0q+AIydigo{Q)GJbLcCQtbfmD*z8Yc08caBy%i z9X@Z~0S7X<}j`rIb?T7*KEd z_dK|sc71z3?RjuLRgMAmmVah;DBZaEW}2BDN|j>(D1X25gYqjsJcD+1u1mW**QLDW zFO^EER4S#sX8SS+Sfr%t76 zJAryMZSPF&pL~?6?F8z&{@$+i#g_+DwVeR0G)w;3276jl$ELM0c560vZ*7j*`Nwg8 zW+597YRd9I%(h2&cX!Or&c^igbc~OWHZU=6W_B)PMbRFU67fHpkS|qqz3fgKRv2mAeBN>}gGXuWyVqqxWNC`e7j= zQpA(RU__)^hrrVO^kP0+4AwdXmgmdma*BAe7>tNi>kz2SFHAoy%$z=#BAzS;BO=v0 z1pe##`wp~5L?nj*EAjxy9`idkt*tD7<$u3^s`bbp5z(=6dPzPje62Acd(7|H^yiX% zMd4GeNB$@IznA1I3ZH5{@<&8;v^-pT{r?u;7{Kb7`Sau}XZ}3-%9%e;zH;Wzb^R4H zzq^6eW=%xIt)J$f>Pv3ky!ll5a=H9e`I*z_o+^L#%zbwP0000000000000000F%B2 h(v!di4;b*j`v<_E=lC%ShnN5W002ovPDHLkV1j* 0) { - gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY, 0); - } else if (gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY) > 0) { - gameProc.world.placeToBackground(gameProc.cursorX, gameProc.cursorY, 0); - } - + gameProc.blockDmg = 0; } } gameProc.isTouchDown = false; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index fdf1206..c387bab 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.game.mobs.Mob; +import ru.deadsoftware.cavecraft.game.objects.Drop; import ru.deadsoftware.cavecraft.game.objects.Player; import java.util.Iterator; @@ -67,6 +68,16 @@ public class GamePhysics { return gameProc.world.getForeMap((int)(rect.x+rect.width/2)/16, (int)(rect.y+rect.height/8*7)/16); } + private void dropPhy(Drop drop) { + if (drop.move.y < 9) drop.move.y += gravity.y/4; + drop.position.add(drop.move); + drop.position.y = MathUtils.round(drop.position.y); + while (checkColl(drop.getRect())) { + drop.position.y--; + drop.move.y = 0; + } + } + private void playerPhy(Player pl) { pl.position.add(pl.moveY); if (checkColl(pl.getRect())) { @@ -170,6 +181,7 @@ public class GamePhysics { } public void update(float delta) { + for (Drop drop : gameProc.drops) dropPhy(drop); for (Mob mob : gameProc.mobs) { mob.ai(); mobPhy(mob); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index ddeac68..25658c1 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -9,6 +9,7 @@ import ru.deadsoftware.cavecraft.game.mobs.FallingGravel; import ru.deadsoftware.cavecraft.game.mobs.FallingSand; import ru.deadsoftware.cavecraft.game.mobs.Mob; import ru.deadsoftware.cavecraft.game.mobs.Pig; +import ru.deadsoftware.cavecraft.game.objects.Drop; import ru.deadsoftware.cavecraft.game.objects.Player; import ru.deadsoftware.cavecraft.misc.AppState; import ru.deadsoftware.cavecraft.misc.Assets; @@ -22,11 +23,11 @@ public class GameProc implements Serializable{ public static boolean DO_UPD = false; public static int UPD_X = -1, UPD_Y = -1; - public static int FUPD_X, FUPD_Y; public Player player; public ArrayList mobs; + public ArrayList drops; public transient GameWorld world; public transient GameRenderer renderer; @@ -36,6 +37,7 @@ public class GameProc implements Serializable{ public int invSlot; public int ctrlMode; public int creativeScroll, maxCreativeScroll; + public int blockDmg = 0; public boolean isTouchDown, isKeyDown, swim; public int touchDownX, touchDownY, keyDownCode; @@ -46,6 +48,7 @@ public class GameProc implements Serializable{ world = new GameWorld(); world.generate(1024,256); player = new Player(world.getSpawnPoint()); + drops = new ArrayList(); mobs = new ArrayList(); for (int i=0; i<16; i++) { mobs.add(new Pig(i*256, 196*16)); @@ -79,6 +82,7 @@ public class GameProc implements Serializable{ } private void moveCursor() { + int pastX = cursorX, pastY = cursorY; if (ctrlMode == 0 && CaveGame.TOUCH) { cursorX = (int) (player.position.x + player.texWidth / 2) / 16; if (player.dir == 0) cursorX--; @@ -103,6 +107,7 @@ public class GameProc implements Serializable{ (renderer.camera.viewportWidth/GameScreen.getWidth())+renderer.camera.position.x)<0) cursorX--; } + if (pastX!=cursorX || pastY!=cursorY) blockDmg = 0; } private void checkCursorBounds() { @@ -397,29 +402,33 @@ public class GameProc implements Serializable{ } } - updateFluids(FUPD_X, FUPD_Y); - FUPD_X++; - if (FUPD_X>=(int)(renderer.camera.position.x+renderer.camera.viewportWidth)/16+1) { - FUPD_X = (int) renderer.camera.position.x / 16 - 1; - FUPD_Y++; - if (FUPD_Y>=(int)(renderer.camera.position.y+renderer.camera.viewportHeight)/16+1) { - FUPD_Y = (int) renderer.camera.position.y / 16 - 1; - } - } - physics.update(delta); moveCursor(); checkCursorBounds(); + if (isTouchDown && touchDownButton==Input.Buttons.LEFT) { + if (world.getForeMap(cursorX, cursorY) > 0 && + Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()>=0){// || world.getBackMap(cursorX, cursorY) > 0) { + blockDmg++; + if (blockDmg>=Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()) { + if (Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop()>0) + drops.add(new Drop(cursorX*16+4, cursorY*16+4, Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop())); + world.placeToForeground(cursorX, cursorY, 0); + blockDmg=0; + } + } + } + if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) { if (touchDownButton== Input.Buttons.RIGHT) { useItem(cursorX, cursorY, player.inventory[invSlot], true); + isTouchDown = false; } else if (touchDownY< Assets.invBar.getRegionHeight() && touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 && touchDownX 0) { + spriteBatch.draw(Assets.wreck[ + 10*gameProc.blockDmg/ + Items.BLOCKS.getValueAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)).getHp()], + gameProc.cursorX*16-camera.position.x, + gameProc.cursorY*16-camera.position.y); + } if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)>0 || gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY)>0 || gameProc.ctrlMode==1 || @@ -224,6 +244,7 @@ public class GameRenderer extends Renderer { drawWorldBackground(); drawPlayer(gameProc.player); for (Mob mob : gameProc.mobs) drawMob(mob); + for (Drop drop : gameProc.drops) drawDrop(drop); drawWorldForeground(); drawGUI(); } @@ -250,7 +271,8 @@ public class GameRenderer extends Renderer { drawString("X: "+(int)(gameProc.player.position.x/16),0, 10); drawString("Y: "+(int)(gameProc.player.position.y/16),0, 20); drawString("Mobs: "+gameProc.mobs.size(), 0, 30); - drawString("Block: "+Items.BLOCKS.getKeyAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)), 0, 40); + drawString("Drops: "+gameProc.drops.size(), 0, 40); + drawString("Block: "+Items.BLOCKS.getKeyAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)), 0, 50); } spriteBatch.end(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index db32ad1..690d5ac 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -146,6 +146,16 @@ public class Items { ITEMS.add(new Item("Diamond Sword", 3, 1)); //58 ITEMS.add(new Item("Golden Sword", 4, 1)); + //59 + ITEMS.add(new Item("Wooden Shovel", 5, 1)); + //60 + ITEMS.add(new Item("Stone Shovel", 6, 1)); + //61 + ITEMS.add(new Item("Iron Shovel", 7, 1)); + //62 + ITEMS.add(new Item("Diamond Shovel", 8, 1)); + //63 + ITEMS.add(new Item("Golden Shovel", 9, 1)); } @@ -153,141 +163,141 @@ public class Items { //0 BLOCKS.put("none", null); //1 - BLOCKS.put("stone", new Block(0)); + BLOCKS.put("stone", new Block(0, 450, 4)); //2 - BLOCKS.put("grass", new Block(1)); + BLOCKS.put("grass", new Block(1, 54, 3)); //3 - BLOCKS.put("dirt", new Block(2)); + BLOCKS.put("dirt", new Block(2, 45, 3)); //4 - BLOCKS.put("cobblestone", new Block(3)); + BLOCKS.put("cobblestone", new Block(3, 600, 4)); //5 - BLOCKS.put("planks", new Block(4)); + BLOCKS.put("planks", new Block(4, 180, 5)); //6 - BLOCKS.put("sapling", new Block(5,false,false,true)); + BLOCKS.put("sapling", new Block(5,0,6,false,false,true)); //7 - BLOCKS.put("bedrock", new Block(6)); + BLOCKS.put("bedrock", new Block(6,-1,7)); //8 - BLOCKS.put("water", new Block(7,false,false,true)); + BLOCKS.put("water", new Block(7,-1,0,false,false,true)); //9 - BLOCKS.put("lava", new Block(8,false,false,false)); + BLOCKS.put("lava", new Block(8,-1,0,false,false,false)); //10 - BLOCKS.put("sand", new Block(9)); + BLOCKS.put("sand", new Block(9, 45,8)); //11 - BLOCKS.put("gravel", new Block(10)); + BLOCKS.put("gravel", new Block(10, 54,9)); //12 - BLOCKS.put("gold_ore", new Block(11)); + BLOCKS.put("gold_ore", new Block(11, 900,10)); //13 - BLOCKS.put("iron_ore", new Block(12)); + BLOCKS.put("iron_ore", new Block(12, 900,11)); //14 - BLOCKS.put("coal_ore", new Block(13)); + BLOCKS.put("coal_ore", new Block(13, 900,0)); //15 - BLOCKS.put("log", new Block(14)); + BLOCKS.put("log", new Block(14, 180,13)); //16 - BLOCKS.put("leaves", new Block(15)); + BLOCKS.put("leaves", new Block(15, 21,0)); //17 - BLOCKS.put("sponge", new Block(16)); + BLOCKS.put("sponge", new Block(16, 54,0)); //18 - BLOCKS.put("glass", new Block(17,true,false,true)); + BLOCKS.put("glass", new Block(17, 27,0,true,false,true)); //19 - BLOCKS.put("lapis_ore", new Block(18)); + BLOCKS.put("lapis_ore", new Block(18, 900,0)); //20 - BLOCKS.put("lapis_block", new Block(19)); + BLOCKS.put("lapis_block", new Block(19, 900,17)); //21 - BLOCKS.put("sandstone", new Block(20)); + BLOCKS.put("sandstone", new Block(20, 240,18)); //22 - BLOCKS.put("noteblock", new Block(21)); + BLOCKS.put("noteblock", new Block(21, 75,0)); //23 - BLOCKS.put("bed_l", new Block(22,false,true,true)); + BLOCKS.put("bed_l", new Block(22, 21,0,false,true,true)); //24 - BLOCKS.put("bed_r", new Block(23, false,true, true)); + BLOCKS.put("bed_r", new Block(23, 21,0, false,true, true)); //25 - BLOCKS.put("cobweb", new Block(24,false,false,true)); + BLOCKS.put("cobweb", new Block(24, 1200,0,false,false,true)); //26 - BLOCKS.put("tallgrass", new Block(25,false,false,true)); + BLOCKS.put("tallgrass", new Block(25, 0,0,false,false,true)); //27 - BLOCKS.put("deadbush", new Block(26,false,false,true)); + BLOCKS.put("deadbush", new Block(26, 0,0,false,false,true)); //28 - BLOCKS.put("brick_block", new Block(27)); + BLOCKS.put("brick_block", new Block(27, 600,22)); //29 - BLOCKS.put("dandelion", new Block(28,false,false,true)); + BLOCKS.put("dandelion", new Block(28, 0,23,false,false,true)); //30 - BLOCKS.put("rose", new Block(29,false,false,true)); + BLOCKS.put("rose", new Block(29, 0,24,false,false,true)); //31 - BLOCKS.put("brown_mushroom", new Block(30,false,false,true)); + BLOCKS.put("brown_mushroom", new Block(30, 0,25,false,false,true)); //32 - BLOCKS.put("red_mushroom", new Block(31,false,false,true)); + BLOCKS.put("red_mushroom", new Block(31, 0,26,false,false,true)); //33 - BLOCKS.put("wool_while", new Block(32,true,false,false)); + BLOCKS.put("wool_while", new Block(32, 75,27,true,false,false)); //34 - BLOCKS.put("wool_orange", new Block(33,true,false,false)); + BLOCKS.put("wool_orange", new Block(33, 75,28,true,false,false)); //35 - BLOCKS.put("wool_magenta", new Block(34,true,false,false)); + BLOCKS.put("wool_magenta", new Block(34, 75,29,true,false,false)); //36 - BLOCKS.put("wool_lightblue", new Block(35,true,false,false)); + BLOCKS.put("wool_lightblue", new Block(35, 75,30,true,false,false)); //37 - BLOCKS.put("wool_yellow", new Block(36,true,false,false)); + BLOCKS.put("wool_yellow", new Block(36, 75,31,true,false,false)); //38 - BLOCKS.put("wool_lime", new Block(37,true,false,false)); + BLOCKS.put("wool_lime", new Block(37, 75,32,true,false,false)); //39 - BLOCKS.put("wool_pink", new Block(38,true,false,false)); + BLOCKS.put("wool_pink", new Block(38, 75,33,true,false,false)); //40 - BLOCKS.put("wool_gray", new Block(39,true,false,false)); + BLOCKS.put("wool_gray", new Block(39, 75,34,true,false,false)); //41 - BLOCKS.put("wool_lightgray", new Block(40,true,false,false)); + BLOCKS.put("wool_lightgray", new Block(40, 75,35,true,false,false)); //42 - BLOCKS.put("wool_cyan", new Block(41,true,false,false)); + BLOCKS.put("wool_cyan", new Block(41, 75,36,true,false,false)); //43 - BLOCKS.put("wool_purple", new Block(42,true,false,false)); + BLOCKS.put("wool_purple", new Block(42, 75,37,true,false,false)); //44 - BLOCKS.put("wool_blue", new Block(43,true,false,false)); + BLOCKS.put("wool_blue", new Block(43, 75,38,true,false,false)); //45 - BLOCKS.put("wool_brown", new Block(44,true,false,false)); + BLOCKS.put("wool_brown", new Block(44, 75,39,true,false,false)); //46 - BLOCKS.put("wool_green", new Block(45,true,false,false)); + BLOCKS.put("wool_green", new Block(45, 75,40,true,false,false)); //47 - BLOCKS.put("wool_red", new Block(46,true,false,false)); + BLOCKS.put("wool_red", new Block(46, 75,41,true,false,false)); //48 - BLOCKS.put("wool_black", new Block(47,true,false,false)); + BLOCKS.put("wool_black", new Block(47, 75,42,true,false,false)); //49 - BLOCKS.put("gold_block", new Block(48)); + BLOCKS.put("gold_block", new Block(48, 900,43)); //50 - BLOCKS.put("iron_block", new Block(49)); + BLOCKS.put("iron_block", new Block(49, 1500,44)); //51 - BLOCKS.put("stone_slab", new Block(0, 8, 16,8, 50, true, false, true)); + BLOCKS.put("stone_slab", new Block(0, 8, 16,8, 50, 600,45, true, false, true)); //52 - BLOCKS.put("double_stone_slab", new Block(51)); + BLOCKS.put("double_stone_slab", new Block(51, 600,45)); //53 - BLOCKS.put("sandstone_slab", new Block(0, 8, 16,8, 52, true, false, true)); + BLOCKS.put("sandstone_slab", new Block(0, 8, 16,8, 52, 600,46, true, false, true)); //54 - BLOCKS.put("wooden_slab", new Block(0, 8, 16,8, 53, true, false, true)); + BLOCKS.put("wooden_slab", new Block(0, 8, 16,8, 53, 180,47, true, false, true)); //55 - BLOCKS.put("cobblestone_slab", new Block(0, 8, 16,8, 54, true, false, true)); + BLOCKS.put("cobblestone_slab", new Block(0, 8, 16,8, 54, 600,48, true, false, true)); //56 - BLOCKS.put("brick_slab", new Block(0, 8, 16,8, 55, true, false, true)); + BLOCKS.put("brick_slab", new Block(0, 8, 16,8, 55, 600,49, true, false, true)); //57 - BLOCKS.put("stonebrick", new Block(64)); + BLOCKS.put("stonebrick", new Block(64, 450,50)); //58 - BLOCKS.put("stone_brick_slab", new Block(0, 8, 16,8, 56, true, false, true)); + BLOCKS.put("stone_brick_slab", new Block(0, 8, 16,8, 56, 450,51, true, false, true)); //59 - BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, true, false, true)); + BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, 39,52, true, false, true)); //60 - BLOCKS.put("water_16", new Block(7,false,false,true)); + BLOCKS.put("water_16", new Block(7, -1,0,false,false,true)); //61 - BLOCKS.put("water_12", new Block(58,false,false,true)); + BLOCKS.put("water_12", new Block(58, -1,0,false,false,true)); //62 - BLOCKS.put("water_8", new Block(59,false,false,true)); + BLOCKS.put("water_8", new Block(59, -1,0,false,false,true)); //63 - BLOCKS.put("water_4", new Block(60,false,false,true)); + BLOCKS.put("water_4", new Block(60, -1,0,false,false,true)); //64 - BLOCKS.put("lava_16", new Block(8,false,false,true)); + BLOCKS.put("lava_16", new Block(8, -1,0,false,false,true)); //65 - BLOCKS.put("lava_12", new Block(61,false,false,true)); + BLOCKS.put("lava_12", new Block(61, -1,0,false,false,true)); //66 - BLOCKS.put("lava_8", new Block(62,false,false,true)); + BLOCKS.put("lava_8", new Block(62, -1,0,false,false,true)); //67 - BLOCKS.put("lava_4", new Block(63,false,false,true)); + BLOCKS.put("lava_4", new Block(63, -1,0,false,false,true)); //68 - BLOCKS.put("obsidian", new Block(65)); + BLOCKS.put("obsidian", new Block(65, 1500,53)); } public static void load() { diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java index 44619f0..5d2814e 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java @@ -1,29 +1,31 @@ package ru.deadsoftware.cavecraft.game.objects; -import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Rectangle; public class Block { private int x,y,w,h; private int texture; + private int hp, drop; public boolean collision, background, transparent; - public Block(int texture) { - this(0,0,16,16,texture, true, false, false); + public Block(int texture, int hp, int drop) { + this(0,0,16,16,texture, hp, drop, true, false, false); } - public Block(int texture, boolean collision, boolean background, boolean transparent) { - this(0,0,16,16,texture, collision, background, transparent); + public Block(int texture, int hp, int drop, boolean collision, boolean background, boolean transparent) { + this(0,0,16,16,texture, hp, drop, collision, background, transparent); } - public Block(int x, int y, int w, int h, int texture, boolean collision, boolean background, boolean transparent) { + public Block(int x, int y, int w, int h, int texture, int hp, int drop, boolean collision, boolean background, boolean transparent) { this.x = x; this.y = y; this.w = w; this.h = h; this.texture = texture; + this.hp = hp; + this.drop = drop; this.collision = collision; this.background = background; this.transparent = transparent; @@ -33,6 +35,14 @@ public class Block { return texture; } + public int getHp() { + return hp; + } + + public int getDrop() { + return drop; + } + public Rectangle getRect(int x, int y) { x*=16; y*=16; diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java new file mode 100644 index 0000000..5ff36e4 --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java @@ -0,0 +1,35 @@ +package ru.deadsoftware.cavecraft.game.objects; + +import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.math.Vector2; + +import java.io.Serializable; + +public class Drop implements Serializable { + private int id; + public Vector2 move, position; + + public static void pickUpDrop(Player pl, int id) { + for (int i = 0; i < pl.inventory.length; i++) { + if (pl.inventory[i] == 0) { + pl.inventory[i] = id; + break; + } + } + } + + public Drop(float x, float y, int id) { + this.id = id; + position = new Vector2(x, y); + move = new Vector2(0, -1); + } + + public int getId() { + return id; + } + + public Rectangle getRect() { + return new Rectangle(position.x, position.y, 8, 8); + } + +} diff --git a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java index 14575a3..e28c322 100644 --- a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java @@ -11,7 +11,7 @@ import ru.deadsoftware.cavecraft.CaveGame; public class Assets { public static final int BLOCK_TEXTURES = 66; - public static final int ITEM_TEXTURES = 5; + public static final int ITEM_TEXTURES = 10; private static GlyphLayout layout; @@ -41,6 +41,9 @@ public class Assets { public static TextureRegion invBarCur; public static TextureRegion guiCur; + public static Texture wreckTexture; + public static TextureRegion[] wreck = new TextureRegion[10]; + public static Texture creativeTexture; public static TextureRegion creativeInv; public static TextureRegion creativeScroll; @@ -124,6 +127,11 @@ public class Assets { creativeScroll = new TextureRegion(creativeTexture, 3, 137, 12, 15); creativeScroll.flip(false, true); + wreckTexture = new Texture(Gdx.files.internal("break.png")); + for (int i=0; i<10; i++) { + wreck[i] = new TextureRegion(wreckTexture, 16*i, 0, 16, 16); + } + if (CaveGame.TOUCH) { touchGui = new Texture(Gdx.files.internal("touch_gui.png")); for (int i = 0; i < 4; i++) { -- 2.29.2 From 3fb849898964a43a51cc6483ac72f5e3abbd01f0 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Fri, 28 Sep 2018 19:10:56 +0700 Subject: [PATCH 12/16] Add drop picking --- .../cavecraft/game/GamePhysics.java | 19 ++++++++++++------- .../cavecraft/game/objects/Drop.java | 18 ++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index c387bab..e38e3b0 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -1,6 +1,5 @@ package ru.deadsoftware.cavecraft.game; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Intersector; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Rectangle; @@ -181,16 +180,22 @@ public class GamePhysics { } public void update(float delta) { - for (Drop drop : gameProc.drops) dropPhy(drop); - for (Mob mob : gameProc.mobs) { - mob.ai(); - mobPhy(mob); + for (Iterator it = gameProc.drops.iterator(); it.hasNext(); ) { + Drop drop = it.next(); + dropPhy(drop); + if (Intersector.overlaps(drop.getRect(), gameProc.player.getRect())) + drop.pickUpDrop(gameProc.player); + if (drop.pickedUp) it.remove(); } + for (Iterator it = gameProc.mobs.iterator(); it.hasNext();) { - Mob m = it.next(); - if (m.dead) + Mob mob = it.next(); + mob.ai(); + mobPhy(mob); + if (mob.dead) it.remove(); } + playerPhy(gameProc.player); gameProc.renderer.camera.position.set( diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java index 5ff36e4..e967f88 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java @@ -7,23 +7,25 @@ import java.io.Serializable; public class Drop implements Serializable { private int id; + public boolean pickedUp = false; public Vector2 move, position; - public static void pickUpDrop(Player pl, int id) { + public Drop(float x, float y, int id) { + this.id = id; + position = new Vector2(x, y); + move = new Vector2(0, -1); + } + + public void pickUpDrop(Player pl) { for (int i = 0; i < pl.inventory.length; i++) { - if (pl.inventory[i] == 0) { + if (pl.inventory[i] == 0 || pl.inventory[i] == id) { pl.inventory[i] = id; + pickedUp = true; break; } } } - public Drop(float x, float y, int id) { - this.id = id; - position = new Vector2(x, y); - move = new Vector2(0, -1); - } - public int getId() { return id; } -- 2.29.2 From bea2a3c5b967bcd90ccd83e08e833d58449e963a Mon Sep 17 00:00:00 2001 From: fred-boy Date: Sun, 30 Sep 2018 14:11:19 +0700 Subject: [PATCH 13/16] Fix code style --- android/build.gradle | 2 +- build.gradle | 2 +- .../ru/deadsoftware/cavecraft/CaveGame.java | 64 +-- .../ru/deadsoftware/cavecraft/GameScreen.java | 14 +- .../cavecraft/game/GameInput.java | 66 +-- .../cavecraft/game/GamePhysics.java | 98 ++-- .../deadsoftware/cavecraft/game/GameProc.java | 444 +++++++++--------- .../cavecraft/game/GameRenderer.java | 176 ++++--- .../cavecraft/game/GameSaver.java | 46 +- .../cavecraft/game/GameWorld.java | 27 +- .../ru/deadsoftware/cavecraft/game/Items.java | 126 ++--- .../deadsoftware/cavecraft/game/WorldGen.java | 112 ++--- .../cavecraft/game/mobs/FallingGravel.java | 4 +- .../cavecraft/game/mobs/FallingSand.java | 3 +- .../deadsoftware/cavecraft/game/mobs/Mob.java | 8 +- .../deadsoftware/cavecraft/game/mobs/Pig.java | 25 +- .../cavecraft/game/objects/Block.java | 14 +- .../cavecraft/game/objects/Item.java | 3 + .../cavecraft/game/objects/Player.java | 2 +- .../cavecraft/menu/MenuRenderer.java | 60 ++- .../deadsoftware/cavecraft/misc/Assets.java | 80 ++-- .../cavecraft/misc/InputHandlerGame.java | 40 +- .../cavecraft/misc/InputHandlerMenu.java | 8 +- .../deadsoftware/cavecraft/misc/Renderer.java | 11 +- 24 files changed, 729 insertions(+), 706 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 23d84e2..e917a5f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -24,7 +24,7 @@ android { minSdkVersion 9 targetSdkVersion 20 versionCode 5 - versionName "alpha0.4-dev" + versionName "alpha0.4" } buildTypes { release { diff --git a/build.gradle b/build.gradle index 76faca8..c413ee9 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ allprojects { apply plugin: "eclipse" apply plugin: "idea" - version = 'alpha0.4-dev' + version = 'alpha0.4' ext { appName = "CaveCraft" gdxVersion = '1.9.7' diff --git a/core/src/ru/deadsoftware/cavecraft/CaveGame.java b/core/src/ru/deadsoftware/cavecraft/CaveGame.java index d95c477..37fd2e1 100644 --- a/core/src/ru/deadsoftware/cavecraft/CaveGame.java +++ b/core/src/ru/deadsoftware/cavecraft/CaveGame.java @@ -6,37 +6,37 @@ import ru.deadsoftware.cavecraft.misc.AppState; public class CaveGame extends Game { - public static final String VERSION = "alpha 0.4-dev"; - public static String GAME_FOLDER; - - public static AppState STATE; - - public static boolean TOUCH; - - public CaveGame() { - this(false); - } - - public CaveGame(boolean touch) { - TOUCH = touch; - STATE = AppState.MENU_MAIN; - } - - @Override - public void create () { - switch (Gdx.app.getType()) { - case Desktop: - GAME_FOLDER = System.getProperty("user.home")+"/.cavecraft"; - break; - case Android: - GAME_FOLDER = "/sdcard/cavecraft"; - break; - default: - Gdx.app.exit(); - } - Gdx.app.log("CaveGame", GAME_FOLDER); - Gdx.files.absolute(GAME_FOLDER).mkdirs(); - setScreen(new GameScreen()); - } + public static final String VERSION = "alpha 0.4"; + public static String GAME_FOLDER; + + public static AppState STATE; + + public static boolean TOUCH; + + public CaveGame() { + this(false); + } + + public CaveGame(boolean touch) { + TOUCH = touch; + STATE = AppState.MENU_MAIN; + } + + @Override + public void create() { + switch (Gdx.app.getType()) { + case Desktop: + GAME_FOLDER = System.getProperty("user.home") + "/.cavecraft"; + break; + case Android: + GAME_FOLDER = "/sdcard/cavecraft"; + break; + default: + Gdx.app.exit(); + } + Gdx.app.log("CaveGame", GAME_FOLDER); + Gdx.files.absolute(GAME_FOLDER).mkdirs(); + setScreen(new GameScreen()); + } } diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java index dc7bb60..2704dbc 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameScreen.java +++ b/core/src/ru/deadsoftware/cavecraft/GameScreen.java @@ -20,7 +20,7 @@ public class GameScreen implements Screen { public GameScreen() { Assets.load(); Items.load(); - menuRenderer = new MenuRenderer(CaveGame.TOUCH?320:480); + menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480); renderer = menuRenderer; Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer)); } @@ -46,9 +46,10 @@ public class GameScreen implements Screen { @Override public void render(float delta) { - FPS = (int)(1/delta); + FPS = (int) (1 / delta); switch (CaveGame.STATE) { - case GAME_PLAY: case GAME_CREATIVE_INV: + case GAME_PLAY: + case GAME_CREATIVE_INV: game(delta); break; @@ -76,7 +77,7 @@ public class GameScreen implements Screen { break; case GOTO_MENU: - menuRenderer = new MenuRenderer(CaveGame.TOUCH?320:480); + menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480); renderer = menuRenderer; Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer)); break; @@ -88,10 +89,11 @@ public class GameScreen implements Screen { public void resize(int width, int height) { switch (CaveGame.STATE) { case MENU_MAIN: - menuRenderer = new MenuRenderer(CaveGame.TOUCH?320:480); + menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480); renderer = menuRenderer; break; - case GAME_PLAY: case GAME_CREATIVE_INV: + case GAME_PLAY: + case GAME_CREATIVE_INV: gameProc.resetRenderer(); renderer = gameProc.renderer; break; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index 0f6c399..63cf93d 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.GameScreen; -import ru.deadsoftware.cavecraft.game.mobs.FallingSand; import ru.deadsoftware.cavecraft.game.mobs.Pig; import ru.deadsoftware.cavecraft.misc.AppState; import ru.deadsoftware.cavecraft.misc.Assets; @@ -18,12 +17,12 @@ public class GameInput { } private boolean checkSwim() { - return (Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16, - (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16))); + return (Items.isFluid(gameProc.world.getForeMap((int) (gameProc.player.position.x + gameProc.player.width / 2) / 16, + (int) (gameProc.player.position.y + gameProc.player.height / 4 * 3) / 16))); } private void wasdPressed(int keycode) { - if (gameProc.ctrlMode==0 || !CaveGame.TOUCH) { + if (gameProc.ctrlMode == 0 || !CaveGame.TOUCH) { switch (keycode) { case Input.Keys.A: gameProc.player.moveX.x = -GamePhysics.PL_SPEED; @@ -36,7 +35,7 @@ public class GameInput { if (CaveGame.TOUCH && checkSwim()) gameProc.swim = true; break; } - } else if (CaveGame.TOUCH){ + } else if (CaveGame.TOUCH) { switch (keycode) { case Input.Keys.A: gameProc.cursorX--; @@ -55,7 +54,7 @@ public class GameInput { } } - public void keyDown(int keycode) { + public void keyDown(int keycode) { gameProc.isKeyDown = true; gameProc.keyDownCode = keycode; if (keycode == Input.Keys.W || keycode == Input.Keys.A || @@ -88,14 +87,15 @@ public class GameInput { case Input.Keys.E: if (CaveGame.STATE == AppState.GAME_PLAY) CaveGame.STATE = AppState.GAME_CREATIVE_INV; - else CaveGame.STATE = AppState.GAME_PLAY; + else CaveGame.STATE = AppState.GAME_PLAY; break; case Input.Keys.G: - gameProc.mobs.add(new Pig(gameProc.cursorX*16, gameProc.cursorY*16)); + gameProc.mobs.add(new Pig(gameProc.cursorX * 16, gameProc.cursorY * 16)); break; - case Input.Keys.ESCAPE: case Input.Keys.BACK: + case Input.Keys.ESCAPE: + case Input.Keys.BACK: CaveGame.STATE = AppState.GOTO_MENU; break; @@ -107,12 +107,14 @@ public class GameInput { public void keyUp(int keycode) { switch (keycode) { - case Input.Keys.A: case Input.Keys.D: + case Input.Keys.A: + case Input.Keys.D: gameProc.player.moveX.x = 0; if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false; break; - case Input.Keys.SPACE: case Input.Keys.CONTROL_LEFT: + case Input.Keys.SPACE: + case Input.Keys.CONTROL_LEFT: if (gameProc.player.flyMode) gameProc.player.moveY.setZero(); if (gameProc.swim) gameProc.swim = false; break; @@ -137,14 +139,14 @@ public class GameInput { } if (gameProc.isTouchDown) { if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && - screenX>gameProc.renderer.camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2 && - screenXgameProc.renderer.camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2 && - screenY gameProc.renderer.camera.viewportWidth / 2 - Assets.creativeInv.getRegionWidth() / 2 && + screenX < gameProc.renderer.camera.viewportWidth / 2 + Assets.creativeInv.getRegionWidth() / 2 && + screenY > gameProc.renderer.camera.viewportHeight / 2 - Assets.creativeInv.getRegionHeight() / 2 && + screenY < gameProc.renderer.camera.viewportHeight / 2 + Assets.creativeInv.getRegionHeight() / 2) { int ix = (int) (screenX - (gameProc.renderer.camera.viewportWidth / 2 - Assets.creativeInv.getRegionWidth() / 2 + 8)) / 18; int iy = (int) (screenY - (gameProc.renderer.camera.viewportHeight / 2 - Assets.creativeInv.getRegionHeight() / 2 + 18)) / 18; - int item = gameProc.creativeScroll*8+(ix + iy * 8); - if (ix>=8 || ix<0 || iy<0 || iy>=5) item=-1; + int item = gameProc.creativeScroll * 8 + (ix + iy * 8); + if (ix >= 8 || ix < 0 || iy < 0 || iy >= 5) item = -1; if (item >= 0 && item < Items.ITEMS.size()) { for (int i = 8; i > 0; i--) { gameProc.player.inventory[i] = gameProc.player.inventory[i - 1]; @@ -153,13 +155,13 @@ public class GameInput { } } else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) { CaveGame.STATE = AppState.GAME_PLAY; - } else if (screenYgameProc.renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 && - screenX gameProc.renderer.camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 && + screenX < gameProc.renderer.camera.viewportWidth / 2 + Assets.invBar.getRegionWidth() / 2) { + gameProc.invSlot = (int) ((screenX - (gameProc.renderer.camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2)) / 20); + } else if (button == Input.Buttons.RIGHT) { gameProc.useItem(gameProc.cursorX, gameProc.cursorY, - gameProc.player.inventory[gameProc.invSlot], false); + gameProc.player.inventory[gameProc.invSlot], false); } else if (button == Input.Buttons.LEFT) { gameProc.blockDmg = 0; } @@ -168,11 +170,11 @@ public class GameInput { } public void touchDragged(int screenX, int screenY) { - if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && Math.abs(screenY-gameProc.touchDownY)>16) { - if (screenX>gameProc.renderer.camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2 && - screenXgameProc.renderer.camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2 && - screenY 16) { + if (screenX > gameProc.renderer.camera.viewportWidth / 2 - Assets.creativeInv.getRegionWidth() / 2 && + screenX < gameProc.renderer.camera.viewportWidth / 2 + Assets.creativeInv.getRegionWidth() / 2 && + screenY > gameProc.renderer.camera.viewportHeight / 2 - Assets.creativeInv.getRegionHeight() / 2 && + screenY < gameProc.renderer.camera.viewportHeight / 2 + Assets.creativeInv.getRegionHeight() / 2) { gameProc.creativeScroll -= (screenY - gameProc.touchDownY) / 16; gameProc.touchDownX = screenX; gameProc.touchDownY = screenY; @@ -191,10 +193,10 @@ public class GameInput { if (gameProc.invSlot > 8) gameProc.invSlot = 0; break; case GAME_CREATIVE_INV: - gameProc.creativeScroll+=amount; - if (gameProc.creativeScroll<0) gameProc.creativeScroll=0; - if (gameProc.creativeScroll>gameProc.maxCreativeScroll) - gameProc.creativeScroll=gameProc.maxCreativeScroll; + gameProc.creativeScroll += amount; + if (gameProc.creativeScroll < 0) gameProc.creativeScroll = 0; + if (gameProc.creativeScroll > gameProc.maxCreativeScroll) + gameProc.creativeScroll = gameProc.maxCreativeScroll; break; } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index e38e3b0..66f4236 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -21,40 +21,40 @@ public class GamePhysics { public GamePhysics(GameProc gameProc) { this.gameProc = gameProc; - gravity = new Vector2(0,.9f); + gravity = new Vector2(0, .9f); } private boolean checkJump(Rectangle rect, int dir) { int bl; switch (dir) { case 0: - bl = gameProc.world.getForeMap((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16)); - if (checkColl(new Rectangle(rect.x-8, rect.y-18, rect.width, rect.height))) bl=0; + bl = gameProc.world.getForeMap((int) ((rect.x - 8) / 16), (int) ((rect.y + rect.height - 8) / 16)); + if (checkColl(new Rectangle(rect.x - 8, rect.y - 18, rect.width, rect.height))) bl = 0; break; case 1: - bl = gameProc.world.getForeMap((int)((rect.x+rect.width+8)/16),(int)((rect.y+rect.height-8)/16)); - if (checkColl(new Rectangle(rect.x+rect.width+8, rect.y-18, rect.width, rect.height))) bl=0; + bl = gameProc.world.getForeMap((int) ((rect.x + rect.width + 8) / 16), (int) ((rect.y + rect.height - 8) / 16)); + if (checkColl(new Rectangle(rect.x + rect.width + 8, rect.y - 18, rect.width, rect.height))) bl = 0; break; default: - bl=0; + bl = 0; } - return (bl>0 && Items.BLOCKS.getValueAt(bl).toJump() && - (rect.y+rect.height)-Items.BLOCKS.getValueAt(bl).getRect((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16)).y>8); + return (bl > 0 && Items.BLOCKS.getValueAt(bl).toJump() && + (rect.y + rect.height) - Items.BLOCKS.getValueAt(bl).getRect((int) ((rect.x - 8) / 16), (int) ((rect.y + rect.height - 8) / 16)).y > 8); } private boolean checkColl(Rectangle rect) { int bl; - int minX = (int) ((rect.x+rect.width/2)/16)-4; - int minY = (int) ((rect.y+rect.height/2)/16)-4; - 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>gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); - for (int y=minY; y0 && Items.BLOCKS.getValueAt(bl).collision){ - if (Intersector.overlaps(rect, Items.BLOCKS.getValueAt(bl).getRect(x,y))){ + int minX = (int) ((rect.x + rect.width / 2) / 16) - 4; + int minY = (int) ((rect.y + rect.height / 2) / 16) - 4; + 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 > gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); + for (int y = minY; y < maxY; y++) { + for (int x = minX; x < maxX; x++) { + bl = gameProc.world.getForeMap(x, y); + if (bl > 0 && Items.BLOCKS.getValueAt(bl).collision) { + if (Intersector.overlaps(rect, Items.BLOCKS.getValueAt(bl).getRect(x, y))) { return true; } } @@ -64,11 +64,11 @@ public class GamePhysics { } private int getBlock(Rectangle rect) { - return gameProc.world.getForeMap((int)(rect.x+rect.width/2)/16, (int)(rect.y+rect.height/8*7)/16); + return gameProc.world.getForeMap((int) (rect.x + rect.width / 2) / 16, (int) (rect.y + rect.height / 8 * 7) / 16); } private void dropPhy(Drop drop) { - if (drop.move.y < 9) drop.move.y += gravity.y/4; + if (drop.move.y < 9) drop.move.y += gravity.y / 4; drop.position.add(drop.move); drop.position.y = MathUtils.round(drop.position.y); while (checkColl(drop.getRect())) { @@ -81,36 +81,36 @@ public class GamePhysics { pl.position.add(pl.moveY); if (checkColl(pl.getRect())) { int d = -1; - if (pl.moveY.y<0) d=1; - if (d==-1) { + if (pl.moveY.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; + while (checkColl(pl.getRect())) pl.position.y += d; pl.moveY.setZero(); } 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.moveX.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); } else { pl.moveY.add(0, -.5f); - if (pl.moveY.y<-3) pl.moveY.y = -3; + if (pl.moveY.y < -3) pl.moveY.y = -3; } } else { - if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity); + if (!pl.flyMode && pl.moveY.y < 18) pl.moveY.add(gravity); } pl.position.add(pl.moveX); if (checkColl(pl.getRect())) { - if (pl.canJump && !pl.flyMode) pl.position.y-=8; + if (pl.canJump && !pl.flyMode) pl.position.y -= 8; if (checkColl(pl.getRect())) { - if (pl.canJump && !pl.flyMode) pl.position.y+=8; + 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; @@ -118,9 +118,10 @@ public class GamePhysics { while (checkColl(pl.getRect())) pl.position.x += d; } } - if (pl.position.x+pl.texWidth/2<0) pl.position.x+=gameProc.world.getWidth()*16; - if (pl.position.x+pl.texWidth/2>gameProc.world.getWidth()*16) pl.position.x-=gameProc.world.getWidth()*16; - if (pl.position.y > gameProc.world.getHeight()*16) { + if (pl.position.x + pl.texWidth / 2 < 0) pl.position.x += gameProc.world.getWidth() * 16; + if (pl.position.x + pl.texWidth / 2 > gameProc.world.getWidth() * 16) + pl.position.x -= gameProc.world.getWidth() * 16; + 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)) { @@ -133,13 +134,13 @@ public class GamePhysics { mob.position.add(mob.moveY); if (checkColl(mob.getRect())) { int d = -1; - if (mob.moveY.y<0) d=1; - if (d==-1) mob.canJump = true; + if (mob.moveY.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; + while (checkColl(mob.getRect())) mob.position.y += d; mob.moveY.setZero(); if (mob.getType() > 0) { - gameProc.world.setForeMap((int)mob.position.x/16, (int)mob.position.y/16, mob.getType()); + gameProc.world.setForeMap((int) mob.position.x / 16, (int) mob.position.y / 16, mob.getType()); mob.position.y = -1; mob.dead = true; } @@ -147,19 +148,19 @@ public class GamePhysics { mob.canJump = false; } - if (mob.getType()==0 && Items.isFluid(getBlock(mob.getRect()))) { + 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.moveY.y < -3) mob.moveY.y = -3; + } else if (mob.moveY.y < 18) mob.moveY.add(gravity); mob.position.add(mob.moveX); if (checkColl(mob.getRect())) { if (mob.canJump) { - mob.position.y-=8; + mob.position.y -= 8; } if (checkColl(mob.getRect())) { - if (mob.canJump) mob.position.y+=8; + 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; @@ -168,16 +169,17 @@ public class GamePhysics { if (mob.canJump) mob.changeDir(); } } - if (mob.position.x+mob.width/2<0) mob.position.x+=gameProc.world.getWidth()*16; - if (mob.position.x+mob.width/2>gameProc.world.getWidth()*16) mob.position.x-=gameProc.world.getWidth()*16; - if (mob.position.y > gameProc.world.getHeight()*16) { + if (mob.position.x + mob.width / 2 < 0) mob.position.x += gameProc.world.getWidth() * 16; + if (mob.position.x + mob.width / 2 > gameProc.world.getWidth() * 16) + mob.position.x -= gameProc.world.getWidth() * 16; + 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); mob.canJump = false; } -} + } public void update(float delta) { for (Iterator it = gameProc.drops.iterator(); it.hasNext(); ) { @@ -188,7 +190,7 @@ public class GamePhysics { if (drop.pickedUp) it.remove(); } - for (Iterator it = gameProc.mobs.iterator(); it.hasNext();) { + for (Iterator it = gameProc.mobs.iterator(); it.hasNext(); ) { Mob mob = it.next(); mob.ai(); mobPhy(mob); @@ -199,8 +201,8 @@ public class GamePhysics { playerPhy(gameProc.player); gameProc.renderer.camera.position.set( - gameProc.player.position.x+gameProc.player.texWidth/2 - gameProc.renderer.camera.viewportWidth/2, - gameProc.player.position.y+gameProc.player.height/2-gameProc.renderer.camera.viewportHeight/2, + gameProc.player.position.x + gameProc.player.texWidth / 2 - gameProc.renderer.camera.viewportWidth / 2, + gameProc.player.position.y + gameProc.player.height / 2 - gameProc.renderer.camera.viewportHeight / 2, 0 ); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index 25658c1..e4d12b2 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -17,7 +17,7 @@ import ru.deadsoftware.cavecraft.misc.Assets; import java.io.Serializable; import java.util.ArrayList; -public class GameProc implements Serializable{ +public class GameProc implements Serializable { public static double RUN_TIME = 0; @@ -46,39 +46,39 @@ public class GameProc implements Serializable{ public GameProc() { world = new GameWorld(); - world.generate(1024,256); + world.generate(1024, 256); player = new Player(world.getSpawnPoint()); drops = new ArrayList(); mobs = new ArrayList(); - for (int i=0; i<16; i++) { - mobs.add(new Pig(i*256, 196*16)); + for (int i = 0; i < 16; i++) { + mobs.add(new Pig(i * 256, 196 * 16)); } physics = new GamePhysics(this); if (CaveGame.TOUCH) { - renderer = new GameRenderer(this,320, - 320*((float)GameScreen.getHeight()/GameScreen.getWidth())); + renderer = new GameRenderer(this, 320, + 320 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } else { ctrlMode = 1; - renderer = new GameRenderer(this,480, - 480*((float)GameScreen.getHeight()/GameScreen.getWidth())); + renderer = new GameRenderer(this, 480, + 480 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } - maxCreativeScroll = Items.ITEMS.size()/8; + maxCreativeScroll = Items.ITEMS.size() / 8; GameSaver.save(this); } public void resetRenderer() { if (CaveGame.TOUCH) { - renderer = new GameRenderer(this,320, - 320*((float)GameScreen.getHeight()/GameScreen.getWidth())); + renderer = new GameRenderer(this, 320, + 320 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } else { - renderer = new GameRenderer(this,480, - 480*((float)GameScreen.getHeight()/GameScreen.getWidth())); + renderer = new GameRenderer(this, 480, + 480 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } } private boolean isAutoselectable(int x, int y) { - return (world.getForeMap(x,y)>0 && - Items.BLOCKS.getValueAt(world.getForeMap(x,y)).collision); + return (world.getForeMap(x, y) > 0 && + Items.BLOCKS.getValueAt(world.getForeMap(x, y)).collision); } private void moveCursor() { @@ -86,7 +86,7 @@ public class GameProc implements Serializable{ if (ctrlMode == 0 && CaveGame.TOUCH) { cursorX = (int) (player.position.x + player.texWidth / 2) / 16; if (player.dir == 0) cursorX--; - else cursorX++; + else cursorX++; cursorY = (int) (player.position.y + player.texWidth) / 16; if (!isAutoselectable(cursorX, cursorY)) { cursorY++; @@ -98,249 +98,251 @@ public class GameProc implements Serializable{ if (player.dir == 0) cursorX++; else cursorX--; } - } else if (!CaveGame.TOUCH){ - cursorX = (int)(Gdx.input.getX()* - (renderer.camera.viewportWidth/GameScreen.getWidth())+renderer.camera.position.x)/16; - cursorY = (int)(Gdx.input.getY()* - (renderer.camera.viewportHeight/GameScreen.getHeight())+renderer.camera.position.y)/16; - if ((Gdx.input.getX()* - (renderer.camera.viewportWidth/GameScreen.getWidth())+renderer.camera.position.x)<0) + } else if (!CaveGame.TOUCH) { + cursorX = (int) (Gdx.input.getX() * + (renderer.camera.viewportWidth / GameScreen.getWidth()) + renderer.camera.position.x) / 16; + cursorY = (int) (Gdx.input.getY() * + (renderer.camera.viewportHeight / GameScreen.getHeight()) + renderer.camera.position.y) / 16; + if ((Gdx.input.getX() * + (renderer.camera.viewportWidth / GameScreen.getWidth()) + renderer.camera.position.x) < 0) cursorX--; } - if (pastX!=cursorX || pastY!=cursorY) blockDmg = 0; + if (pastX != cursorX || pastY != cursorY) blockDmg = 0; } private void checkCursorBounds() { if (cursorY < 0) cursorY = 0; - if (cursorY >= world.getHeight()) cursorY = world.getHeight()-1; - if (ctrlMode==1) { - if (cursorX*16+8player.position.x+player.texWidth/2) - player.dir=1; + if (cursorY >= world.getHeight()) cursorY = world.getHeight() - 1; + if (ctrlMode == 1) { + if (cursorX * 16 + 8 < player.position.x + player.texWidth / 2) + player.dir = 0; + if (cursorX * 16 + 8 > player.position.x + player.texWidth / 2) + player.dir = 1; } } private void updateFluids(int x, int y) { - if (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y)!=8) { - if (world.getForeMap(x, y)==60) { + if (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y) != 8) { + if (world.getForeMap(x, y) == 60) { if (!Items.isWater(world.getForeMap(x, y - 1))) world.setForeMap(x, y, world.getForeMap(x, y) + 1); - } else if ((!Items.isWater(world.getForeMap(x-1,y)) || - (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) && - (!Items.isWater(world.getForeMap(x+1,y)) || - (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){ - world.setForeMap(x, y, world.getForeMap(x, y)+1); + } else if ((!Items.isWater(world.getForeMap(x - 1, y)) || + (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x - 1, y) >= world.getForeMap(x, y))) && + (!Items.isWater(world.getForeMap(x + 1, y)) || + (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x + 1, y) >= world.getForeMap(x, y)))) { + world.setForeMap(x, y, world.getForeMap(x, y) + 1); } - if (world.getForeMap(x, y)>63) world.setForeMap(x, y, 0); + if (world.getForeMap(x, y) > 63) world.setForeMap(x, y, 0); } if (world.getForeMap(x, y) == 8 || world.getForeMap(x, y) == 60) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,60); - updateBlock(x, y+2); - } else if (Items.isLava(world.getForeMap(x, y+1))) { - if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 68); - } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { - if (world.getForeMap(x+1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>61)) { - world.setForeMap(x+1,y,61); - updateBlock(x+1, y+1); - } else if (Items.isLava(world.getForeMap(x+1, y))) { - if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); - else world.setForeMap(x+1, y, 68); - } else if (world.getForeMap(x+1, y)==61 && (world.getForeMap(x+2, y)==8 || world.getForeMap(x+2, y)==60)) world.setForeMap(x+1, y, 8); - - if (world.getForeMap(x-1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>61)) { - world.setForeMap(x-1,y,61); - updateBlock(x-1, y+1); - } else if (Items.isLava(world.getForeMap(x-1, y))) { - if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); - else world.setForeMap(x-1, y, 68); - } else if (world.getForeMap(x-1, y)==61 && (world.getForeMap(x-2, y)==8 || world.getForeMap(x-2, y)==60)) world.setForeMap(x-1, y, 8); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 60); + updateBlock(x, y + 2); + } else if (Items.isLava(world.getForeMap(x, y + 1))) { + if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4); + else world.setForeMap(x, y + 1, 68); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { + if (world.getForeMap(x + 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) || + (Items.isWater(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 61)) { + world.setForeMap(x + 1, y, 61); + updateBlock(x + 1, y + 1); + } else if (Items.isLava(world.getForeMap(x + 1, y))) { + if (world.getForeMap(x + 1, y) > 9) world.setForeMap(x + 1, y, 4); + else world.setForeMap(x + 1, y, 68); + } else if (world.getForeMap(x + 1, y) == 61 && (world.getForeMap(x + 2, y) == 8 || world.getForeMap(x + 2, y) == 60)) + world.setForeMap(x + 1, y, 8); + + if (world.getForeMap(x - 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) || + (Items.isWater(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 61)) { + world.setForeMap(x - 1, y, 61); + updateBlock(x - 1, y + 1); + } else if (Items.isLava(world.getForeMap(x - 1, y))) { + if (world.getForeMap(x - 1, y) > 9) world.setForeMap(x - 1, y, 4); + else world.setForeMap(x - 1, y, 68); + } else if (world.getForeMap(x - 1, y) == 61 && (world.getForeMap(x - 2, y) == 8 || world.getForeMap(x - 2, y) == 60)) + world.setForeMap(x - 1, y, 8); } return; } if (world.getForeMap(x, y) == 61) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,60); - updateBlock(x, y+2); - } else if (Items.isLava(world.getForeMap(x, y+1))) { - if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 68); - } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { - if (world.getForeMap(x+1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>62)){ - world.setForeMap(x+1,y,62); - updateBlock(x+1, y+1); - } else if (Items.isLava(world.getForeMap(x+1, y))) { - if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); - else world.setForeMap(x+1, y, 68); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 60); + updateBlock(x, y + 2); + } else if (Items.isLava(world.getForeMap(x, y + 1))) { + if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4); + else world.setForeMap(x, y + 1, 68); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { + if (world.getForeMap(x + 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) || + (Items.isWater(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 62)) { + world.setForeMap(x + 1, y, 62); + updateBlock(x + 1, y + 1); + } else if (Items.isLava(world.getForeMap(x + 1, y))) { + if (world.getForeMap(x + 1, y) > 9) world.setForeMap(x + 1, y, 4); + else world.setForeMap(x + 1, y, 68); } - if (world.getForeMap(x-1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>62)){ - world.setForeMap(x-1,y,62); - updateBlock(x-1, y+1); - } else if (Items.isLava(world.getForeMap(x-1, y))) { - if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); - else world.setForeMap(x-1, y, 68); + if (world.getForeMap(x - 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) || + (Items.isWater(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 62)) { + world.setForeMap(x - 1, y, 62); + updateBlock(x - 1, y + 1); + } else if (Items.isLava(world.getForeMap(x - 1, y))) { + if (world.getForeMap(x - 1, y) > 9) world.setForeMap(x - 1, y, 4); + else world.setForeMap(x - 1, y, 68); } } return; } if (world.getForeMap(x, y) == 62) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,60); - updateBlock(x, y+2); - } else if (Items.isLava(world.getForeMap(x, y+1))) { - if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 68); - } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { - if (world.getForeMap(x+1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){ - world.setForeMap(x+1,y,63); - updateBlock(x+1, y+1); - } else if (Items.isLava(world.getForeMap(x+1, y))) { - if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4); - else world.setForeMap(x+1, y, 68); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 60); + updateBlock(x, y + 2); + } else if (Items.isLava(world.getForeMap(x, y + 1))) { + if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4); + else world.setForeMap(x, y + 1, 68); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { + if (world.getForeMap(x + 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y)))) { + world.setForeMap(x + 1, y, 63); + updateBlock(x + 1, y + 1); + } else if (Items.isLava(world.getForeMap(x + 1, y))) { + if (world.getForeMap(x + 1, y) > 9) world.setForeMap(x + 1, y, 4); + else world.setForeMap(x + 1, y, 68); } - if (world.getForeMap(x-1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){ - world.setForeMap(x-1,y,63); - updateBlock(x-1, y+1); - } else if (Items.isLava(world.getForeMap(x-1, y))) { - if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4); - else world.setForeMap(x-1, y, 68); + if (world.getForeMap(x - 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y)))) { + world.setForeMap(x - 1, y, 63); + updateBlock(x - 1, y + 1); + } else if (Items.isLava(world.getForeMap(x - 1, y))) { + if (world.getForeMap(x - 1, y) > 9) world.setForeMap(x - 1, y, 4); + else world.setForeMap(x - 1, y, 68); } } return; } if (world.getForeMap(x, y) == 63) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,60); - updateBlock(x, y+2); - } else if (Items.isLava(world.getForeMap(x, y+1))) { - if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4); - else world.setForeMap(x, y+1, 68); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 60); + updateBlock(x, y + 2); + } else if (Items.isLava(world.getForeMap(x, y + 1))) { + if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4); + else world.setForeMap(x, y + 1, 68); } return; } - if (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x, y)!=9) { - if (world.getForeMap(x, y)==64) { + if (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x, y) != 9) { + if (world.getForeMap(x, y) == 64) { if (!Items.isLava(world.getForeMap(x, y - 1))) world.setForeMap(x, y, world.getForeMap(x, y) + 1); - } else if ((!Items.isLava(world.getForeMap(x,y-1))) && - (!Items.isLava(world.getForeMap(x-1,y)) || - (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) && - (!Items.isLava(world.getForeMap(x+1,y)) || - (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){ - world.setForeMap(x, y, world.getForeMap(x, y)+1); + } else if ((!Items.isLava(world.getForeMap(x, y - 1))) && + (!Items.isLava(world.getForeMap(x - 1, y)) || + (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x - 1, y) >= world.getForeMap(x, y))) && + (!Items.isLava(world.getForeMap(x + 1, y)) || + (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x + 1, y) >= world.getForeMap(x, y)))) { + world.setForeMap(x, y, world.getForeMap(x, y) + 1); } - if (world.getForeMap(x, y)>67) world.setForeMap(x, y, 0); + if (world.getForeMap(x, y) > 67) world.setForeMap(x, y, 0); } if (world.getForeMap(x, y) == 9 || world.getForeMap(x, y) == 64) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,64); - updateBlock(x, y+2); - } else if (Items.isWater(world.getForeMap(x, y+1))) { - world.setForeMap(x, y+1, 1); - } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { - if (world.getForeMap(x+1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>65)) { - world.setForeMap(x+1,y,65); - updateBlock(x+1, y+1); - } else if (Items.isWater(world.getForeMap(x+1, y))) { - world.setForeMap(x+1, y, 1); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 64); + updateBlock(x, y + 2); + } else if (Items.isWater(world.getForeMap(x, y + 1))) { + world.setForeMap(x, y + 1, 1); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { + if (world.getForeMap(x + 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) || + (Items.isLava(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 65)) { + world.setForeMap(x + 1, y, 65); + updateBlock(x + 1, y + 1); + } else if (Items.isWater(world.getForeMap(x + 1, y))) { + world.setForeMap(x + 1, y, 1); } - if (world.getForeMap(x-1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>65)) { - world.setForeMap(x-1,y,65); - updateBlock(x-1, y+1); - } else if (Items.isWater(world.getForeMap(x-1, y))) { - world.setForeMap(x-1, y, 1); + if (world.getForeMap(x - 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) || + (Items.isLava(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 65)) { + world.setForeMap(x - 1, y, 65); + updateBlock(x - 1, y + 1); + } else if (Items.isWater(world.getForeMap(x - 1, y))) { + world.setForeMap(x - 1, y, 1); } } return; } if (world.getForeMap(x, y) == 65) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,64); - updateBlock(x, y+2); - } else if (Items.isWater(world.getForeMap(x, y+1))) { - world.setForeMap(x, y+1, 1); - } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { - if (world.getForeMap(x+1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) || - (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>66)){ - world.setForeMap(x+1,y,66); - updateBlock(x+1, y+1); - } else if (Items.isWater(world.getForeMap(x+1, y))) { - world.setForeMap(x+1, y, 1); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 64); + updateBlock(x, y + 2); + } else if (Items.isWater(world.getForeMap(x, y + 1))) { + world.setForeMap(x, y + 1, 1); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { + if (world.getForeMap(x + 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) || + (Items.isLava(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 66)) { + world.setForeMap(x + 1, y, 66); + updateBlock(x + 1, y + 1); + } else if (Items.isWater(world.getForeMap(x + 1, y))) { + world.setForeMap(x + 1, y, 1); } - if (world.getForeMap(x-1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) || - (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>66)){ - world.setForeMap(x-1,y,66); - updateBlock(x-1, y+1); - } else if (Items.isWater(world.getForeMap(x-1, y))) { - world.setForeMap(x-1, y, 1); + if (world.getForeMap(x - 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) || + (Items.isLava(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 66)) { + world.setForeMap(x - 1, y, 66); + updateBlock(x - 1, y + 1); + } else if (Items.isWater(world.getForeMap(x - 1, y))) { + world.setForeMap(x - 1, y, 1); } } return; } if (world.getForeMap(x, y) == 66) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,64); - updateBlock(x, y+2); - } else if (Items.isWater(world.getForeMap(x, y+1))) { - world.setForeMap(x, y+1, 1); - } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { - if (world.getForeMap(x+1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){ - world.setForeMap(x+1,y,67); - updateBlock(x+1, y+1); - } else if (Items.isWater(world.getForeMap(x+1, y))) { - world.setForeMap(x+1, y, 1); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 64); + updateBlock(x, y + 2); + } else if (Items.isWater(world.getForeMap(x, y + 1))) { + world.setForeMap(x, y + 1, 1); + } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { + if (world.getForeMap(x + 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y)))) { + world.setForeMap(x + 1, y, 67); + updateBlock(x + 1, y + 1); + } else if (Items.isWater(world.getForeMap(x + 1, y))) { + world.setForeMap(x + 1, y, 1); } - if (world.getForeMap(x-1, y)==0 || - (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){ - world.setForeMap(x-1,y,67); - updateBlock(x-1, y+1); - } else if (Items.isWater(world.getForeMap(x-1, y))) { - world.setForeMap(x-1, y, 1); + if (world.getForeMap(x - 1, y) == 0 || + (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y)))) { + world.setForeMap(x - 1, y, 67); + updateBlock(x - 1, y + 1); + } else if (Items.isWater(world.getForeMap(x - 1, y))) { + world.setForeMap(x - 1, y, 1); } } return; } if (world.getForeMap(x, y) == 67) { - if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) || - (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) { - world.setForeMap(x,y+1,64); - updateBlock(x, y+2); - } else if (Items.isWater(world.getForeMap(x, y+1))) { - world.setForeMap(x, y+1, 1); + if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) || + (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) { + world.setForeMap(x, y + 1, 64); + updateBlock(x, y + 2); + } else if (Items.isWater(world.getForeMap(x, y + 1))) { + world.setForeMap(x, y + 1, 1); } return; } @@ -348,40 +350,40 @@ public class GameProc implements Serializable{ private void updateBlock(int x, int y) { if (world.getForeMap(x, y) == 10) { - if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x,y+1)).collision) { + if (world.getForeMap(x, y + 1) == 0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { world.setForeMap(x, y, 0); - mobs.add(new FallingSand(x*16, y*16)); - updateBlock(x, y-1); + mobs.add(new FallingSand(x * 16, y * 16)); + updateBlock(x, y - 1); } } if (world.getForeMap(x, y) == 11) { - if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x,y+1)).collision) { + if (world.getForeMap(x, y + 1) == 0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { world.setForeMap(x, y, 0); - mobs.add(new FallingGravel(x*16, y*16)); - updateBlock(x, y-1); + mobs.add(new FallingGravel(x * 16, y * 16)); + updateBlock(x, y - 1); } } if (world.getForeMap(x, y) == 59) { - if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) { - world.setForeMap(x,y,0); - updateBlock(x, y-1); + if (world.getForeMap(x, y + 1) == 0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) { + world.setForeMap(x, y, 0); + updateBlock(x, y - 1); } } if (world.getForeMap(x, y) == 2) { - if (world.getForeMap(x, y-1)>0 && (Items.BLOCKS.getValueAt(world.getForeMap(x, y-1)).collision || - Items.isFluid(world.getForeMap(x, y-1)))) { + if (world.getForeMap(x, y - 1) > 0 && (Items.BLOCKS.getValueAt(world.getForeMap(x, y - 1)).collision || + Items.isFluid(world.getForeMap(x, y - 1)))) { world.setForeMap(x, y, 3); } } } public void useItem(int x, int y, int id, boolean bg) { - if (id>0 && Items.ITEMS.get(id).getType()==0) { + if (id > 0 && Items.ITEMS.get(id).getType() == 0) { if (!bg) world.placeToForeground(x, y, Items.ITEMS.get(id).getBlock()); - else world.placeToBackground(x, y, Items.ITEMS.get(id).getBlock()); + else world.placeToBackground(x, y, Items.ITEMS.get(id).getBlock()); } } @@ -389,15 +391,15 @@ public class GameProc implements Serializable{ RUN_TIME += delta; if (DO_UPD) { - for (int y=UPD_Y; y 0 && - Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()>=0){// || world.getBackMap(cursorX, cursorY) > 0) { + Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp() >= 0) {// || world.getBackMap(cursorX, cursorY) > 0) { blockDmg++; - if (blockDmg>=Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()) { - if (Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop()>0) - drops.add(new Drop(cursorX*16+4, cursorY*16+4, Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop())); + if (blockDmg >= Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()) { + if (Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop() > 0) + drops.add(new Drop(cursorX * 16 + 4, cursorY * 16 + 4, Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop())); world.placeToForeground(cursorX, cursorY, 0); - blockDmg=0; + blockDmg = 0; } } } if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) { - if (touchDownButton== Input.Buttons.RIGHT) { + if (touchDownButton == Input.Buttons.RIGHT) { useItem(cursorX, cursorY, player.inventory[invSlot], true); isTouchDown = false; - } else if (touchDownY< Assets.invBar.getRegionHeight() && - touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 && - touchDownX renderer.camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 && + touchDownX < renderer.camera.viewportWidth / 2 + Assets.invBar.getRegionWidth() / 2) { CaveGame.STATE = AppState.GAME_CREATIVE_INV; isTouchDown = false; } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 3d3a8f6..5a8ab94 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -1,9 +1,7 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import ru.deadsoftware.cavecraft.CaveGame; @@ -18,51 +16,51 @@ public class GameRenderer extends Renderer { private GameProc gameProc; - public GameRenderer(GameProc gameProc,float width, float heigth) { - super(width,heigth); - Gdx.gl.glClearColor(0f,.6f,.6f,1f); + public GameRenderer(GameProc gameProc, float width, float heigth) { + super(width, heigth); + Gdx.gl.glClearColor(0f, .6f, .6f, 1f); this.gameProc = gameProc; } private void drawWorldBackground() { - int minX = (int) (camera.position.x/16)-1; - int minY = (int) (camera.position.y/16)-1; - int maxX = (int) ((camera.position.x+camera.viewportWidth)/16)+1; - int maxY = (int) ((camera.position.y+camera.viewportHeight)/16)+1; - if (minY<0) minY=0; - if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); - for (int y=minY; y0) { + int minX = (int) (camera.position.x / 16) - 1; + int minY = (int) (camera.position.y / 16) - 1; + int maxX = (int) ((camera.position.x + camera.viewportWidth) / 16) + 1; + int maxY = (int) ((camera.position.y + camera.viewportHeight) / 16) + 1; + if (minY < 0) minY = 0; + if (maxY > gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); + for (int y = minY; y < maxY; y++) { + for (int x = minX; x < maxX; x++) { + if ((gameProc.world.getForeMap(x, y) == 0 || Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).transparent) + && gameProc.world.getBackMap(x, y) > 0) { spriteBatch.draw( - Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getBackMap(x,y)).getTexture()], - x * 16 - camera.position.x,y * 16 - camera.position.y); - Assets.shade.setPosition(x * 16 - camera.position.x,y * 16 - camera.position.y); + Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getBackMap(x, y)).getTexture()], + x * 16 - camera.position.x, y * 16 - camera.position.y); + Assets.shade.setPosition(x * 16 - camera.position.x, y * 16 - camera.position.y); Assets.shade.draw(spriteBatch); } - if (gameProc.world.getForeMap(x,y)>0 && Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).background) { + if (gameProc.world.getForeMap(x, y) > 0 && Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).background) { spriteBatch.draw( - Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture()], - x * 16 - camera.position.x,y * 16 - camera.position.y); + Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).getTexture()], + x * 16 - camera.position.x, y * 16 - camera.position.y); } } } } - private void drawWorldForeground(){ - int minX = (int) (camera.position.x/16)-1; - int minY = (int) (camera.position.y/16)-1; - int maxX = (int) ((camera.position.x+camera.viewportWidth)/16)+1; - int maxY = (int) ((camera.position.y+camera.viewportHeight)/16)+1; - if (minY<0) minY=0; - if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); - for (int y=minY; y0 && !Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).background) { + private void drawWorldForeground() { + int minX = (int) (camera.position.x / 16) - 1; + int minY = (int) (camera.position.y / 16) - 1; + int maxX = (int) ((camera.position.x + camera.viewportWidth) / 16) + 1; + int maxY = (int) ((camera.position.y + camera.viewportHeight) / 16) + 1; + if (minY < 0) minY = 0; + if (maxY > gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); + for (int y = minY; y < maxY; y++) { + for (int x = minX; x < maxX; x++) { + if (gameProc.world.getForeMap(x, y) > 0 && !Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).background) { spriteBatch.draw( - Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture()], - x * 16 - camera.position.x,y * 16 - camera.position.y); + Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).getTexture()], + x * 16 - camera.position.x, y * 16 - camera.position.y); } } } @@ -70,27 +68,27 @@ public class GameRenderer extends Renderer { private void drawMob(Mob mob) { mob.draw(spriteBatch, - mob.position.x-camera.position.x-gameProc.world.getWidth()*16, mob.position.y-camera.position.y); + mob.position.x - camera.position.x - gameProc.world.getWidth() * 16, mob.position.y - camera.position.y); mob.draw(spriteBatch, - mob.position.x-camera.position.x, mob.position.y-camera.position.y); + mob.position.x - camera.position.x, mob.position.y - camera.position.y); mob.draw(spriteBatch, - mob.position.x-camera.position.x+gameProc.world.getWidth()*16, mob.position.y-camera.position.y); + mob.position.x - camera.position.x + gameProc.world.getWidth() * 16, mob.position.y - camera.position.y); } private void drawDrop(Drop drop) { switch (Items.ITEMS.get(drop.getId()).getType()) { case 0: - Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x-camera.position.x-gameProc.world.getWidth()*16, drop.position.y-camera.position.y); + Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x - camera.position.x - gameProc.world.getWidth() * 16, drop.position.y - camera.position.y); Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].draw(spriteBatch); - Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x-camera.position.x, drop.position.y-camera.position.y); + Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x - camera.position.x, drop.position.y - camera.position.y); Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].draw(spriteBatch); - Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x-camera.position.x+gameProc.world.getWidth()*16, drop.position.y-camera.position.y); + Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x - camera.position.x + gameProc.world.getWidth() * 16, drop.position.y - camera.position.y); Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].draw(spriteBatch); } } private void drawPlayer(Player pl) { - if (!pl.moveX.equals(Vector2.Zero) || Assets.playerSprite[0][2].getRotation()!=0) { + if (!pl.moveX.equals(Vector2.Zero) || 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); @@ -101,7 +99,7 @@ public class GameRenderer extends Renderer { Assets.playerSprite[0][3].setRotation(0); Assets.playerSprite[1][3].setRotation(0); } - if (Assets.playerSprite[0][2].getRotation()>=60 || Assets.playerSprite[0][2].getRotation()<=-60) + if (Assets.playerSprite[0][2].getRotation() >= 60 || Assets.playerSprite[0][2].getRotation() <= -60) Player.ANIM_SPEED = -Player.ANIM_SPEED; //back hand @@ -127,23 +125,23 @@ public class GameRenderer extends Renderer { spriteBatch.draw(Assets.playerSprite[pl.dir][1], pl.position.x - camera.position.x - 2, pl.position.y - camera.position.y + 8); //item in hand - if (pl.inventory[gameProc.invSlot]>0) + if (pl.inventory[gameProc.invSlot] > 0) switch (Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getType()) { case 0: Assets.blockTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setPosition( - pl.position.x - camera.position.x - 8*MathUtils.sin(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()), - pl.position.y - camera.position.y + 6 + 8*MathUtils.cos(MathUtils.degRad*Assets.playerSprite[0][2].getRotation())); + pl.position.x - camera.position.x - 8 * MathUtils.sin(MathUtils.degRad * Assets.playerSprite[0][2].getRotation()), + pl.position.y - camera.position.y + 6 + 8 * MathUtils.cos(MathUtils.degRad * Assets.playerSprite[0][2].getRotation())); Assets.blockTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].draw(spriteBatch); break; default: - Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir==0), false); + Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir == 0), false); Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setRotation( - -45+pl.dir*90+Assets.playerSprite[0][2].getRotation()); + -45 + pl.dir * 90 + Assets.playerSprite[0][2].getRotation()); Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setPosition( - pl.position.x - camera.position.x -10+(12*pl.dir) - 8*MathUtils.sin(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()), - pl.position.y - camera.position.y + 2 + 8*MathUtils.cos(MathUtils.degRad*Assets.playerSprite[0][2].getRotation())); + pl.position.x - camera.position.x - 10 + (12 * pl.dir) - 8 * MathUtils.sin(MathUtils.degRad * Assets.playerSprite[0][2].getRotation()), + pl.position.y - camera.position.y + 2 + 8 * MathUtils.cos(MathUtils.degRad * Assets.playerSprite[0][2].getRotation())); Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].draw(spriteBatch); - Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir==0), false); + Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir == 0), false); break; } //front hand @@ -154,18 +152,18 @@ public class GameRenderer extends Renderer { } private void drawCreative() { - float x = camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2; - float y = camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2; + float x = camera.viewportWidth / 2 - Assets.creativeInv.getRegionWidth() / 2; + float y = camera.viewportHeight / 2 - Assets.creativeInv.getRegionHeight() / 2; spriteBatch.draw(Assets.creativeInv, x, y); - spriteBatch.draw(Assets.creativeScroll, x+156, - y+18+(gameProc.creativeScroll*(72/gameProc.maxCreativeScroll))); - for (int i=gameProc.creativeScroll*8; i0 && i 0 && i < Items.ITEMS.size()) switch (Items.ITEMS.get(i).getType()) { case 0: spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(i).getTexture()], - x + 8 + ((i - gameProc.creativeScroll * 8) % 8) * 18, - y + 18 + ((i - gameProc.creativeScroll * 8) / 8) * 18); + x + 8 + ((i - gameProc.creativeScroll * 8) % 8) * 18, + y + 18 + ((i - gameProc.creativeScroll * 8) / 8) * 18); break; case 1: spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(i).getTexture()], @@ -174,12 +172,12 @@ public class GameRenderer extends Renderer { break; } } - for (int i=0; i<9; i++) { - if (gameProc.player.inventory[i]>0) + for (int i = 0; i < 9; i++) { + if (gameProc.player.inventory[i] > 0) switch (Items.ITEMS.get(gameProc.player.inventory[i]).getType()) { case 0: spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], - x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); + x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); break; case 1: spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], @@ -192,26 +190,26 @@ public class GameRenderer extends Renderer { private void drawGUI() { if (gameProc.blockDmg > 0) { spriteBatch.draw(Assets.wreck[ - 10*gameProc.blockDmg/ + 10 * gameProc.blockDmg / Items.BLOCKS.getValueAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)).getHp()], - gameProc.cursorX*16-camera.position.x, - gameProc.cursorY*16-camera.position.y); + gameProc.cursorX * 16 - camera.position.x, + gameProc.cursorY * 16 - camera.position.y); } - if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)>0 || - gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY)>0 || - gameProc.ctrlMode==1 || + if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY) > 0 || + gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY) > 0 || + gameProc.ctrlMode == 1 || !CaveGame.TOUCH) spriteBatch.draw(Assets.guiCur, - gameProc.cursorX*16-camera.position.x, - gameProc.cursorY*16-camera.position.y); - spriteBatch.draw(Assets.invBar, camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2, 0); - for (int i=0; i<9; i++) { - if (gameProc.player.inventory[i]>0) { + gameProc.cursorX * 16 - camera.position.x, + gameProc.cursorY * 16 - camera.position.y); + spriteBatch.draw(Assets.invBar, camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2, 0); + for (int i = 0; i < 9; i++) { + if (gameProc.player.inventory[i] > 0) { switch (Items.ITEMS.get(gameProc.player.inventory[i]).getType()) { case 0: spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], - camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, - 3); + camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, + 3); break; case 1: spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()], @@ -222,20 +220,20 @@ public class GameRenderer extends Renderer { } } spriteBatch.draw(Assets.invBarCur, - camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2 - 1 + 20*gameProc.invSlot, + camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 - 1 + 20 * gameProc.invSlot, -1); } private void drawTouchGui() { - spriteBatch.draw(Assets.touchArrows[0],26,camera.viewportHeight-52); - spriteBatch.draw(Assets.touchArrows[1],0,camera.viewportHeight-26); - spriteBatch.draw(Assets.touchArrows[2],26,camera.viewportHeight-26); - spriteBatch.draw(Assets.touchArrows[3],52,camera.viewportHeight-26); - spriteBatch.draw(Assets.touchLMB, camera.viewportWidth-52, camera.viewportHeight-26); - spriteBatch.draw(Assets.touchRMB, camera.viewportWidth-26, camera.viewportHeight-26); - spriteBatch.draw(Assets.touchToggleMode, 78, camera.viewportHeight-26); - if (gameProc.ctrlMode==1) { - Assets.shade.setPosition(83, camera.viewportHeight-21); + spriteBatch.draw(Assets.touchArrows[0], 26, camera.viewportHeight - 52); + spriteBatch.draw(Assets.touchArrows[1], 0, camera.viewportHeight - 26); + spriteBatch.draw(Assets.touchArrows[2], 26, camera.viewportHeight - 26); + spriteBatch.draw(Assets.touchArrows[3], 52, camera.viewportHeight - 26); + spriteBatch.draw(Assets.touchLMB, camera.viewportWidth - 52, camera.viewportHeight - 26); + spriteBatch.draw(Assets.touchRMB, camera.viewportWidth - 26, camera.viewportHeight - 26); + spriteBatch.draw(Assets.touchToggleMode, 78, camera.viewportHeight - 26); + if (gameProc.ctrlMode == 1) { + Assets.shade.setPosition(83, camera.viewportHeight - 21); Assets.shade.draw(spriteBatch); } } @@ -267,12 +265,12 @@ public class GameRenderer extends Renderer { if (CaveGame.TOUCH) drawTouchGui(); if (GameScreen.SHOW_DEBUG) { - drawString("FPS: "+GameScreen.FPS,0, 0); - drawString("X: "+(int)(gameProc.player.position.x/16),0, 10); - drawString("Y: "+(int)(gameProc.player.position.y/16),0, 20); - drawString("Mobs: "+gameProc.mobs.size(), 0, 30); - drawString("Drops: "+gameProc.drops.size(), 0, 40); - drawString("Block: "+Items.BLOCKS.getKeyAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)), 0, 50); + drawString("FPS: " + GameScreen.FPS, 0, 0); + drawString("X: " + (int) (gameProc.player.position.x / 16), 0, 10); + drawString("Y: " + (int) (gameProc.player.position.y / 16), 0, 20); + drawString("Mobs: " + gameProc.mobs.size(), 0, 30); + drawString("Drops: " + gameProc.drops.size(), 0, 40); + drawString("Block: " + Items.BLOCKS.getKeyAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)), 0, 50); } spriteBatch.end(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java index aab81f5..a4e314b 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java @@ -15,23 +15,23 @@ public class GameSaver { return ByteBuffer.allocate(4).putInt(i).array(); } - private static void saveMap(FileHandle file, int[][] map) throws IOException{ - int rl,bl; + private static void saveMap(FileHandle file, int[][] map) throws IOException { + int rl, bl; int width = map.length; int height = map[0].length; BufferedOutputStream out = new BufferedOutputStream(file.write(false)); out.write(intToBytes(VERSION)); out.write(intToBytes(width)); out.write(intToBytes(height)); - for (int y=0; y0 && Items.BLOCKS.getValueAt(getForeMap(x,y)).collision) break; + if (getForeMap(x, y) > 0 && Items.BLOCKS.getValueAt(getForeMap(x, y)).collision) break; } - x = x*16 + 4; - y = y*16 - 32; - return new Vector2(x,y); + x = x * 16 + 4; + y = y * 16 - 32; + return new Vector2(x, y); } public void generate(int w, int h) { WIDTH = w; HEIGHT = h; - WorldGen.genWorld(WIDTH,HEIGHT); + WorldGen.genWorld(WIDTH, HEIGHT); foreMap = WorldGen.getForeMap(); backMap = WorldGen.getBackMap(); WorldGen.clear(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index 690d5ac..2121ae0 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -173,131 +173,131 @@ public class Items { //5 BLOCKS.put("planks", new Block(4, 180, 5)); //6 - BLOCKS.put("sapling", new Block(5,0,6,false,false,true)); + BLOCKS.put("sapling", new Block(5, 0, 6, false, false, true)); //7 - BLOCKS.put("bedrock", new Block(6,-1,7)); + BLOCKS.put("bedrock", new Block(6, -1, 7)); //8 - BLOCKS.put("water", new Block(7,-1,0,false,false,true)); + BLOCKS.put("water", new Block(7, -1, 0, false, false, true)); //9 - BLOCKS.put("lava", new Block(8,-1,0,false,false,false)); + BLOCKS.put("lava", new Block(8, -1, 0, false, false, false)); //10 - BLOCKS.put("sand", new Block(9, 45,8)); + BLOCKS.put("sand", new Block(9, 45, 8)); //11 - BLOCKS.put("gravel", new Block(10, 54,9)); + BLOCKS.put("gravel", new Block(10, 54, 9)); //12 - BLOCKS.put("gold_ore", new Block(11, 900,10)); + BLOCKS.put("gold_ore", new Block(11, 900, 10)); //13 - BLOCKS.put("iron_ore", new Block(12, 900,11)); + BLOCKS.put("iron_ore", new Block(12, 900, 11)); //14 - BLOCKS.put("coal_ore", new Block(13, 900,0)); + BLOCKS.put("coal_ore", new Block(13, 900, 0)); //15 - BLOCKS.put("log", new Block(14, 180,13)); + BLOCKS.put("log", new Block(14, 180, 13)); //16 - BLOCKS.put("leaves", new Block(15, 21,0)); + BLOCKS.put("leaves", new Block(15, 21, 0)); //17 - BLOCKS.put("sponge", new Block(16, 54,0)); + BLOCKS.put("sponge", new Block(16, 54, 0)); //18 - BLOCKS.put("glass", new Block(17, 27,0,true,false,true)); + BLOCKS.put("glass", new Block(17, 27, 0, true, false, true)); //19 - BLOCKS.put("lapis_ore", new Block(18, 900,0)); + BLOCKS.put("lapis_ore", new Block(18, 900, 0)); //20 - BLOCKS.put("lapis_block", new Block(19, 900,17)); + BLOCKS.put("lapis_block", new Block(19, 900, 17)); //21 - BLOCKS.put("sandstone", new Block(20, 240,18)); + BLOCKS.put("sandstone", new Block(20, 240, 18)); //22 - BLOCKS.put("noteblock", new Block(21, 75,0)); + BLOCKS.put("noteblock", new Block(21, 75, 0)); //23 - BLOCKS.put("bed_l", new Block(22, 21,0,false,true,true)); + BLOCKS.put("bed_l", new Block(22, 21, 0, false, true, true)); //24 - BLOCKS.put("bed_r", new Block(23, 21,0, false,true, true)); + BLOCKS.put("bed_r", new Block(23, 21, 0, false, true, true)); //25 - BLOCKS.put("cobweb", new Block(24, 1200,0,false,false,true)); + BLOCKS.put("cobweb", new Block(24, 1200, 0, false, false, true)); //26 - BLOCKS.put("tallgrass", new Block(25, 0,0,false,false,true)); + BLOCKS.put("tallgrass", new Block(25, 0, 0, false, false, true)); //27 - BLOCKS.put("deadbush", new Block(26, 0,0,false,false,true)); + BLOCKS.put("deadbush", new Block(26, 0, 0, false, false, true)); //28 - BLOCKS.put("brick_block", new Block(27, 600,22)); + BLOCKS.put("brick_block", new Block(27, 600, 22)); //29 - BLOCKS.put("dandelion", new Block(28, 0,23,false,false,true)); + BLOCKS.put("dandelion", new Block(28, 0, 23, false, false, true)); //30 - BLOCKS.put("rose", new Block(29, 0,24,false,false,true)); + BLOCKS.put("rose", new Block(29, 0, 24, false, false, true)); //31 - BLOCKS.put("brown_mushroom", new Block(30, 0,25,false,false,true)); + BLOCKS.put("brown_mushroom", new Block(30, 0, 25, false, false, true)); //32 - BLOCKS.put("red_mushroom", new Block(31, 0,26,false,false,true)); + BLOCKS.put("red_mushroom", new Block(31, 0, 26, false, false, true)); //33 - BLOCKS.put("wool_while", new Block(32, 75,27,true,false,false)); + BLOCKS.put("wool_while", new Block(32, 75, 27, true, false, false)); //34 - BLOCKS.put("wool_orange", new Block(33, 75,28,true,false,false)); + BLOCKS.put("wool_orange", new Block(33, 75, 28, true, false, false)); //35 - BLOCKS.put("wool_magenta", new Block(34, 75,29,true,false,false)); + BLOCKS.put("wool_magenta", new Block(34, 75, 29, true, false, false)); //36 - BLOCKS.put("wool_lightblue", new Block(35, 75,30,true,false,false)); + BLOCKS.put("wool_lightblue", new Block(35, 75, 30, true, false, false)); //37 - BLOCKS.put("wool_yellow", new Block(36, 75,31,true,false,false)); + BLOCKS.put("wool_yellow", new Block(36, 75, 31, true, false, false)); //38 - BLOCKS.put("wool_lime", new Block(37, 75,32,true,false,false)); + BLOCKS.put("wool_lime", new Block(37, 75, 32, true, false, false)); //39 - BLOCKS.put("wool_pink", new Block(38, 75,33,true,false,false)); + BLOCKS.put("wool_pink", new Block(38, 75, 33, true, false, false)); //40 - BLOCKS.put("wool_gray", new Block(39, 75,34,true,false,false)); + BLOCKS.put("wool_gray", new Block(39, 75, 34, true, false, false)); //41 - BLOCKS.put("wool_lightgray", new Block(40, 75,35,true,false,false)); + BLOCKS.put("wool_lightgray", new Block(40, 75, 35, true, false, false)); //42 - BLOCKS.put("wool_cyan", new Block(41, 75,36,true,false,false)); + BLOCKS.put("wool_cyan", new Block(41, 75, 36, true, false, false)); //43 - BLOCKS.put("wool_purple", new Block(42, 75,37,true,false,false)); + BLOCKS.put("wool_purple", new Block(42, 75, 37, true, false, false)); //44 - BLOCKS.put("wool_blue", new Block(43, 75,38,true,false,false)); + BLOCKS.put("wool_blue", new Block(43, 75, 38, true, false, false)); //45 - BLOCKS.put("wool_brown", new Block(44, 75,39,true,false,false)); + BLOCKS.put("wool_brown", new Block(44, 75, 39, true, false, false)); //46 - BLOCKS.put("wool_green", new Block(45, 75,40,true,false,false)); + BLOCKS.put("wool_green", new Block(45, 75, 40, true, false, false)); //47 - BLOCKS.put("wool_red", new Block(46, 75,41,true,false,false)); + BLOCKS.put("wool_red", new Block(46, 75, 41, true, false, false)); //48 - BLOCKS.put("wool_black", new Block(47, 75,42,true,false,false)); + BLOCKS.put("wool_black", new Block(47, 75, 42, true, false, false)); //49 - BLOCKS.put("gold_block", new Block(48, 900,43)); + BLOCKS.put("gold_block", new Block(48, 900, 43)); //50 - BLOCKS.put("iron_block", new Block(49, 1500,44)); + BLOCKS.put("iron_block", new Block(49, 1500, 44)); //51 - BLOCKS.put("stone_slab", new Block(0, 8, 16,8, 50, 600,45, true, false, true)); + BLOCKS.put("stone_slab", new Block(0, 8, 16, 8, 50, 600, 45, true, false, true)); //52 - BLOCKS.put("double_stone_slab", new Block(51, 600,45)); + BLOCKS.put("double_stone_slab", new Block(51, 600, 45)); //53 - BLOCKS.put("sandstone_slab", new Block(0, 8, 16,8, 52, 600,46, true, false, true)); + BLOCKS.put("sandstone_slab", new Block(0, 8, 16, 8, 52, 600, 46, true, false, true)); //54 - BLOCKS.put("wooden_slab", new Block(0, 8, 16,8, 53, 180,47, true, false, true)); + BLOCKS.put("wooden_slab", new Block(0, 8, 16, 8, 53, 180, 47, true, false, true)); //55 - BLOCKS.put("cobblestone_slab", new Block(0, 8, 16,8, 54, 600,48, true, false, true)); + BLOCKS.put("cobblestone_slab", new Block(0, 8, 16, 8, 54, 600, 48, true, false, true)); //56 - BLOCKS.put("brick_slab", new Block(0, 8, 16,8, 55, 600,49, true, false, true)); + BLOCKS.put("brick_slab", new Block(0, 8, 16, 8, 55, 600, 49, true, false, true)); //57 - BLOCKS.put("stonebrick", new Block(64, 450,50)); + BLOCKS.put("stonebrick", new Block(64, 450, 50)); //58 - BLOCKS.put("stone_brick_slab", new Block(0, 8, 16,8, 56, 450,51, true, false, true)); + BLOCKS.put("stone_brick_slab", new Block(0, 8, 16, 8, 56, 450, 51, true, false, true)); //59 - BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, 39,52, true, false, true)); + BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, 39, 52, true, false, true)); //60 - BLOCKS.put("water_16", new Block(7, -1,0,false,false,true)); + BLOCKS.put("water_16", new Block(7, -1, 0, false, false, true)); //61 - BLOCKS.put("water_12", new Block(58, -1,0,false,false,true)); + BLOCKS.put("water_12", new Block(58, -1, 0, false, false, true)); //62 - BLOCKS.put("water_8", new Block(59, -1,0,false,false,true)); + BLOCKS.put("water_8", new Block(59, -1, 0, false, false, true)); //63 - BLOCKS.put("water_4", new Block(60, -1,0,false,false,true)); + BLOCKS.put("water_4", new Block(60, -1, 0, false, false, true)); //64 - BLOCKS.put("lava_16", new Block(8, -1,0,false,false,true)); + BLOCKS.put("lava_16", new Block(8, -1, 0, false, false, true)); //65 - BLOCKS.put("lava_12", new Block(61, -1,0,false,false,true)); + BLOCKS.put("lava_12", new Block(61, -1, 0, false, false, true)); //66 - BLOCKS.put("lava_8", new Block(62, -1,0,false,false,true)); + BLOCKS.put("lava_8", new Block(62, -1, 0, false, false, true)); //67 - BLOCKS.put("lava_4", new Block(63, -1,0,false,false,true)); + BLOCKS.put("lava_4", new Block(63, -1, 0, false, false, true)); //68 - BLOCKS.put("obsidian", new Block(65, 1500,53)); + BLOCKS.put("obsidian", new Block(65, 1500, 53)); } public static void load() { diff --git a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java index bf9eadf..974cef4 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java +++ b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java @@ -1,6 +1,5 @@ package ru.deadsoftware.cavecraft.game; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.RandomXS128; import com.badlogic.gdx.utils.TimeUtils; @@ -22,51 +21,52 @@ public class WorldGen { bMap = new int[width]; int t; res[0] = mid; - for (int i=1; i-3 && t<3) t=0; else t/=Math.abs(t); - if (i>width-(max-min)) { - if (res[i-1]+tres[0]) t=-Math.abs(t); + for (int i = 1; i < width; i++) { + t = rand.nextInt(7) - 3; + if (t > -3 && t < 3) t = 0; + else t /= Math.abs(t); + if (i > width - (max - min)) { + if (res[i - 1] + t < res[0]) t = Math.abs(t); + else if (res[i - 1] + t > res[0]) t = -Math.abs(t); } - res[i] = res[i-1] + t; - if (res[i]max) res[i] = max; - if (i>=width/2) { - bMap [i] = 1; + res[i] = res[i - 1] + t; + if (res[i] < min) res[i] = min; + if (res[i] > max) res[i] = max; + if (i >= width / 2) { + bMap[i] = 1; if (res[i] < 60) res[i] = 60; } else { bMap[i] = 0; } } - if (res[0]2 && x 2 && x < width - 2) { + if (foreMap[x][height - hMap[x] - 1] == 0 && foreMap[x][height - hMap[x]] == 2) { switch (rand.nextInt(50)) { case 0: genOak(x, height - hMap[x] - 1); break; case 1: - foreMap[x][height-hMap[x]-1] = 26; + foreMap[x][height - hMap[x] - 1] = 26; break; case 2: - foreMap[x][height-hMap[x]-1] = 29; + foreMap[x][height - hMap[x] - 1] = 29; break; case 3: - foreMap[x][height-hMap[x]-1] = 30; + foreMap[x][height - hMap[x] - 1] = 30; break; case 4: - foreMap[x][height-hMap[x]-1] = 31; + foreMap[x][height - hMap[x] - 1] = 31; break; case 5: - foreMap[x][height-hMap[x]-1] = 32; + foreMap[x][height - hMap[x] - 1] = 32; break; } } - if (foreMap[x][height-hMap[x]-1]==0 && foreMap[x][height-hMap[x]]==10) { - switch(rand.nextInt(20)) { + if (foreMap[x][height - hMap[x] - 1] == 0 && foreMap[x][height - hMap[x]] == 10) { + switch (rand.nextInt(20)) { case 0: - genCactus(x,height-hMap[x]-1); + genCactus(x, height - hMap[x] - 1); break; case 1: - foreMap[x][height-hMap[x]-1] = 27; + foreMap[x][height - hMap[x] - 1] = 27; break; } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java index 0cfa261..11d02d2 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java @@ -6,7 +6,7 @@ import com.badlogic.gdx.math.Vector2; import ru.deadsoftware.cavecraft.game.Items; import ru.deadsoftware.cavecraft.misc.Assets; -public class FallingGravel extends Mob{ +public class FallingGravel extends Mob { public FallingGravel(int x, int y) { dir = 0; @@ -29,7 +29,7 @@ public class FallingGravel extends Mob{ @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("gravel").getTexture()],x, y); + spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("gravel").getTexture()], x, y); } @Override diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java index 1d6a78e..37f8a59 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java @@ -3,7 +3,6 @@ package ru.deadsoftware.cavecraft.game.mobs; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavecraft.game.GameProc; import ru.deadsoftware.cavecraft.game.Items; import ru.deadsoftware.cavecraft.misc.Assets; @@ -30,7 +29,7 @@ public class FallingSand extends Mob { @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("sand").getTexture()],x, y); + spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("sand").getTexture()], x, y); } @Override diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java index 180c4d1..fbab397 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java @@ -3,12 +3,10 @@ package ru.deadsoftware.cavecraft.game.mobs; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavecraft.game.GameProc; -import ru.deadsoftware.cavecraft.misc.Assets; import java.io.Serializable; -public abstract class Mob implements Serializable{ +public abstract class Mob implements Serializable { public int ANIM_SPEED = 6; public Vector2 position; @@ -18,8 +16,12 @@ public abstract class Mob implements Serializable{ public boolean dead; public abstract void ai(); + public abstract void changeDir(); + public abstract void draw(SpriteBatch spriteBatch, float x, float y); + public abstract Rectangle getRect(); + public abstract int getType(); //0 - mob, 10 - sand, 11 - gravel } diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java index 04a96f6..0fa08bd 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java @@ -4,16 +4,14 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavecraft.game.GameWorld; import ru.deadsoftware.cavecraft.misc.Assets; -import ru.deadsoftware.cavecraft.game.GameProc; -public class Pig extends Mob{ +public class Pig extends Mob { public Pig(int x, int y) { dir = MathUtils.random(1); position = new Vector2(x, y); - moveX = new Vector2(-1+dir*2, 0); + moveX = new Vector2(-1 + dir * 2, 0); moveY = new Vector2(0, 0); width = 25; height = 18; @@ -23,8 +21,8 @@ public class Pig extends Mob{ @Override public void changeDir() { - dir=-dir+1; - moveX.set(-1+2*dir,0); + dir = -dir + 1; + moveX.set(-1 + 2 * dir, 0); } @Override @@ -32,10 +30,11 @@ public class Pig extends Mob{ if (MathUtils.randomBoolean(.0025f)) changeDir(); else if (MathUtils.randomBoolean(.0025f)) { if (moveX.x != 0f) moveX.setZero(); - else moveX.set(-1+2*dir, 0); + else moveX.set(-1 + 2 * dir, 0); } - if (moveX.x != 0f) animation+=ANIM_SPEED; else animation=0; - if (animation>=60 || animation<=-60) { + if (moveX.x != 0f) animation += ANIM_SPEED; + else animation = 0; + if (animation >= 60 || animation <= -60) { ANIM_SPEED = -ANIM_SPEED; } } @@ -45,14 +44,14 @@ public class Pig extends Mob{ Assets.pigSprite[0][1].setRotation(animation); Assets.pigSprite[1][1].setRotation(-animation); //back legs - Assets.pigSprite[1][1].setPosition(x-4+(9-dir*9),y+6); + Assets.pigSprite[1][1].setPosition(x - 4 + (9 - dir * 9), y + 6); Assets.pigSprite[1][1].draw(spriteBatch); - Assets.pigSprite[1][1].setPosition(x+17-(9*dir),y+6); + Assets.pigSprite[1][1].setPosition(x + 17 - (9 * dir), y + 6); Assets.pigSprite[1][1].draw(spriteBatch); //front legs - Assets.pigSprite[0][1].setPosition(x-4+(9-dir*9),y+6); + Assets.pigSprite[0][1].setPosition(x - 4 + (9 - dir * 9), y + 6); Assets.pigSprite[0][1].draw(spriteBatch); - Assets.pigSprite[0][1].setPosition(x+17-(9*dir),y+6); + Assets.pigSprite[0][1].setPosition(x + 17 - (9 * dir), y + 6); Assets.pigSprite[0][1].draw(spriteBatch); //head & body spriteBatch.draw(Assets.pigSprite[dir][0], x, y); diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java index 5d2814e..dfd8351 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java @@ -4,18 +4,18 @@ import com.badlogic.gdx.math.Rectangle; public class Block { - private int x,y,w,h; + private int x, y, w, h; private int texture; private int hp, drop; public boolean collision, background, transparent; public Block(int texture, int hp, int drop) { - this(0,0,16,16,texture, hp, drop, true, false, false); + this(0, 0, 16, 16, texture, hp, drop, true, false, false); } public Block(int texture, int hp, int drop, boolean collision, boolean background, boolean transparent) { - this(0,0,16,16,texture, hp, drop, collision, background, transparent); + this(0, 0, 16, 16, texture, hp, drop, collision, background, transparent); } public Block(int x, int y, int w, int h, int texture, int hp, int drop, boolean collision, boolean background, boolean transparent) { @@ -44,13 +44,13 @@ public class Block { } public Rectangle getRect(int x, int y) { - x*=16; - y*=16; - return new Rectangle(x+this.x, y+this.y, w, h); + x *= 16; + y *= 16; + return new Rectangle(x + this.x, y + this.y, w, h); } public boolean toJump() { - return (y<8 && collision); + return (y < 8 && collision); } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java index bc2ed8f..8c13881 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Item.java @@ -21,12 +21,15 @@ public class Item { public int getTexture() { return texture; } + public int getType() { return type; } + public int getBlock() { return block; } + public String getName() { return name; } diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java index 2d5ffe8..546fb6e 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java @@ -27,7 +27,7 @@ public class Player implements Serializable { } public Rectangle getRect() { - return new Rectangle(position.x+2, position.y, width, height); + return new Rectangle(position.x + 2, position.y, width, height); } } diff --git a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java index da04d46..d7da1c5 100644 --- a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java @@ -2,7 +2,8 @@ package ru.deadsoftware.cavecraft.menu; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.Array; -import ru.deadsoftware.cavecraft.*; +import ru.deadsoftware.cavecraft.CaveGame; +import ru.deadsoftware.cavecraft.GameScreen; import ru.deadsoftware.cavecraft.game.GameSaver; import ru.deadsoftware.cavecraft.game.Items; import ru.deadsoftware.cavecraft.menu.objects.Button; @@ -15,11 +16,11 @@ public class MenuRenderer extends Renderer { public Array