Change enemy internal coords to Rectangle
This commit is contained in:
parent
8e10f4d1de
commit
487cdd274c
@ -2,6 +2,7 @@ package com.annimon.influencexxii;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
|
||||
/**
|
||||
* Enemy object
|
||||
@ -9,7 +10,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
*/
|
||||
public class Enemy {
|
||||
|
||||
private int x, y, size;
|
||||
private Rectangle rect;
|
||||
private int dir;
|
||||
private Color color;
|
||||
|
||||
@ -18,20 +19,17 @@ public class Enemy {
|
||||
}
|
||||
|
||||
public Enemy(int x, int y, int size, int dir, Color color) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.size = size;
|
||||
rect = new Rectangle(x, y, size, size);
|
||||
this.dir = dir;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public boolean isCollide(int tx, int ty) {
|
||||
return ( ((tx >= x) && (tx <= x + size))
|
||||
&& ((ty >= y) && (ty <= y + size)) );
|
||||
public boolean isCollide(float tx, float ty) {
|
||||
return (rect.contains(tx, ty));
|
||||
}
|
||||
|
||||
public void draw(ShapeRenderer renderer) {
|
||||
renderer.setColor(color);
|
||||
renderer.rect(x, y, size, size);
|
||||
renderer.rect(rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user