From: fred-boy Date: Wed, 25 Apr 2018 12:55:51 +0000 (+0700) Subject: Add more blocks X-Git-Tag: alpha0.4~101 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=4617ae53584520a741f45770e17a2a253717f83a;p=cavedroid.git Add more blocks --- diff --git a/android/assets/terrain.png b/android/assets/terrain.png index 11be603..28bfb43 100644 Binary files a/android/assets/terrain.png and b/android/assets/terrain.png differ diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 3ffc0ae..648e785 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -28,14 +28,19 @@ public class GameRenderer extends Renderer { if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); for (int y=minY; y0){ - } else if (gameProc.world.getBackMap(x,y)>0) { + if ((gameProc.world.getForeMap(x,y)==0 || Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).transparent) + && gameProc.world.getBackMap(x,y)>0) { spriteBatch.draw( - Items.BLOCKS.getValueAt(gameProc.world.getBackMap(x,y)).getTexture(), + 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) { + spriteBatch.draw( + Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture()], + x * 16 - camera.position.x,y * 16 - camera.position.y); + } } } } @@ -51,7 +56,7 @@ public class GameRenderer extends Renderer { for (int x=minX; x0) { spriteBatch.draw( - Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture(), + Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture()], x * 16 - camera.position.x,y * 16 - camera.position.y); } } @@ -119,13 +124,13 @@ public class GameRenderer extends Renderer { y+18+(gameProc.creativeScroll*(72/(gameProc.maxCreativeScroll+1)))); for (int i=gameProc.creativeScroll*40; i<(gameProc.creativeScroll+1)*40; i++) { if (i>0 && i0) - spriteBatch.draw(Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture(), + spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture()], x+8+i*18, y+Assets.creativeInv.getRegionHeight()-24); } } @@ -140,7 +145,7 @@ 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(Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture(), + spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture()], camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2+3+i*20, 3); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java index 7885d2e..0c3ac52 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -77,7 +77,7 @@ public class GameWorld { } public void placeToBackground(int x, int y, int value) { - if (value==0 || (getBackMap(x,y) == 0 && !Items.BLOCKS.getValueAt(value).foreground)) { + if (value==0 || (getBackMap(x,y) == 0 && !Items.BLOCKS.getValueAt(value).background)) { setBackMap(x,y,value); } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index e28062f..93b9a1f 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -10,24 +10,38 @@ public class Items { public static void loadBlocks() { BLOCKS.put("none", null); - BLOCKS.put("stone", new Block(0,0,16,16, Assets.blockTextures[0])); - BLOCKS.put("grass", new Block(0,0,16,16,Assets.blockTextures[1])); - BLOCKS.put("dirt", new Block(0,0,16,16,Assets.blockTextures[2])); - BLOCKS.put("cobblestone", new Block(0,0,16,16,Assets.blockTextures[3])); - BLOCKS.put("planks", new Block(0,0,16,16,Assets.blockTextures[4])); - BLOCKS.put("sapling", new Block(0,0,16,16,Assets.blockTextures[5],false,true)); - BLOCKS.put("bedrock", new Block(0,0,16,16,Assets.blockTextures[6])); - BLOCKS.put("water", new Block(0,0,16,16,Assets.blockTextures[7],false,true)); - BLOCKS.put("lava", new Block(0,0,16,16,Assets.blockTextures[8],false,true)); - BLOCKS.put("sand", new Block(0,0,16,16,Assets.blockTextures[9])); - BLOCKS.put("gravel", new Block(0,0,16,16,Assets.blockTextures[10])); - BLOCKS.put("gold_ore", new Block(0,0,16,16,Assets.blockTextures[11])); - BLOCKS.put("iron_ore", new Block(0,0,16,16,Assets.blockTextures[12])); - BLOCKS.put("coal_ore", new Block(0,0,16,16,Assets.blockTextures[13])); - BLOCKS.put("log", new Block(0,0,16,16,Assets.blockTextures[14])); - BLOCKS.put("leaves", new Block(0,0,16,16,Assets.blockTextures[15])); - BLOCKS.put("sponge", new Block(0,0,16,16,Assets.blockTextures[16])); - BLOCKS.put("glass", new Block(0,0,16,16,Assets.blockTextures[17])); + BLOCKS.put("stone", new Block(0)); + BLOCKS.put("grass", new Block(1)); + BLOCKS.put("dirt", new Block(2)); + BLOCKS.put("cobblestone", new Block(3)); + BLOCKS.put("planks", new Block(4)); + BLOCKS.put("sapling", new Block(5,false,false,true)); + BLOCKS.put("bedrock", new Block(6)); + BLOCKS.put("water", new Block(7,false,false,true)); + BLOCKS.put("lava", new Block(8,false,false,false)); + BLOCKS.put("sand", new Block(9)); + BLOCKS.put("gravel", new Block(10)); + BLOCKS.put("gold_ore", new Block(11)); + BLOCKS.put("iron_ore", new Block(12)); + BLOCKS.put("coal_ore", new Block(13)); + BLOCKS.put("log", new Block(14)); + BLOCKS.put("leaves", new Block(15)); + BLOCKS.put("sponge", new Block(16)); + BLOCKS.put("glass", new Block(17,true,false,true)); + BLOCKS.put("lapis_ore", new Block(18)); + BLOCKS.put("lapis_block", new Block(19)); + BLOCKS.put("sandstone", new Block(20)); + BLOCKS.put("noteblock", new Block(21)); + BLOCKS.put("bed", new Block(0,8,16,8,22,false,true,true)); + BLOCKS.put("cobweb", new Block(24,false,false,true)); + BLOCKS.put("tallgrass", new Block(25,false,false,true)); + BLOCKS.put("deadbush", new Block(26,false,false,true)); + BLOCKS.put("brick_block", new Block(27)); + BLOCKS.put("dandelion", new Block(28,false,false,true)); + BLOCKS.put("rose", new Block(29,false,false,true)); + BLOCKS.put("brown_mushroom", new Block(30,false,false,true)); + BLOCKS.put("red_mushroom", new Block(31,false,false,true)); + BLOCKS.put("wool", new Block(32,false,true,false)); } 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 a1696f6..4fa4736 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java @@ -6,25 +6,30 @@ import com.badlogic.gdx.math.Rectangle; public class Block { private int x,y,w,h; - private TextureRegion texture; + private int texture; - public boolean collision, foreground; + public boolean collision, background, transparent; - public Block(int x, int y, int w, int h, TextureRegion texture) { - this(x,y,w,h,texture, true, false); + public Block(int texture) { + this(0,0,16,16,texture, true, false, false); } - public Block(int x, int y, int w, int h, TextureRegion texture, boolean collision, boolean foreground) { + public Block(int texture, boolean collision, boolean background, boolean transparent) { + this(0,0,16,16,texture, collision, background, transparent); + } + + public Block(int x, int y, int w, int h, int texture, boolean collision, boolean background, boolean transparent) { this.x = x; this.y = y; this.w = w; this.h = h; this.texture = texture; this.collision = collision; - this.foreground = foreground; + this.background = background; + this.transparent = transparent; } - public TextureRegion getTexture() { + public int getTexture() { return texture; } diff --git a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java index acfad3d..da04d46 100644 --- a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java @@ -61,7 +61,7 @@ public class MenuRenderer extends Renderer { spriteBatch.begin(); for (int x=0; x<=getWidth()/16; x++) for (int y=0; y<=getHeight()/16; y++) { - spriteBatch.draw(Items.BLOCKS.get("dirt").getTexture(), x * 16, y * 16); + spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("dirt").getTexture()], x * 16, y * 16); spriteBatch.draw(Assets.shade,x*16,y*16); } spriteBatch.draw(Assets.gameLogo, getWidth()/2-Assets.gameLogo.getWidth()/2, 0); diff --git a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java index f3d1226..28f3508 100644 --- a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java @@ -10,7 +10,7 @@ import ru.deadsoftware.cavecraft.CaveGame; public class Assets { - public static final int BLOCK_TEXTURES = 18; + public static final int BLOCK_TEXTURES = 47; private static GlyphLayout layout;