From 487cdd274c70a398147948b885db87357462e432 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 14 Jan 2014 22:12:13 +0200 Subject: [PATCH] Change enemy internal coords to Rectangle --- src/com/annimon/influencexxii/Enemy.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/com/annimon/influencexxii/Enemy.java b/src/com/annimon/influencexxii/Enemy.java index 0d33d88..ab0dffd 100644 --- a/src/com/annimon/influencexxii/Enemy.java +++ b/src/com/annimon/influencexxii/Enemy.java @@ -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); } } \ No newline at end of file