X-Git-Url: https://deadsoftware.ru/gitweb?p=cavedroid.git;a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2Fobjects%2FBlock.java;h=58714852ea514847d09c29bc68a7e913b2f99b55;hp=e888b212fe3d0b7d8ac0b9690dba9757022eac01;hb=cef4b5a9985bcbdfea6dc652147ecde0721d7fdc;hpb=f988ac987aae5e7dd99721ca4cf044d061153e89 diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java index e888b21..5871485 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Block.java @@ -1,39 +1,82 @@ package ru.deadsoftware.cavecraft.game.objects; -import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Rectangle; public class Block { - private Rectangle rect; - private TextureRegion texture; + private int x, y, w, h; + private int tex; + private int hp, drop; - public Block(int x, int y, int w, int h, TextureRegion texture) { - rect = new Rectangle(x,y,w,h); - this.texture = texture; + //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; + this.hp = hp; + this.drop = drop; + 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 TextureRegion getTexture() { - return texture; + public boolean requiresBlock() { + return rb; } - public Rectangle getRect() { - return rect; + public int getTex() { + return tex; } - public int getX() { - return (int)rect.x; + public int getHp() { + return hp; } - public int getY() { - return (int)rect.y; + public int getDrop() { + return drop; } - public int getWidth() { - return (int)rect.width; + public Rectangle getRect(int x, int y) { + x *= 16; + y *= 16; + return new Rectangle(x + this.x, y + this.y, w, h); } - public int getHeight() { - return (int)rect.height; + public boolean toJump() { + return (y < 8 && coll); } + }