From 44bd000cd15bf9713453a279840e133416fea998 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Sat, 28 Sep 2019 22:54:50 +0700 Subject: [PATCH] Fix build --- android/assets/background.png | Bin 0 -> 2176 bytes android/assets/json/texture_regions.json | 9 +- .../deadsoftware/cavedroid/game/GameProc.java | 2 +- .../cavedroid/game/mobs/FallingGravel.java | 2 +- .../cavedroid/game/mobs/FallingSand.java | 2 +- .../cavedroid/menu/MenuRenderer.java | 5 +- .../deadsoftware/cavedroid/misc/Assets.java | 83 +++++++++++------- 7 files changed, 57 insertions(+), 46 deletions(-) create mode 100644 android/assets/background.png diff --git a/android/assets/background.png b/android/assets/background.png new file mode 100644 index 0000000000000000000000000000000000000000..1774f866d5d9ae1c782cd8c4c1b9d9efc57cb003 GIT binary patch literal 2176 zcmV-`2!Hp9P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O1Y;mb5ku{O?ob2$sCb$MJ&S%MEh;loyt6=;`_L z0yB*ankkR9pXC#9xOf(7C{>w(XAUz^&uGDa}WfYXd+UU!!s zbPKNij5tLnUBFt!RH<1{KH?mYIQKM~K3l*ejdE)!~~991}V0m)Ho_Z`STeyG4IVG2dY|~O=ZmA(y3C2R99SVQ?)pL+ow@!C zD-c3$Vd@6Hq~=AxADvhO2Hk*Ju)(DBbdepM+A@P@qn(1O)w5nG)a3vWA+|#@WWa#- zWE^?YfjJNXM*%+xnX|E+!2mhsxFSoo#(0o}YCvqP2{dfk@tj6`83p1^05vEbkY%m2 z9`z=WP*Tn~>zwm0IC0S>Z@l%+dmnu7Qz@8Wg9|={AR&e%MyxpT5=10QiX08vm{ZZm z5GBT#5`re1;48sCVIp%j*=Co04q0-{sX#u(7FT=;MM^BGay1n#KviEul^Sc>XoHkC zySdG8VUsOxsX=SaG}~PBEi`GdrGvG_>MLvS%>B$7E!KDt)$PK`8m2?oT~Kc)u5$*) z*b*2IodF1%J7-$RTJFqs&U9p>jB$)CT_>kfXABJ5jo39hxI3Bq$eRMXf65y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t!7|sZr#aOi$6cdXZ-+@(i10B@`6^Ond|50_sxZ)LvxW zA-xx9p~%?S`X~aWX#a^9+5;weCb7EI7?UF#rqv3z*-HU8N$!+-mYCsC9LyZf+6j-Fb zKIDCBFQ`i`z8^Xi0LHw~-$b2OD-_LMd@*z-LB0V1bTiuHSe~T-0000 500) holdMB(); if (fluidThread == null || !fluidThread.isAlive()) startFluidThread(); diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java index f6149ea..fe4e46a 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java @@ -31,7 +31,7 @@ public class FallingGravel extends Mob { @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(GameItems.getBlock("gravel").getTex(), x, y); + spriteBatch.draw(Assets.fallingGravelSprite, x, y); } @Override diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java index b1777c4..315fcfc 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java @@ -31,7 +31,7 @@ public class FallingSand extends Mob { @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(GameItems.getBlock("sand").getTex(), x, y); + spriteBatch.draw(Assets.fallingSandSprite, x, y); } @Override diff --git a/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java index 2ae84db..74fbf95 100644 --- a/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java +++ b/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java @@ -95,14 +95,13 @@ public class MenuRenderer extends Renderer { @Override public void render() { - TextureRegion shade = textureRegions.get("shade"); + TextureRegion background = textureRegions.get("background"); TextureRegion gamelogo = textureRegions.get("gamelogo"); spriter.begin(); for (int x = 0; x <= getWidth() / 16; x++) { for (int y = 0; y <= getHeight() / 16; y++) { -// spriter.draw(GameItems.getBlock(3).getTex(), x * 16, y * 16); - spriter.draw(shade, x * 16, y * 16); + spriter.draw(background, x * 16, y * 16); } } spriter.draw(gamelogo, getWidth() / 2 - (float) gamelogo.getRegionWidth() / 2, 8); diff --git a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java index 30c346b..778a44d 100644 --- a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java @@ -16,57 +16,67 @@ import java.util.HashMap; public class Assets { public static JsonReader jsonReader = new JsonReader(); + + private static GlyphLayout glyphLayout = new GlyphLayout(); + + static BitmapFont minecraftFont; + public static Sprite[][] playerSprite = new Sprite[2][4]; + public static Sprite[][] pigSprite = new Sprite[2][2]; + public static Sprite fallingSandSprite; + public static Sprite fallingGravelSprite; public static HashMap textureRegions = new HashMap<>(); public static ArrayMap guiMap = new ArrayMap<>(); - public static Sprite[][] pigSprite = new Sprite[2][2]; - static BitmapFont minecraftFont; - private static GlyphLayout glyphLayout = new GlyphLayout(); private static TextureRegion flippedRegion(Texture texture, int x, int y, int width, int height) { return new TextureRegion(texture, x, y + height, width, -height); } + private static Sprite flippedSprite(Texture texture) { + Sprite sprite = new Sprite(texture); + sprite.flip(false, true); + return sprite; + } + + private static Sprite flippedSprite(TextureRegion texture) { + Sprite sprite = new Sprite(texture); + sprite.flip(false, true); + return sprite; + } + private static void loadPlayer() { Texture plTex = new Texture(Gdx.files.internal("mobs/char.png")); //LOOK TO LEFT //head - playerSprite[0][0] = new Sprite(new TextureRegion(plTex, 0, 0, 12, 12)); - playerSprite[0][0].flip(false, true); + playerSprite[0][0] = flippedSprite(new TextureRegion(plTex, 0, 0, 12, 12)); //body - playerSprite[0][1] = new Sprite(new TextureRegion(plTex, 0, 13, 12, 12)); - playerSprite[0][1].flip(false, true); + playerSprite[0][1] = flippedSprite(new TextureRegion(plTex, 0, 13, 12, 12)); //hand - playerSprite[0][2] = new Sprite(new TextureRegion(plTex, 25, 5, 20, 20)); - playerSprite[0][2].flip(false, true); + playerSprite[0][2] = flippedSprite(new TextureRegion(plTex, 25, 5, 20, 20)); //leg - playerSprite[0][3] = new Sprite(new TextureRegion(plTex, 25, 27, 20, 20)); - playerSprite[0][3].flip(false, true); + playerSprite[0][3] = flippedSprite(new TextureRegion(plTex, 25, 27, 20, 20)); //LOOK TO RIGHT //head - playerSprite[1][0] = new Sprite(new TextureRegion(plTex, 13, 0, 12, 12)); - playerSprite[1][0].flip(false, true); + playerSprite[1][0] = flippedSprite(new TextureRegion(plTex, 13, 0, 12, 12)); //body - playerSprite[1][1] = new Sprite(new TextureRegion(plTex, 13, 13, 12, 12)); - playerSprite[1][1].flip(false, true); + playerSprite[1][1] = flippedSprite(new TextureRegion(plTex, 13, 13, 12, 12)); //hand - playerSprite[1][2] = new Sprite(new TextureRegion(plTex, 37, 5, 20, 20)); - playerSprite[1][2].flip(false, true); + playerSprite[1][2] = flippedSprite(new TextureRegion(plTex, 37, 5, 20, 20)); //leg - playerSprite[1][3] = new Sprite(new TextureRegion(plTex, 37, 27, 20, 20)); - playerSprite[1][3].flip(false, true); + playerSprite[1][3] = flippedSprite(new TextureRegion(plTex, 37, 27, 20, 20)); } private static void loadPig() { Texture pigTex = new Texture(Gdx.files.internal("mobs/pig.png")); - pigSprite[0][0] = new Sprite(new TextureRegion(pigTex, 0, 0, 25, 12)); - pigSprite[0][0].flip(false, true); - pigSprite[1][0] = new Sprite(new TextureRegion(pigTex, 0, 12, 25, 12)); - pigSprite[1][0].flip(false, true); - pigSprite[0][1] = new Sprite(new TextureRegion(pigTex, 4, 26, 12, 12)); - pigSprite[0][1].flip(false, true); - pigSprite[1][1] = new Sprite(new TextureRegion(pigTex, 16, 26, 12, 12)); - pigSprite[1][1].flip(false, true); + pigSprite[0][0] = flippedSprite(new TextureRegion(pigTex, 0, 0, 25, 12)); + pigSprite[1][0] = flippedSprite(new TextureRegion(pigTex, 0, 12, 25, 12)); + pigSprite[0][1] = flippedSprite(new TextureRegion(pigTex, 4, 26, 12, 12)); + pigSprite[1][1] = flippedSprite(new TextureRegion(pigTex, 16, 26, 12, 12)); + } + + private static void loadFallingBlocks() { + fallingSandSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/sand.png")))); + fallingGravelSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/gravel.png")))); } /** @@ -74,15 +84,19 @@ public class Assets { * and puts to {@link #textureRegions} HashMap */ private static void loadJSON() { - JsonValue json = Assets.jsonReader.parse(Gdx.files.internal("json/texture_regions.json")); + JsonValue json = jsonReader.parse(Gdx.files.internal("json/texture_regions.json")); for (JsonValue file = json.child(); file != null; file = file.next()) { Texture texture = new Texture(Gdx.files.internal(file.name() + ".png")); - for (JsonValue key = file.child(); key != null; key = key.next()) { - int x = key.has("x") ? key.getInt("x") : 0; - int y = key.has("y") ? key.getInt("y") : 0; - int w = key.has("w") ? key.getInt("w") : texture.getWidth(); - int h = key.has("h") ? key.getInt("h") : texture.getHeight(); - textureRegions.put(key.name(), flippedRegion(texture, x, y, w, h)); + if (file.size == 0) { + textureRegions.put(file.name(), flippedRegion(texture, 0, 0, texture.getWidth(), texture.getHeight())); + } else { + for (JsonValue key = file.child(); key != null; key = key.next()) { + int x = key.has("x") ? key.getInt("x") : 0; + int y = key.has("y") ? key.getInt("y") : 0; + int w = key.has("w") ? key.getInt("w") : texture.getWidth(); + int h = key.has("h") ? key.getInt("h") : texture.getHeight(); + textureRegions.put(key.name(), flippedRegion(texture, x, y, w, h)); + } } } } @@ -92,6 +106,7 @@ public class Assets { minecraftFont.getData().setScale(.375f); loadPlayer(); loadPig(); + loadFallingBlocks(); loadJSON(); } -- 2.29.2