From: fred-boy Date: Mon, 4 Mar 2019 18:13:33 +0000 (+0700) Subject: Move items to JSON X-Git-Tag: alpha0.4~60 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=4eb1f6f24fb76c0336394b85393e801fd0b99da4;p=cavedroid.git Move items to JSON Split textures Misc improvements --- diff --git a/android/assets/game_items.json b/android/assets/game_items.json new file mode 100644 index 0000000..0bc31cc --- /dev/null +++ b/android/assets/game_items.json @@ -0,0 +1,555 @@ +{ + "blocks": { + "none": { + "collision": false, + "transparent": true + }, + "stone": { + "hp": 450, + "drop": "cobblestone" + }, + "grass": { + "hp": 54, + "drop": "dirt" + }, + "dirt": { + "hp": 45 + }, + "cobblestone": { + "hp": 600 + }, + "planks": { + "hp": 180 + }, + "sapling": { + "hp": 0, + "collision": false, + "background": false, + "transparent": true, + "block_required": true + }, + "bedrock": { + "hp": -1 + }, + "water": { + "hp": -1, + "collision": false, + "background": false, + "transparent": true, + "fluid": true, + "meta": "water" + }, + "lava": { + "hp": -1, + "collision": false, + "background": false, + "fluid": true, + "meta": "lava" + }, + "sand": { + "hp": 45 + }, + "gravel": { + "hp": 54 + }, + "gold_ore": { + "hp": 900 + }, + "iron_ore": { + "hp": 900 + }, + "coal_ore":{ + "hp": 900, + "drop": "coal" + }, + "log": { + "hp": 180 + }, + "leaves": { + "hp": 21 + }, + "sponge": { + "hp": 54 + }, + "glass": { + "hp": 27, + "drop": "none", + "background": false, + "transparent": true + }, + "lapis_ore": { + "hp": 900, + "drop": "lapis" + }, + "lapis_block": { + "hp": 900 + }, + "sandstone": { + "hp": 240 + }, + "noteblock": { + "hp": 75 + }, + "bed_l": { + "hp": 21, + "drop": "none", + "collision": false, + "background": true, + "transparent": true + }, + "bed_r": { + "hp": 21, + "drop": "none", + "collision": false, + "background": true, + "transparent": true + }, + "web": { + "hp": 1200, + "collision": false, + "background": false, + "transparent": true + }, + "tallgrass": { + "hp": 0, + "collision": false, + "background": false, + "transparent": true, + "block_required": true + }, + "deadbush": { + "hp": 0, + "collision": false, + "background": false, + "transparent": true, + "block_required": true + }, + "bricks": { + "hp": 600 + }, + "dandelion": { + "hp": 0, + "collision": false, + "background": false, + "transparent": true, + "block_required": true + }, + "rose": { + "hp": 0, + "collision": false, + "background": false, + "transparent": true, + "block_required": true + }, + "mushroom_brown": { + "hp": 0, + "collision": false, + "background": false, + "transparent": true, + "block_required": true + }, + "mushroom_red": { + "hp": 0, + "collision": false, + "background": false, + "transparent": true, + "block_required": true + }, + "wool": { + "hp": 75 + }, + "wool_orange": { + "hp": 75 + }, + "wool_magenta": { + "hp": 75 + }, + "wool_lightblue": { + "hp": 75 + }, + "wool_yellow": { + "hp": 75 + }, + "wool_lime": { + "hp": 75 + }, + "wool_pink": { + "hp": 75 + }, + "wool_gray": { + "hp": 75 + }, + "wool_lightgray": { + "hp": 75 + }, + "wool_cyan": { + "hp": 75 + }, + "wool_purple": { + "hp": 75 + }, + "wool_blue": { + "hp": 75 + }, + "wool_brown": { + "hp": 75 + }, + "wool_green": { + "hp": 75 + }, + "wool_red": { + "hp": 75 + }, + "wool_black": { + "hp": 75 + }, + "gold_block": { + "hp": 900 + }, + "iron_block": { + "hp": 1500 + }, + "stone_slab": { + "top": 8, + "hp": 600, + "transparent": true + }, + "double_stone_slab": { + "hp": 600, + "drop": "stone_slab" + }, + "sandstone_slab": { + "top": 8, + "hp": 600, + "transparent": true + }, + "wooden_slab": { + "top": 8, + "hp": 180, + "transparent": true + }, + "cobblestone_slab": { + "top": 8, + "hp": 600, + "transparent": true + }, + "brick_slab": { + "top": 8, + "hp": 600, + "transparent": true + }, + "stonebrick": { + "hp": 450 + }, + "stonebrick_slab": { + "top": 8, + "hp": 450, + "transparent": true + }, + "cactus": { + "left": 1, + "right": 1, + "hp": 39, + "transparent": true, + "block_required": true + }, + "water_16": { + "hp": -1, + "collision": false, + "background": false, + "transparent": true, + "texture": "water", + "fluid": true, + "meta": "water" + }, + "water_12": { + "hp": -1, + "collision": false, + "background": false, + "transparent": true, + "fluid": true, + "meta": "water" + }, + "water_8": { + "hp": -1, + "collision": false, + "background": false, + "transparent": true, + "fluid": true, + "meta": "water" + }, + "water_4": { + "hp": -1, + "collision": false, + "background": false, + "transparent": true, + "fluid": true, + "meta": "water" + }, + "lava_16": { + "hp": -1, + "collision": false, + "background": false, + "texture": "lava", + "fluid": true, + "meta": "lava" + }, + "lava_12": { + "hp": -1, + "collision": false, + "background": false, + "fluid": true, + "meta": "lava" + }, + "lava_8": { + "hp": -1, + "collision": false, + "background": false, + "fluid": true, + "meta": "lava" + }, + "lava_4": { + "hp": -1, + "collision": false, + "background": false, + "fluid": true, + "meta": "lava" + }, + "obsidian": { + "hp": 1500 + } + }, + + "items": { + "none": { + "name": "", + "type": "block" + }, + "stone": { + "name": "Stone", + "type": "block" + }, + "grass": { + "name": "Grass", + "type": "block" + }, + "dirt": { + "name": "Dirt", + "type": "block" + }, + "cobblestone": { + "name": "Cobblestone", + "type": "block" + }, + "planks": { + "name": "Planks", + "type": "block" + }, + "sapling": { + "name": "Sapling", + "type": "block" + }, + "bedrock": { + "name": "Bedrock", + "type": "block" + }, + "water": { + "name": "Water", + "type": "block" + }, + "lava": { + "name": "Lava", + "type": "block" + }, + "sand": { + "name": "Sand", + "type": "block" + }, + "gravel": { + "name": "Gravel", + "type": "block" + }, + "gold_ore": { + "name": "Golden Ore", + "type": "block" + }, + "iron_ore": { + "name": "Iron Ore", + "type": "block" + }, + "coal_ore": { + "name": "Coal Ore", + "type": "block" + }, + "log": { + "name": "Wood", + "type": "block" + }, + "leaves": { + "name": "Leaves", + "type": "block" + }, + "glass": { + "name": "Glass", + "type": "block" + }, + "lapis_ore": { + "name": "Lapis Ore", + "type": "block" + }, + "lapis_block": { + "name": "Lapis Block", + "type": "block" + }, + "sandstone": { + "name": "Sandstone", + "type": "block" + }, + "web": { + "name": "Cobweb", + "type": "block" + }, + "tallgrass": { + "name": "Tall Grass", + "type": "block" + }, + "deadbush": { + "name": "Dead Bush", + "type": "block" + }, + "bricks": { + "name": "Bricks", + "type": "block" + }, + "dandelion": { + "name": "Dandelion", + "type": "block" + }, + "rose": { + "name": "Rose", + "type": "block" + }, + "mushroom_brown": { + "name": "Mushroom", + "type": "block" + }, + "mushroom_red": { + "name": "Mushroom", + "type": "block" + }, + "wool": { + "name": "Wool", + "type": "block" + }, + "wool_orange": { + "name": "Wool", + "type": "block" + }, + "wool_magenta": { + "name": "Wool", + "type": "block" + }, + "wool_lightblue": { + "name": "Wool", + "type": "block" + }, + "wool_yellow": { + "name": "Wool", + "type": "block" + }, + "wool_lime": { + "name": "Wool", + "type": "block" + }, + "wool_pink": { + "name": "Wool", + "type": "block" + }, + "wool_gray": { + "name": "Wool", + "type": "block" + }, + "wool_lightgray": { + "name": "Wool", + "type": "block" + }, + "wool_cyan": { + "name": "Wool", + "type": "block" + }, + "wool_purple": { + "name": "Wool", + "type": "block" + }, + "wool_blue": { + "name": "Wool", + "type": "block" + }, + "wool_brown": { + "name": "Wool", + "type": "block" + }, + "wool_green": { + "name": "Wool", + "type": "block" + }, + "wool_red": { + "name": "Wool", + "type": "block" + }, + "wool_black": { + "name": "Wool", + "type": "block" + }, + "gold_block": { + "name": "Gold Block", + "type": "block" + }, + "iron_block": { + "name": "Iron Block", + "type": "block" + }, + "stone_slab": { + "name": "Stone Slab", + "type": "block", + "meta": "slab" + }, + "sandstone_slab": { + "name": "Sandstone Slab", + "type": "block", + "meta": "slab" + }, + "wooden_slab": { + "name": "Wooden Slab", + "type": "block", + "meta": "slab" + }, + "cobblestone_slab": { + "name": "Cobblestone Slab", + "type": "block", + "meta": "slab" + }, + "brick_slab": { + "name": "Brick Slab", + "type": "block", + "meta": "slab" + }, + "stonebrick": { + "name": "Stone Brick", + "type": "block" + }, + "stonebrick_slab": { + "name": "Stone Brick Slab", + "type": "block", + "meta": "slab" + }, + "cactus": { + "name": "Cactus", + "type": "block" + }, + "obsidian": { + "name": "Obsidian", + "type": "block" + } + } +} \ No newline at end of file diff --git a/android/assets/textures/bed_l.png b/android/assets/textures/bed_l.png new file mode 100644 index 0000000..005a87a Binary files /dev/null and b/android/assets/textures/bed_l.png differ diff --git a/android/assets/textures/bed_r.png b/android/assets/textures/bed_r.png new file mode 100644 index 0000000..78f7285 Binary files /dev/null and b/android/assets/textures/bed_r.png differ diff --git a/android/assets/textures/bedrock.png b/android/assets/textures/bedrock.png new file mode 100644 index 0000000..1643c99 Binary files /dev/null and b/android/assets/textures/bedrock.png differ diff --git a/android/assets/textures/bookshelf.png b/android/assets/textures/bookshelf.png new file mode 100644 index 0000000..1c9a1e8 Binary files /dev/null and b/android/assets/textures/bookshelf.png differ diff --git a/android/assets/textures/brick_slab.png b/android/assets/textures/brick_slab.png new file mode 100644 index 0000000..560e8af Binary files /dev/null and b/android/assets/textures/brick_slab.png differ diff --git a/android/assets/textures/bricks.png b/android/assets/textures/bricks.png new file mode 100644 index 0000000..3fc0832 Binary files /dev/null and b/android/assets/textures/bricks.png differ diff --git a/android/assets/textures/cactus.png b/android/assets/textures/cactus.png new file mode 100644 index 0000000..9ef970d Binary files /dev/null and b/android/assets/textures/cactus.png differ diff --git a/android/assets/textures/cake.png b/android/assets/textures/cake.png new file mode 100644 index 0000000..b648028 Binary files /dev/null and b/android/assets/textures/cake.png differ diff --git a/android/assets/textures/clay.png b/android/assets/textures/clay.png new file mode 100644 index 0000000..1b673bb Binary files /dev/null and b/android/assets/textures/clay.png differ diff --git a/android/assets/textures/coal_block.png b/android/assets/textures/coal_block.png new file mode 100644 index 0000000..6d29a6e Binary files /dev/null and b/android/assets/textures/coal_block.png differ diff --git a/android/assets/textures/coal_ore.png b/android/assets/textures/coal_ore.png new file mode 100644 index 0000000..76d5741 Binary files /dev/null and b/android/assets/textures/coal_ore.png differ diff --git a/android/assets/textures/cobblestone.png b/android/assets/textures/cobblestone.png new file mode 100644 index 0000000..fd5f2f1 Binary files /dev/null and b/android/assets/textures/cobblestone.png differ diff --git a/android/assets/textures/cobblestone_mossy.png b/android/assets/textures/cobblestone_mossy.png new file mode 100644 index 0000000..f1403ea Binary files /dev/null and b/android/assets/textures/cobblestone_mossy.png differ diff --git a/android/assets/textures/cobblestone_slab.png b/android/assets/textures/cobblestone_slab.png new file mode 100644 index 0000000..7d5cf2c Binary files /dev/null and b/android/assets/textures/cobblestone_slab.png differ diff --git a/android/assets/textures/crafting_table.png b/android/assets/textures/crafting_table.png new file mode 100644 index 0000000..87c318f Binary files /dev/null and b/android/assets/textures/crafting_table.png differ diff --git a/android/assets/textures/dandelion.png b/android/assets/textures/dandelion.png new file mode 100644 index 0000000..873e3f5 Binary files /dev/null and b/android/assets/textures/dandelion.png differ diff --git a/android/assets/textures/deadbush.png b/android/assets/textures/deadbush.png new file mode 100644 index 0000000..f545cfc Binary files /dev/null and b/android/assets/textures/deadbush.png differ diff --git a/android/assets/textures/diamond_block.png b/android/assets/textures/diamond_block.png new file mode 100644 index 0000000..1dd69f8 Binary files /dev/null and b/android/assets/textures/diamond_block.png differ diff --git a/android/assets/textures/diamond_ore.png b/android/assets/textures/diamond_ore.png new file mode 100644 index 0000000..757e056 Binary files /dev/null and b/android/assets/textures/diamond_ore.png differ diff --git a/android/assets/textures/dirt.png b/android/assets/textures/dirt.png new file mode 100644 index 0000000..617d353 Binary files /dev/null and b/android/assets/textures/dirt.png differ diff --git a/android/assets/textures/double_stone_slab.png b/android/assets/textures/double_stone_slab.png new file mode 100644 index 0000000..1cf3e08 Binary files /dev/null and b/android/assets/textures/double_stone_slab.png differ diff --git a/android/assets/textures/furnace_off.png b/android/assets/textures/furnace_off.png new file mode 100644 index 0000000..c417a41 Binary files /dev/null and b/android/assets/textures/furnace_off.png differ diff --git a/android/assets/textures/furnace_on.png b/android/assets/textures/furnace_on.png new file mode 100644 index 0000000..e064201 Binary files /dev/null and b/android/assets/textures/furnace_on.png differ diff --git a/android/assets/textures/glass.png b/android/assets/textures/glass.png new file mode 100644 index 0000000..fad9138 Binary files /dev/null and b/android/assets/textures/glass.png differ diff --git a/android/assets/textures/gold_block.png b/android/assets/textures/gold_block.png new file mode 100644 index 0000000..61c5f15 Binary files /dev/null and b/android/assets/textures/gold_block.png differ diff --git a/android/assets/textures/gold_ore.png b/android/assets/textures/gold_ore.png new file mode 100644 index 0000000..2f5f22a Binary files /dev/null and b/android/assets/textures/gold_ore.png differ diff --git a/android/assets/textures/grass.png b/android/assets/textures/grass.png new file mode 100644 index 0000000..a4975e5 Binary files /dev/null and b/android/assets/textures/grass.png differ diff --git a/android/assets/textures/gravel.png b/android/assets/textures/gravel.png new file mode 100644 index 0000000..09bdcef Binary files /dev/null and b/android/assets/textures/gravel.png differ diff --git a/android/assets/textures/iron_bars.png b/android/assets/textures/iron_bars.png new file mode 100644 index 0000000..0aa0963 Binary files /dev/null and b/android/assets/textures/iron_bars.png differ diff --git a/android/assets/textures/iron_block.png b/android/assets/textures/iron_block.png new file mode 100644 index 0000000..2ac584b Binary files /dev/null and b/android/assets/textures/iron_block.png differ diff --git a/android/assets/textures/iron_ore.png b/android/assets/textures/iron_ore.png new file mode 100644 index 0000000..1e55573 Binary files /dev/null and b/android/assets/textures/iron_ore.png differ diff --git a/android/assets/textures/ladder.png b/android/assets/textures/ladder.png new file mode 100644 index 0000000..ee80fbd Binary files /dev/null and b/android/assets/textures/ladder.png differ diff --git a/android/assets/textures/lapis_block.png b/android/assets/textures/lapis_block.png new file mode 100644 index 0000000..7ecaee8 Binary files /dev/null and b/android/assets/textures/lapis_block.png differ diff --git a/android/assets/textures/lapis_ore.png b/android/assets/textures/lapis_ore.png new file mode 100644 index 0000000..04a4630 Binary files /dev/null and b/android/assets/textures/lapis_ore.png differ diff --git a/android/assets/textures/lava.png b/android/assets/textures/lava.png new file mode 100644 index 0000000..6585048 Binary files /dev/null and b/android/assets/textures/lava.png differ diff --git a/android/assets/textures/lava_12.png b/android/assets/textures/lava_12.png new file mode 100644 index 0000000..ca2bd32 Binary files /dev/null and b/android/assets/textures/lava_12.png differ diff --git a/android/assets/textures/lava_16.png b/android/assets/textures/lava_16.png new file mode 100644 index 0000000..6585048 Binary files /dev/null and b/android/assets/textures/lava_16.png differ diff --git a/android/assets/textures/lava_4.png b/android/assets/textures/lava_4.png new file mode 100644 index 0000000..1e46885 Binary files /dev/null and b/android/assets/textures/lava_4.png differ diff --git a/android/assets/textures/lava_8.png b/android/assets/textures/lava_8.png new file mode 100644 index 0000000..0b638e9 Binary files /dev/null and b/android/assets/textures/lava_8.png differ diff --git a/android/assets/textures/leaves.png b/android/assets/textures/leaves.png new file mode 100644 index 0000000..58c2104 Binary files /dev/null and b/android/assets/textures/leaves.png differ diff --git a/android/assets/textures/log.png b/android/assets/textures/log.png new file mode 100644 index 0000000..f4d1c3b Binary files /dev/null and b/android/assets/textures/log.png differ diff --git a/android/assets/textures/mushroom_brown.png b/android/assets/textures/mushroom_brown.png new file mode 100644 index 0000000..61b81d1 Binary files /dev/null and b/android/assets/textures/mushroom_brown.png differ diff --git a/android/assets/textures/mushroom_red.png b/android/assets/textures/mushroom_red.png new file mode 100644 index 0000000..6b98399 Binary files /dev/null and b/android/assets/textures/mushroom_red.png differ diff --git a/android/assets/textures/noteblock.png b/android/assets/textures/noteblock.png new file mode 100644 index 0000000..831ad73 Binary files /dev/null and b/android/assets/textures/noteblock.png differ diff --git a/android/assets/textures/obsidian.png b/android/assets/textures/obsidian.png new file mode 100644 index 0000000..74db248 Binary files /dev/null and b/android/assets/textures/obsidian.png differ diff --git a/android/assets/textures/planks.png b/android/assets/textures/planks.png new file mode 100644 index 0000000..b845983 Binary files /dev/null and b/android/assets/textures/planks.png differ diff --git a/android/assets/textures/rose.png b/android/assets/textures/rose.png new file mode 100644 index 0000000..895d78f Binary files /dev/null and b/android/assets/textures/rose.png differ diff --git a/android/assets/textures/sand.png b/android/assets/textures/sand.png new file mode 100644 index 0000000..a5d1cc1 Binary files /dev/null and b/android/assets/textures/sand.png differ diff --git a/android/assets/textures/sandstone.png b/android/assets/textures/sandstone.png new file mode 100644 index 0000000..f40d0ce Binary files /dev/null and b/android/assets/textures/sandstone.png differ diff --git a/android/assets/textures/sandstone_slab.png b/android/assets/textures/sandstone_slab.png new file mode 100644 index 0000000..83e60fc Binary files /dev/null and b/android/assets/textures/sandstone_slab.png differ diff --git a/android/assets/textures/sapling.png b/android/assets/textures/sapling.png new file mode 100644 index 0000000..17f69e1 Binary files /dev/null and b/android/assets/textures/sapling.png differ diff --git a/android/assets/textures/sponge.png b/android/assets/textures/sponge.png new file mode 100644 index 0000000..043b962 Binary files /dev/null and b/android/assets/textures/sponge.png differ diff --git a/android/assets/textures/sponge_wet.png b/android/assets/textures/sponge_wet.png new file mode 100644 index 0000000..ec79e06 Binary files /dev/null and b/android/assets/textures/sponge_wet.png differ diff --git a/android/assets/textures/stone.png b/android/assets/textures/stone.png new file mode 100644 index 0000000..5f12361 Binary files /dev/null and b/android/assets/textures/stone.png differ diff --git a/android/assets/textures/stone_slab.png b/android/assets/textures/stone_slab.png new file mode 100644 index 0000000..e970ecd Binary files /dev/null and b/android/assets/textures/stone_slab.png differ diff --git a/android/assets/textures/stonebrick.png b/android/assets/textures/stonebrick.png new file mode 100644 index 0000000..3cf3520 Binary files /dev/null and b/android/assets/textures/stonebrick.png differ diff --git a/android/assets/textures/stonebrick_slab.png b/android/assets/textures/stonebrick_slab.png new file mode 100644 index 0000000..cda6747 Binary files /dev/null and b/android/assets/textures/stonebrick_slab.png differ diff --git a/android/assets/textures/tallgrass.png b/android/assets/textures/tallgrass.png new file mode 100644 index 0000000..8a8381c Binary files /dev/null and b/android/assets/textures/tallgrass.png differ diff --git a/android/assets/textures/water.png b/android/assets/textures/water.png new file mode 100644 index 0000000..9fff324 Binary files /dev/null and b/android/assets/textures/water.png differ diff --git a/android/assets/textures/water_12.png b/android/assets/textures/water_12.png new file mode 100644 index 0000000..24f9187 Binary files /dev/null and b/android/assets/textures/water_12.png differ diff --git a/android/assets/textures/water_16.png b/android/assets/textures/water_16.png new file mode 100644 index 0000000..9fff324 Binary files /dev/null and b/android/assets/textures/water_16.png differ diff --git a/android/assets/textures/water_4.png b/android/assets/textures/water_4.png new file mode 100644 index 0000000..e6a9432 Binary files /dev/null and b/android/assets/textures/water_4.png differ diff --git a/android/assets/textures/water_8.png b/android/assets/textures/water_8.png new file mode 100644 index 0000000..4dc9f38 Binary files /dev/null and b/android/assets/textures/water_8.png differ diff --git a/android/assets/textures/web.png b/android/assets/textures/web.png new file mode 100644 index 0000000..d72a13c Binary files /dev/null and b/android/assets/textures/web.png differ diff --git a/android/assets/textures/wooden_slab.png b/android/assets/textures/wooden_slab.png new file mode 100644 index 0000000..51d4452 Binary files /dev/null and b/android/assets/textures/wooden_slab.png differ diff --git a/android/assets/textures/wool.png b/android/assets/textures/wool.png new file mode 100644 index 0000000..fa2c56e Binary files /dev/null and b/android/assets/textures/wool.png differ diff --git a/android/assets/textures/wool_black.png b/android/assets/textures/wool_black.png new file mode 100644 index 0000000..0e486b0 Binary files /dev/null and b/android/assets/textures/wool_black.png differ diff --git a/android/assets/textures/wool_blue.png b/android/assets/textures/wool_blue.png new file mode 100644 index 0000000..14c5d71 Binary files /dev/null and b/android/assets/textures/wool_blue.png differ diff --git a/android/assets/textures/wool_brown.png b/android/assets/textures/wool_brown.png new file mode 100644 index 0000000..ffaa750 Binary files /dev/null and b/android/assets/textures/wool_brown.png differ diff --git a/android/assets/textures/wool_cyan.png b/android/assets/textures/wool_cyan.png new file mode 100644 index 0000000..6545f38 Binary files /dev/null and b/android/assets/textures/wool_cyan.png differ diff --git a/android/assets/textures/wool_gray.png b/android/assets/textures/wool_gray.png new file mode 100644 index 0000000..1d12e2d Binary files /dev/null and b/android/assets/textures/wool_gray.png differ diff --git a/android/assets/textures/wool_green.png b/android/assets/textures/wool_green.png new file mode 100644 index 0000000..f8bc1ef Binary files /dev/null and b/android/assets/textures/wool_green.png differ diff --git a/android/assets/textures/wool_lightblue.png b/android/assets/textures/wool_lightblue.png new file mode 100644 index 0000000..529c92a Binary files /dev/null and b/android/assets/textures/wool_lightblue.png differ diff --git a/android/assets/textures/wool_lightgray.png b/android/assets/textures/wool_lightgray.png new file mode 100644 index 0000000..f7f1353 Binary files /dev/null and b/android/assets/textures/wool_lightgray.png differ diff --git a/android/assets/textures/wool_lime.png b/android/assets/textures/wool_lime.png new file mode 100644 index 0000000..e106780 Binary files /dev/null and b/android/assets/textures/wool_lime.png differ diff --git a/android/assets/textures/wool_magenta.png b/android/assets/textures/wool_magenta.png new file mode 100644 index 0000000..b9700a8 Binary files /dev/null and b/android/assets/textures/wool_magenta.png differ diff --git a/android/assets/textures/wool_orange.png b/android/assets/textures/wool_orange.png new file mode 100644 index 0000000..61c1e4b Binary files /dev/null and b/android/assets/textures/wool_orange.png differ diff --git a/android/assets/textures/wool_pink.png b/android/assets/textures/wool_pink.png new file mode 100644 index 0000000..17ef62b Binary files /dev/null and b/android/assets/textures/wool_pink.png differ diff --git a/android/assets/textures/wool_purple.png b/android/assets/textures/wool_purple.png new file mode 100644 index 0000000..08d4ee0 Binary files /dev/null and b/android/assets/textures/wool_purple.png differ diff --git a/android/assets/textures/wool_red.png b/android/assets/textures/wool_red.png new file mode 100644 index 0000000..f11cbcc Binary files /dev/null and b/android/assets/textures/wool_red.png differ diff --git a/android/assets/textures/wool_yellow.png b/android/assets/textures/wool_yellow.png new file mode 100644 index 0000000..fba2787 Binary files /dev/null and b/android/assets/textures/wool_yellow.png differ diff --git a/android/build.gradle b/android/build.gradle index 70bf455..ef956e0 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -33,6 +33,7 @@ android { applicationIdSuffix ".debug" } } + } diff --git a/core/src/ru/deadsoftware/cavedroid/GameScreen.java b/core/src/ru/deadsoftware/cavedroid/GameScreen.java index 6b5382e..d30adba 100644 --- a/core/src/ru/deadsoftware/cavedroid/GameScreen.java +++ b/core/src/ru/deadsoftware/cavedroid/GameScreen.java @@ -11,7 +11,7 @@ import ru.deadsoftware.cavedroid.misc.*; public class GameScreen implements Screen { public static int FPS; - public static boolean SHOW_DEBUG = false; + public static boolean SHOW_DEBUG = true; public static int NEW_GAME_MODE = 0; public static GameProc GP; @@ -92,8 +92,8 @@ 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); + Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer)); renderer = menuRenderer; break; case GAME_PLAY: diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java index 6c511a4..1bbb03c 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java @@ -1,42 +1,74 @@ package ru.deadsoftware.cavedroid.game; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.utils.ArrayMap; +import com.badlogic.gdx.utils.JsonReader; +import com.badlogic.gdx.utils.JsonValue; import ru.deadsoftware.cavedroid.game.objects.Block; import ru.deadsoftware.cavedroid.game.objects.Item; -import java.util.ArrayList; +import java.util.HashMap; public class GameItems { + private static HashMap blocksIds = new HashMap(); + private static HashMap itemsIds = new HashMap(); + private static ArrayMap blocks = new ArrayMap(); - private static ArrayList items = new ArrayList(); + private static ArrayMap items = new ArrayMap(); + + public static boolean isFluid(int id) { + return getBlock(id).isFluid(); + } + + public static boolean isWater(int id) { + return getBlock(id).getMeta().equals("water"); + } + + public static boolean isLava(int id) { + return getBlock(id).getMeta().equals("lava"); + } + + public static boolean isSlab(int id) { + return getBlock(id).getMeta().equals("slab"); + } + + public static Block getBlock(int id) { + return blocks.getValueAt(id); + } + + public static Item getItem(int id) { + return items.getValueAt(id); + } - public static boolean isFluid(int bl) { - return isWater(bl) || isLava(bl); + public static Block getBlock(String key) { + return blocks.getValueAt(blocksIds.get(key)); } - public static boolean isWater(int bl) { - return (bl == 8 || bl == 60 || bl == 61 || bl == 62 || bl == 63); + public static Item getItem(String key) { + return items.getValueAt(itemsIds.get(key)); } - public static boolean isLava(int bl) { - return (bl == 9 || bl == 64 || bl == 65 || bl == 66 || bl == 67); + public static int getBlockId(String key) { + return blocksIds.get(key); } - public static boolean isSlab(int bl) { - return (bl == 51 || bl == 53 || bl == 54 || bl == 55 || bl == 56 || bl == 58); + public static int getItemId(String key) { + return itemsIds.get(key); } public static String getBlockKey(int id) { return blocks.getKeyAt(id); } - public static Block getBlock(int id) { - return blocks.getValueAt(id); + public static String getItemKey(int id) { + return items.getKeyAt(id); } - public static Item getItem(int id) { - return items.get(id); + public static int getBlockIdByItemId(int id) { + return getBlockId(items.getKeyAt(id)); } public static int getBlocksSize() { @@ -44,291 +76,54 @@ public class GameItems { } public static int getItemsSize() { - return items.size(); + return items.size; } - public static void loadItems() { - //0 - items.add(null); - //1 - items.add(new Item("Stone", 0, 0, 1)); - //2 - items.add(new Item("Grass", 1, 0, 2)); - //3 - items.add(new Item("Dirt", 2, 0, 3)); - //4 - items.add(new Item("Cobblestone", 3, 0, 4)); - //5 - items.add(new Item("Planks", 4, 0, 5)); - //6 - items.add(new Item("Sapling", 5, 0, 6)); - //7 - items.add(new Item("Bedrock", 6, 0, 7)); - //8 - items.add(new Item("Sand", 9, 0, 10)); - //9 - items.add(new Item("Gravel", 10, 0, 11)); - //10 - items.add(new Item("Golden Ore", 11, 0, 12)); - //11 - items.add(new Item("Iron Ore", 12, 0, 13)); - //12 - items.add(new Item("Coal Ore", 13, 0, 14)); - //13 - items.add(new Item("Wood", 14, 0, 15)); - //14 - items.add(new Item("Leaves", 15, 0, 16)); - //15 - items.add(new Item("Glass", 17, 0, 18)); - //16 - items.add(new Item("Lapis Ore", 18, 0, 19)); - //17 - items.add(new Item("Lapis Block", 19, 0, 20)); - //18 - items.add(new Item("Sandstone", 20, 0, 21)); - //19 - items.add(new Item("Cobweb", 24, 0, 25)); - //20 - items.add(new Item("Tall Grass", 25, 0, 26)); - //21 - items.add(new Item("Dead Bush", 26, 0, 27)); - //22 - items.add(new Item("Bricks", 27, 0, 28)); - //23 - items.add(new Item("Dandelion", 28, 0, 29)); - //24 - items.add(new Item("Rose", 29, 0, 30)); - //25 - items.add(new Item("Mushroom", 30, 0, 31)); - //26 - items.add(new Item("Mushroom", 31, 0, 32)); - //27 - items.add(new Item("White Wool", 32, 0, 33)); - //28 - items.add(new Item("Orange Wool", 33, 0, 34)); - //29 - items.add(new Item("Magenta Wool", 34, 0, 35)); - //30 - items.add(new Item("Light Blue Wool", 35, 0, 36)); - //31 - items.add(new Item("Yellow Wool", 36, 0, 37)); - //32 - items.add(new Item("Lime Wool", 37, 0, 38)); - //33 - items.add(new Item("Pink Wool", 38, 0, 39)); - //34 - items.add(new Item("Gray Wool", 39, 0, 40)); - //35 - items.add(new Item("Light Gray Wool", 40, 0, 41)); - //36 - items.add(new Item("Cyan Wool", 41, 0, 42)); - //37 - items.add(new Item("Purple Wool", 42, 0, 43)); - //38 - items.add(new Item("Blue Wool", 43, 0, 44)); - //39 - items.add(new Item("Brown Wool", 44, 0, 45)); - //40 - items.add(new Item("Green Wool", 45, 0, 46)); - //41 - items.add(new Item("Red Wool", 46, 0, 47)); - //42 - items.add(new Item("Black Wool", 47, 0, 48)); - //43 - items.add(new Item("Golden Block", 48, 0, 49)); - //44 - items.add(new Item("Iron Block", 49, 0, 50)); - //45 - items.add(new Item("Stone Slab", 50, 0, 51)); - //46 - items.add(new Item("Sandstone Slab", 52, 0, 53)); - //47 - items.add(new Item("Wooden Slab", 53, 0, 54)); - //48 - items.add(new Item("Cobblestone Slab", 54, 0, 55)); - //49 - items.add(new Item("Brick Slab", 55, 0, 56)); - //50 - items.add(new Item("Stone Brick", 64, 0, 57)); - //51 - 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)); - //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)); - //64 - items.add(new Item("Empty Bucket", 10, 2)); - //65 - items.add(new Item("Water Bucket", 11, 2)); - //66 - items.add(new Item("Lava Bucket", 12, 2)); - + public static Sprite getBlockTex(int id) { + return getBlock(id).getTex(); } - public static void loadBlocks() { - //0 - blocks.put("none", null); - //1 - blocks.put("stone", new Block(0, 450, 4)); - //2 - blocks.put("grass", new Block(1, 54, 3)); - //3 - blocks.put("dirt", new Block(2, 45, 3)); - //4 - blocks.put("cobblestone", new Block(3, 600, 4)); - //5 - blocks.put("planks", new Block(4, 180, 5)); - //6 - blocks.put("sapling", new Block(5, 0, 6, false, false, true, true)); - //7 - blocks.put("bedrock", new Block(6, -1, 7)); - //8 - blocks.put("water", new Block(7, -1, 0, false, false, true)); - //9 - blocks.put("lava", new Block(8, -1, 0, false, false, false)); - //10 - blocks.put("sand", new Block(9, 45, 8)); - //11 - blocks.put("gravel", new Block(10, 54, 9)); - //12 - blocks.put("gold_ore", new Block(11, 900, 10)); - //13 - blocks.put("iron_ore", new Block(12, 900, 11)); - //14 - blocks.put("coal_ore", new Block(13, 900, 0)); - //15 - blocks.put("log", new Block(14, 180, 13)); - //16 - blocks.put("leaves", new Block(15, 21, 0)); - //17 - blocks.put("sponge", new Block(16, 54, 0)); - //18 - blocks.put("glass", new Block(17, 27, 0, true, false, true)); - //19 - blocks.put("lapis_ore", new Block(18, 900, 0)); - //20 - blocks.put("lapis_block", new Block(19, 900, 17)); - //21 - blocks.put("sandstone", new Block(20, 240, 18)); - //22 - blocks.put("noteblock", new Block(21, 75, 0)); - //23 - 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)); - //25 - blocks.put("cobweb", new Block(24, 1200, 0, false, false, true)); - //26 - blocks.put("tallgrass", new Block(25, 0, 0, false, false, true, true)); - //27 - blocks.put("deadbush", new Block(26, 0, 0, false, false, true, true)); - //28 - blocks.put("brick_block", new Block(27, 600, 22)); - //29 - blocks.put("dandelion", new Block(28, 0, 23, false, false, true, true)); - //30 - blocks.put("rose", new Block(29, 0, 24, false, false, true, true)); - //31 - blocks.put("brown_mushroom", new Block(30, 0, 25, false, false, true, true)); - //32 - blocks.put("red_mushroom", new Block(31, 0, 26, false, false, true, true)); - //33 - 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)); - //35 - 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)); - //37 - 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)); - //39 - 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)); - //41 - 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)); - //43 - 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)); - //45 - 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)); - //47 - 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)); - //49 - blocks.put("gold_block", new Block(48, 900, 43)); - //50 - 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)); - //52 - 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)); - //54 - 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)); - //56 - 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)); - //58 - 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, true)); - //60 - 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)); - //62 - 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)); - //64 - 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)); - //66 - 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)); - //68 - blocks.put("obsidian", new Block(65, 1500, 53)); + public static Sprite getItemTex(int id) { + if (items.getValueAt(id).getType().equals("block")) return getBlockTex(id); + else return getItem(id).getTex(); } public static void load() { - loadBlocks(); - loadItems(); + JsonValue json = new JsonReader().parse(Gdx.files.internal("game_items.json")); + JsonValue block = json.child.child; + JsonValue item = json.child.next.child; + while (block != null) { + String key = block.name; + int left = (block.has("left") ? block.getInt("left") : 0); + int right = (block.has("right") ? block.getInt("right") : 0); + int top = (block.has("top") ? block.getInt("top") : 0); + int bottom = (block.has("bottom") ? block.getInt("bottom") : 0); + int hp = (block.has("hp") ? block.getInt("hp") : -1); + String drop = (block.has("drop") ? block.getString("drop") : key); + boolean collision = (!block.has("collision") || block.getBoolean("collision")); + boolean background = (block.has("background") && block.getBoolean("background")); + boolean transparent = !(!block.has("collision") || block.getBoolean("collision")); + boolean blockRequired = (block.has("block_required") && block.getBoolean("block_required")); + boolean fluid = (block.has("fluid") && block.getBoolean("fluid")); + String meta = (block.has("meta") ? block.getString("meta") : ""); + String texture = (block.has("texture") ? block.getString("texture") : key); + blocksIds.put(key, blocks.size); + blocks.put(key, new Block(left, top, right, bottom, hp, drop, collision, + background, transparent, blockRequired, fluid, meta, + key.equals("none") ? null : + new Sprite(new Texture(Gdx.files.internal("textures/" + texture + ".png"))))); + block = block.next(); + } + while (item != null) { + String key = item.name; + String name = (item.has("name") ? item.getString("name") : key); + String type = (item.has("type") ? item.getString("type") : "item"); + String texture = (item.has("texture") ? item.getString("texture") : key); + itemsIds.put(key, items.size); + items.put(key, new Item(name, type, type.equals("block") ? null : + new Sprite(new Texture(Gdx.files.internal("textures/" + texture + ".png"))))); + item = item.next(); + } } -} +} \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java index fb0d6ed..8678404 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java @@ -135,7 +135,7 @@ class GamePhysics { if (!pl.flyMode && pl.mov.y < 18) pl.mov.add(gravity); } - pl.pos.x += pl.mov.x; + pl.pos.x += pl.mov.x * (pl.flyMode ? 1.5f : 1) * (GameItems.isFluid(getBlock(pl.getRect())) && !pl.flyMode ? .8f : 1); mobXColl(pl); if (CaveGame.TOUCH && checkJump(pl.getRect(), pl.getDir()) && !pl.flyMode && pl.canJump && pl.mov.x != 0) { diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java index aa11931..cd957a0 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java @@ -58,6 +58,14 @@ public class GameProc implements Serializable { 480 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } maxCreativeScroll = GameItems.getItemsSize() / 8; + + new Thread(new Runnable() { + @Override + public void run() { + while (true) fluidUpdater(); + } + }).start(); + GameSaver.save(this); } @@ -362,7 +370,7 @@ public class GameProc implements Serializable { if (world.getForeMap(x, y) > 0 && GameItems.getBlock(world.getForeMap(x, y)).requiresBlock()) { if (world.getForeMap(x, y + 1) == 0 || !GameItems.getBlock(world.getForeMap(x, y + 1)).hasCollision()) { - world.destroyForeMap(x, y, this); + world.destroyForeMap(x, y); updateBlock(x, y - 1); } } @@ -375,14 +383,20 @@ public class GameProc implements Serializable { } } + private void fluidUpdater() { + for (int y = 0; y < world.getHeight(); y++) { + for (int x = (int) renderer.getCamX() / 16 - 1; x < (int) (renderer.getCamX() + renderer.getWidth()) / 16 + 1; x++) { + updateFluids(x, y); + } + } + } + void useItem(int x, int y, int id, boolean bg) { if (id > 0) { - switch (GameItems.getItem(id).getType()) { - case 0: - if (!bg) world.placeToForeground(x, y, GameItems.getItem(id).getBlock()); - else world.placeToBackground(x, y, GameItems.getItem(id).getBlock()); - break; - case 2: + if (GameItems.getItem(id).isBlock()) { + if (!bg) world.placeToForeground(x, y, GameItems.getBlockIdByItemId(id)); + else world.placeToBackground(x, y, GameItems.getBlockIdByItemId(id)); + } else { switch (id) { case 65: world.placeToForeground(x, y, 8); @@ -393,7 +407,6 @@ public class GameProc implements Serializable { player.inv[player.invSlot] = 64; break; } - break; } } } @@ -407,12 +420,6 @@ public class GameProc implements Serializable { DO_UPD = false; } - for (int y = 0; y < world.getHeight(); y++) { - for (int x = (int) renderer.getCamX() / 16 - 1; x < (int) (renderer.getCamX() + renderer.getWidth()) / 16 + 1; x++) { - updateFluids(x, y); - } - } - physics.update(delta); moveCursor(); checkCursorBounds(); @@ -426,12 +433,12 @@ public class GameProc implements Serializable { blockDmg++; if (world.getForeMap(curX, curY) > 0) { if (blockDmg >= GameItems.getBlock(world.getForeMap(curX, curY)).getHp()) { - world.destroyForeMap(curX, curY, this); + world.destroyForeMap(curX, curY); blockDmg = 0; } } else if (world.getBackMap(curX, curY) > 0) { if (blockDmg >= GameItems.getBlock(world.getBackMap(curX, curY)).getHp()) { - world.destroyBackMap(curX, curY, this); + world.destroyBackMap(curX, curY); blockDmg = 0; } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java index 1229fcb..a34f0c8 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java @@ -41,17 +41,13 @@ public class GameRenderer extends Renderer { if (drawBG) { if ((GP.world.getForeMap(x, y) == 0 || GameItems.getBlock(GP.world.getForeMap(x, y)).isTransparent()) && GP.world.getBackMap(x, y) > 0) { - spriter.draw( - Assets.blockTex[GameItems.getBlock(GP.world.getBackMap(x, y)).getTex()], - drawX(x), drawY(y)); + spriter.draw(GameItems.getBlock(GP.world.getBackMap(x, y)).getTex(), drawX(x), drawY(y)); if (GP.world.getForeMap(x, y) == 0 && x == GP.curX && y == GP.curY) drawWreck(GP.world.getBackMap(GP.curX, GP.curY)); } } if (GP.world.getForeMap(x, y) > 0 && GameItems.getBlock(GP.world.getForeMap(x, y)).isBackground() == drawBG) { - spriter.draw( - Assets.blockTex[GameItems.getBlock(GP.world.getForeMap(x, y)).getTex()], - drawX(x), drawY(y)); + spriter.draw(GameItems.getBlock(GP.world.getForeMap(x, y)).getTex(), drawX(x), drawY(y)); if (x == GP.curX && y == GP.curY) drawWreck(GP.world.getForeMap(GP.curX, GP.curY)); } @@ -102,21 +98,6 @@ public class GameRenderer extends Renderer { } private void drawDrop(Drop drop) { - switch (GameItems.getItem(drop.getId()).getType()) { - case 0: - Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition( - drop.pos.x - getCamX() - GP.world.getWidthPx(), - drop.pos.y - getCamY()); - Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter); - Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition( - drop.pos.x - getCamX(), - drop.pos.y - getCamY()); - Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter); - Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition( - drop.pos.x - getCamX() + GP.world.getWidthPx(), - drop.pos.y - getCamY()); - Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter); - } } @SuppressWarnings("IntegerDivisionInFloatingPointContext") @@ -128,34 +109,27 @@ public class GameRenderer extends Renderer { y + 18 + (GP.creativeScroll * (72f / GP.maxCreativeScroll))); for (int i = GP.creativeScroll * 8; i < GP.creativeScroll * 8 + 40; i++) { if (i > 0 && i < GameItems.getItemsSize()) - switch (GameItems.getItem(i).getType()) { - case 0: - spriter.draw(Assets.blockTex[GameItems.getItem(i).getTex()], - x + 8 + ((i - GP.creativeScroll * 8) % 8) * 18, - y + 18 + ((i - GP.creativeScroll * 8) / 8) * 18); - break; - case 1: - case 2: - spriter.draw(Assets.itemTex[GameItems.getItem(i).getTex()], - x + 8 + ((i - GP.creativeScroll * 8) % 8) * 18, - y + 18 + ((i - GP.creativeScroll * 8) / 8) * 18); - break; + if (GameItems.getItem(i).isBlock()) { + spriter.draw(GameItems.getBlock(GameItems.getBlockIdByItemId(i)).getTex(), + x + 8 + ((i - GP.creativeScroll * 8) % 8) * 18, + y + 18 + ((i - GP.creativeScroll * 8) / 8) * 18); + } else { + spriter.draw(GameItems.getItem(i).getTex(), + x + 8 + ((i - GP.creativeScroll * 8) % 8) * 18, + y + 18 + ((i - GP.creativeScroll * 8) / 8) * 18); } } for (int i = 0; i < 9; i++) { if (GP.player.inv[i] > 0) - switch (GameItems.getItem(GP.player.inv[i]).getType()) { - case 0: - spriter.draw(Assets.blockTex[GameItems.getItem(GP.player.inv[i]).getTex()], - x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); - break; - case 1: - case 2: - spriter.draw(Assets.itemTex[GameItems.getItem(GP.player.inv[i]).getTex()], - x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); - break; + if (GameItems.getItem(GP.player.inv[i]).isBlock()) { + spriter.draw(GameItems.getBlock(GameItems.getBlockIdByItemId(GP.player.inv[i])).getTex(), + x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); + } else { + spriter.draw(GameItems.getItem(GP.player.inv[i]).getTex(), + x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); } } + } private void drawGUI() { @@ -169,18 +143,14 @@ public class GameRenderer extends Renderer { spriter.draw(Assets.invBar, getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2, 0); for (int i = 0; i < 9; i++) { if (GP.player.inv[i] > 0) { - switch (GameItems.getItem(GP.player.inv[i]).getType()) { - case 0: - spriter.draw(Assets.blockTex[GameItems.getItem(GP.player.inv[i]).getTex()], - getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, - 3); - break; - case 1: - case 2: - spriter.draw(Assets.itemTex[GameItems.getItem(GP.player.inv[i]).getTex()], - getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, - 3); - break; + if (GameItems.getItem(GP.player.inv[i]).isBlock()) { + spriter.draw(GameItems.getBlock(GameItems.getBlockIdByItemId(GP.player.inv[i])).getTex(), + getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, + 3); + } else { + spriter.draw(GameItems.getItem(GP.player.inv[i]).getTex(), + getWidth() / 2 - (float) Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, + 3); } } } @@ -198,8 +168,7 @@ public class GameRenderer extends Renderer { spriter.draw(Assets.touchRMB, getWidth() - 26, getHeight() - 26); spriter.draw(Assets.touchMode, 78, getHeight() - 26); if (GP.ctrlMode == 1) { - Assets.shade.setPosition(83, getHeight() - 21); - Assets.shade.draw(spriter); + spriter.draw(Assets.shade, 83, getHeight() - 21); } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java b/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java index 6aefd89..89c4585 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java @@ -1,7 +1,10 @@ package ru.deadsoftware.cavedroid.game; +import ru.deadsoftware.cavedroid.game.objects.Block; import ru.deadsoftware.cavedroid.game.objects.Drop; +import static ru.deadsoftware.cavedroid.GameScreen.GP; + public class GameWorld { private int WIDTH, HEIGHT; @@ -43,7 +46,7 @@ public class GameWorld { try { x = transformX(x); map = (layer == 0) ? foreMap[x][y] : backMap[x][y]; - } catch (ArrayIndexOutOfBoundsException e) { + } catch (ArrayIndexOutOfBoundsException ignored) { } return map; } @@ -53,24 +56,36 @@ public class GameWorld { x = transformX(x); if (layer == 0) foreMap[x][y] = value; else backMap[x][y] = value; - } catch (ArrayIndexOutOfBoundsException e) { + } catch (ArrayIndexOutOfBoundsException ignored) { } } + public boolean hasBlockAt(int x, int y) { + return getMap(x, y, 0) != 0; + } + public int getForeMap(int x, int y) { return getMap(x, y, 0); } - public void setForeMap(int x, int y, int value) { - setMap(x, y, 0, value); + public Block getForeMapBlock(int x, int y) { + return GameItems.getBlock(getMap(x, y, 0)); + } + + public void setForeMap(int x, int y, int id) { + setMap(x, y, 0, id); } public int getBackMap(int x, int y) { return getMap(x, y, 1); } - public void setBackMap(int x, int y, int value) { - setMap(x, y, 1, value); + public Block getBackMapBlock(int x, int y) { + return GameItems.getBlock(getMap(x, y, 1)); + } + + public void setBackMap(int x, int y, int id) { + setMap(x, y, 1, id); } private void placeSlab(int x, int y, int value) { @@ -97,7 +112,7 @@ public class GameWorld { } public void placeToForeground(int x, int y, int value) { - if (getForeMap(x, y) == 0 || value == 0 || !GameItems.getBlock(getForeMap(x, y)).hasCollision()) { + if (!hasBlockAt(x, y) || value == 0 || !GameItems.getBlock(getForeMap(x, y)).hasCollision()) { setForeMap(x, y, value); } else if (GameItems.isSlab(value) && getForeMap(x, y) == value) { placeSlab(x, y, value); @@ -114,15 +129,17 @@ public class GameWorld { } } - public void destroyForeMap(int x, int y, GameProc gp) { - if (GameItems.getBlock(getForeMap(x, y)).getDrop() > 0) - gp.drops.add(new Drop(transformX(x) * 16 + 4, y * 16 + 4, GameItems.getBlock(getForeMap(x, y)).getDrop())); + public void destroyForeMap(int x, int y) { + if (GameItems.getBlock(getForeMap(x, y)).hasDrop()) + GP.drops.add(new Drop(transformX(x) * 16 + 4, y * 16 + 4, + GameItems.getItemId(GameItems.getBlock(getForeMap(x, y)).getDrop()))); placeToForeground(x, y, 0); } - public void destroyBackMap(int x, int y, GameProc gp) { - if (GameItems.getBlock(getBackMap(x, y)).getDrop() > 0) - gp.drops.add(new Drop(transformX(x) * 16 + 4, y * 16 + 4, GameItems.getBlock(getBackMap(x, y)).getDrop())); + public void destroyBackMap(int x, int y) { + if (GameItems.getBlock(getBackMap(x, y)).hasDrop()) + GP.drops.add(new Drop(transformX(x) * 16 + 4, y * 16 + 4, + GameItems.getItemId(GameItems.getBlock(getBackMap(x, y)).getDrop()))); placeToBackground(x, y, 0); } @@ -135,11 +152,11 @@ public class GameWorld { WorldGen.clear(); } - public void setMaps(int[][] foreMap, int[][] backMap) { + void setMaps(int[][] foreMap, int[][] backMap) { this.foreMap = foreMap.clone(); this.backMap = backMap.clone(); WIDTH = foreMap.length; HEIGHT = foreMap[0].length; } -} +} \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java index f30faef..93d0b6f 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java @@ -22,7 +22,7 @@ public class FallingGravel extends Mob { @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(Assets.blockTex[GameItems.getBlock(11).getTex()], x, y); + spriteBatch.draw(GameItems.getBlock("gravel").getTex(), 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 6194e4e..cfd5f9b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java @@ -22,7 +22,7 @@ public class FallingSand extends Mob { @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(Assets.blockTex[GameItems.getBlock(10).getTex()], x, y); + spriteBatch.draw(GameItems.getBlock("sand").getTex(), x, y); } @Override diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java index defbd3b..2a44916 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java @@ -1,44 +1,34 @@ package ru.deadsoftware.cavedroid.game.objects; +import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.math.Rectangle; public class Block { private int x, y, w, h; - private int tex; - private int hp, drop; + private int hp; + private String drop, meta; + private Sprite tex; //coll - collision, bg - background, tp - transparent, rb - requires block under it - private boolean coll, bg, tp, rb; - - public Block(int tex, int hp, int drop) { - this(0, 0, 16, 16, tex, hp, drop, true, false, false, false); - } - - public Block(int tex, int hp, int drop, boolean coll, boolean bg, boolean tp) { - this(0, 0, 16, 16, tex, hp, drop, coll, bg, tp, false); - } - - public Block(int tex, int hp, int drop, boolean coll, boolean bg, boolean tp, boolean rb) { - this(0, 0, 16, 16, tex, hp, drop, coll, bg, tp, rb); - } - - public Block(int x, int y, int w, int h, int tex, int hp, int drop, boolean coll, boolean bg, boolean tp) { - this(x, y, w, h, tex, hp, drop, coll, bg, tp, false); - } - - public Block(int x, int y, int w, int h, int tex, int hp, int drop, boolean coll, boolean bg, boolean tp, boolean rb) { - this.x = x; - this.y = y; - this.w = w; - this.h = h; - this.tex = tex; + private boolean coll, bg, tp, rb, fluid; + + public Block(int left, int top, int right, int bottom, int hp, + String drop, boolean coll, boolean bg, boolean tp, boolean rb, boolean fluid, String meta, Sprite tex) { + this.x = left; + this.y = top; + this.w = 16 - right - left; + this.h = 16 - top - bottom; this.hp = hp; this.drop = drop; this.coll = coll; this.bg = bg; this.tp = tp; this.rb = rb; + this.fluid = fluid; + this.meta = meta; + this.tex = tex; + if (this.tex != null) this.tex.flip(false, true); } public boolean hasCollision() { @@ -57,26 +47,38 @@ public class Block { return rb; } - public int getTex() { - return tex; - } - public int getHp() { return hp; } - public int getDrop() { + public String getDrop() { return drop; } + public boolean hasDrop() { + return !drop.equals("none"); + } + + public Sprite getTex() { + return tex; + } + public Rectangle getRect(int x, int y) { x *= 16; y *= 16; return new Rectangle(x + this.x, y + this.y, w, h); } + public boolean isFluid() { + return fluid; + } + + public String getMeta() { + return meta; + } + public boolean toJump() { return (y < 8 && coll); } -} +} \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java index 3d082bf..a619a1b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java @@ -1,37 +1,33 @@ package ru.deadsoftware.cavedroid.game.objects; -public class Item { +import com.badlogic.gdx.graphics.g2d.Sprite; - private int tex; - private int type; // 0 - block, 1 - tool, 2 - other - private int block; - private String name; +public class Item { - public Item(String name, int tex, int type) { - this(name, tex, type, -1); - } + private String name, type; + private Sprite tex; - public Item(String name, int tex, int type, int block) { + public Item(String name, String type, Sprite tex) { this.name = name; - this.tex = tex; this.type = type; - this.block = block; + this.tex = tex; + if (this.tex != null) this.tex.flip(false, true); } - public int getTex() { + public Sprite getTex() { return tex; } - public int getType() { + public String getType() { return type; } - public int getBlock() { - return block; + public boolean isBlock() { + return type.equals("block"); } public String getName() { return name; } -} +} \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java index 5fd04f9..1459506 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java @@ -86,28 +86,6 @@ public class Player extends Mob implements Serializable { spriteBatch.draw(Assets.plSprite[getDir()][0], x - 2, y - 2); //body spriteBatch.draw(Assets.plSprite[getDir()][1], x - 2, y + 8); - //item in hand - if (inv[invSlot] > 0) { - float handRotation = MathUtils.degRad * Assets.plSprite[0][2].getRotation(); - switch (GameItems.getItem(inv[invSlot]).getType()) { - case 0: - Assets.blockTex[GameItems.getItem(inv[invSlot]).getTex()].setPosition( - x - 8 * MathUtils.sin(handRotation), - y + 6 + 8 * MathUtils.cos(handRotation)); - Assets.blockTex[GameItems.getItem(inv[invSlot]).getTex()].draw(spriteBatch); - break; - default: - Assets.itemTex[GameItems.getItem(inv[invSlot]).getTex()].flip((getDir() == 0), false); - Assets.itemTex[GameItems.getItem(inv[invSlot]).getTex()].setRotation( - -45 + getDir() * 90 + Assets.plSprite[0][2].getRotation()); - Assets.itemTex[GameItems.getItem(inv[invSlot]).getTex()].setPosition( - x - 10 + (12 * getDir()) - 8 * MathUtils.sin(handRotation), - y + 2 + 8 * MathUtils.cos(handRotation)); - Assets.itemTex[GameItems.getItem(inv[invSlot]).getTex()].draw(spriteBatch); - Assets.itemTex[GameItems.getItem(inv[invSlot]).getTex()].flip((getDir() == 0), false); - break; - } - } //front hand Assets.plSprite[0][2].setPosition(x - 6, y); Assets.plSprite[0][2].draw(spriteBatch); diff --git a/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java index 212003e..28da58e 100644 --- a/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java +++ b/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java @@ -79,11 +79,11 @@ public class MenuRenderer extends Renderer { spriter.begin(); for (int x = 0; x <= getWidth() / 16; x++) { for (int y = 0; y <= getHeight() / 16; y++) { - spriter.draw(Assets.blockTex[GameItems.getBlock(3).getTex()], x * 16, y * 16); + spriter.draw(GameItems.getBlock(3).getTex(), x * 16, y * 16); spriter.draw(Assets.shade, x * 16, y * 16); } } - spriter.draw(Assets.gameLogo, getWidth() / 2 - Assets.gameLogo.getWidth() / 2, 8); + spriter.draw(Assets.gameLogo, getWidth() / 2 - (float) Assets.gameLogo.getWidth() / 2, 8); switch (CaveGame.STATE) { case MENU_MAIN: diff --git a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java index 6eb0e60..109b0a1 100644 --- a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java @@ -10,14 +10,11 @@ import ru.deadsoftware.cavedroid.CaveGame; public class Assets { - public static final int BLOCK_TEXTURES = 66; - public static final int ITEM_TEXTURES = 13; - private static GlyphLayout layout; public static BitmapFont mcFont; - public static Sprite gameLogo; + public static Texture gameLogo; public static Texture menuBtnTex; public static TextureRegion[] menuBtn = new TextureRegion[3]; @@ -28,13 +25,7 @@ public class Assets { public static Texture pigTex; public static Sprite[][] pigSprite = new Sprite[2][2]; - public static Sprite shade; - - public static Texture terrain; - public static Sprite[] blockTex = new Sprite[BLOCK_TEXTURES]; - - public static Texture items; - public static Sprite[] itemTex = new Sprite[ITEM_TEXTURES]; + public static Texture shade; public static Texture gui; public static TextureRegion invBar; @@ -102,8 +93,7 @@ public class Assets { layout = new GlyphLayout(); - gameLogo = new Sprite(new Texture(Gdx.files.internal("gamelogo.png"))); - gameLogo.flip(false, true); + gameLogo = new Texture(Gdx.files.internal("gamelogo.png")); menuBtnTex = new Texture(Gdx.files.internal("buttons.png")); for (int i = 0; i < 3; i++) { @@ -114,7 +104,7 @@ public class Assets { loadPlayer(); loadPig(); - shade = new Sprite(new Texture(Gdx.files.internal("shade.png"))); + shade = new Texture(Gdx.files.internal("shade.png")); gui = new Texture(Gdx.files.internal("gui.png")); guiCur = new TextureRegion(gui, 0, 0, 16, 16); @@ -148,22 +138,6 @@ public class Assets { touchSpace.flip(false, true); } - terrain = new Texture(Gdx.files.internal("terrain.png")); - for (int i = 0; i < BLOCK_TEXTURES; i++) { - blockTex[i] = new Sprite(terrain, - (i % 16) * 16, (i / 16) * 16, 16, 16); - blockTex[i].flip(false, true); - blockTex[i].setSize(8, 8); - } - terrain = null; - - items = new Texture(Gdx.files.internal("items.png")); - for (int i = 0; i < ITEM_TEXTURES; i++) { - itemTex[i] = new Sprite(items, - (i % 16) * 16, (i / 16) * 16, 16, 16); - itemTex[i].flip(false, true); - } - items = null; } public static int getStringWidth(String s) { diff --git a/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java b/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java index bdfdd77..b3f09bf 100644 --- a/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java +++ b/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java @@ -10,7 +10,7 @@ public class DesktopLauncher { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.addIcon("icons/icon256.png", Files.FileType.Internal); config.addIcon("icons/icon128.png", Files.FileType.Internal); - config.foregroundFPS = 60; + config.foregroundFPS = 144; config.title = "CaveDroid"; config.width = 960; config.height = 540;