DEADSOFTWARE

Code improvements
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / objects / Block.java
index 5d2814e7f0e1c26603c763390989819237c26685..58714852ea514847d09c29bc68a7e913b2f99b55 100644 (file)
@@ -4,35 +4,61 @@ import com.badlogic.gdx.math.Rectangle;
 
 public class Block {
 
-    private int x,y,w,h;
-    private int texture;
+    private int x, y, w, h;
+    private int tex;
     private int hp, drop;
 
-    public boolean collision, background, transparent;
+    //coll - collision, bg - background, tp - transparent, rb - requires block under it
+    private boolean coll, bg, tp, rb;
 
-    public Block(int texture, int hp, int drop) {
-        this(0,0,16,16,texture, hp, drop, true, false, false);
+    public Block(int tex, int hp, int drop) {
+        this(0, 0, 16, 16, tex, hp, drop, true, false, 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);
+    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 x, int y, int w, int h, int texture, int hp, int drop, boolean collision, boolean background, boolean transparent) {
+    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.texture = texture;
+        this.tex = tex;
         this.hp = hp;
         this.drop = drop;
-        this.collision = collision;
-        this.background = background;
-        this.transparent = transparent;
+        this.coll = coll;
+        this.bg = bg;
+        this.tp = tp;
+        this.rb = rb;
+    }
+
+    public boolean hasCollision() {
+        return coll;
+    }
+
+    public boolean isBackground() {
+        return bg;
+    }
+
+    public boolean isTransparent() {
+        return tp;
+    }
+
+    public boolean requiresBlock() {
+        return rb;
     }
 
-    public int getTexture() {
-        return texture;
+    public int getTex() {
+        return tex;
     }
 
     public int getHp() {
@@ -44,13 +70,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 && coll);
     }
 
 }