DEADSOFTWARE

Code improvements
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / objects / Block.java
1 package ru.deadsoftware.cavecraft.game.objects;
3 import com.badlogic.gdx.math.Rectangle;
5 public class Block {
7 private int x, y, w, h;
8 private int tex;
9 private int hp, drop;
11 //coll - collision, bg - background, tp - transparent, rb - requires block under it
12 private boolean coll, bg, tp, rb;
14 public Block(int tex, int hp, int drop) {
15 this(0, 0, 16, 16, tex, hp, drop, true, false, false, false);
16 }
18 public Block(int tex, int hp, int drop, boolean coll, boolean bg, boolean tp) {
19 this(0, 0, 16, 16, tex, hp, drop, coll, bg, tp, false);
20 }
22 public Block(int tex, int hp, int drop, boolean coll, boolean bg, boolean tp, boolean rb) {
23 this(0, 0, 16, 16, tex, hp, drop, coll, bg, tp, rb);
24 }
26 public Block(int x, int y, int w, int h, int tex, int hp, int drop, boolean coll, boolean bg, boolean tp) {
27 this(x, y, w, h, tex, hp, drop, coll, bg, tp, false);
28 }
30 public Block(int x, int y, int w, int h, int tex, int hp, int drop, boolean coll, boolean bg, boolean tp, boolean rb) {
31 this.x = x;
32 this.y = y;
33 this.w = w;
34 this.h = h;
35 this.tex = tex;
36 this.hp = hp;
37 this.drop = drop;
38 this.coll = coll;
39 this.bg = bg;
40 this.tp = tp;
41 this.rb = rb;
42 }
44 public boolean hasCollision() {
45 return coll;
46 }
48 public boolean isBackground() {
49 return bg;
50 }
52 public boolean isTransparent() {
53 return tp;
54 }
56 public boolean requiresBlock() {
57 return rb;
58 }
60 public int getTex() {
61 return tex;
62 }
64 public int getHp() {
65 return hp;
66 }
68 public int getDrop() {
69 return drop;
70 }
72 public Rectangle getRect(int x, int y) {
73 x *= 16;
74 y *= 16;
75 return new Rectangle(x + this.x, y + this.y, w, h);
76 }
78 public boolean toJump() {
79 return (y < 8 && coll);
80 }
82 }