DEADSOFTWARE

Better collision, disable auto jump
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / objects / Block.java
index 77810e95084e6ef1b1f8c54a0bc588b53faadfa4..a1696f64b340a7c3ed979cf3c3e5b359362dfb0e 100644 (file)
@@ -5,7 +5,7 @@ import com.badlogic.gdx.math.Rectangle;
 
 public class Block {
 
-    private Rectangle rect;
+    private int x,y,w,h;
     private TextureRegion texture;
 
     public boolean collision, foreground;
@@ -15,7 +15,10 @@ public class Block {
     }
 
     public Block(int x, int y, int w, int h, TextureRegion texture, boolean collision, boolean foreground) {
-        rect = new Rectangle(x,y,w,h);
+        this.x = x;
+        this.y = y;
+        this.w = w;
+        this.h = h;
         this.texture = texture;
         this.collision = collision;
         this.foreground = foreground;
@@ -25,23 +28,10 @@ public class Block {
         return texture;
     }
 
-    public Rectangle getRect() {
-        return rect;
+    public Rectangle getRect(int x, int y) {
+        x*=16;
+        y*=16;
+        return new Rectangle(x+this.x, y+this.y, w, h);
     }
 
-    public int getX() {
-        return (int)rect.x;
-    }
-
-    public int getY() {
-        return (int)rect.y;
-    }
-
-    public int getWidth() {
-        return (int)rect.width;
-    }
-
-    public int getHeight() {
-        return (int)rect.height;
-    }
 }