X-Git-Url: https://deadsoftware.ru/gitweb?p=cavedroid.git;a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2Fobjects%2FBlock.java;h=2a4491610caae37ea8207e1e46e2205c3fd49740;hp=defbd3b3dcc920bbbfe5d5851d2978637ed45d57;hb=4eb1f6f24fb76c0336394b85393e801fd0b99da4;hpb=e028a66c47ef4d99235b5337d57e14145acbeb2b 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