DEADSOFTWARE

Move items to JSON
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / objects / Block.java
1 package ru.deadsoftware.cavedroid.game.objects;
3 import com.badlogic.gdx.graphics.g2d.Sprite;
4 import com.badlogic.gdx.math.Rectangle;
6 public class Block {
8 private int x, y, w, h;
9 private int hp;
10 private String drop, meta;
11 private Sprite tex;
13 //coll - collision, bg - background, tp - transparent, rb - requires block under it
14 private boolean coll, bg, tp, rb, fluid;
16 public Block(int left, int top, int right, int bottom, int hp,
17 String drop, boolean coll, boolean bg, boolean tp, boolean rb, boolean fluid, String meta, Sprite tex) {
18 this.x = left;
19 this.y = top;
20 this.w = 16 - right - left;
21 this.h = 16 - top - bottom;
22 this.hp = hp;
23 this.drop = drop;
24 this.coll = coll;
25 this.bg = bg;
26 this.tp = tp;
27 this.rb = rb;
28 this.fluid = fluid;
29 this.meta = meta;
30 this.tex = tex;
31 if (this.tex != null) this.tex.flip(false, true);
32 }
34 public boolean hasCollision() {
35 return coll;
36 }
38 public boolean isBackground() {
39 return bg;
40 }
42 public boolean isTransparent() {
43 return tp;
44 }
46 public boolean requiresBlock() {
47 return rb;
48 }
50 public int getHp() {
51 return hp;
52 }
54 public String getDrop() {
55 return drop;
56 }
58 public boolean hasDrop() {
59 return !drop.equals("none");
60 }
62 public Sprite getTex() {
63 return tex;
64 }
66 public Rectangle getRect(int x, int y) {
67 x *= 16;
68 y *= 16;
69 return new Rectangle(x + this.x, y + this.y, w, h);
70 }
72 public boolean isFluid() {
73 return fluid;
74 }
76 public String getMeta() {
77 return meta;
78 }
80 public boolean toJump() {
81 return (y < 8 && coll);
82 }
84 }