com.golden.gamedev.object
Class CollisionRect
java.lang.Object
|
+--com.golden.gamedev.object.CollisionRect
- public class CollisionRect
- extends Object
Almost equal with java.awt.Rectangle, but use some optimized method.
This class is created to optimize collision detection,
because collision detection is heavily used in game.
CollisionRect is the sprite bounding box.
A sprite bounding box is checked its intersection with
other sprite bounding box to determine is the collision occured or not.
x
public int x
y
public int y
width
public int width
height
public int height
CollisionRect
public CollisionRect()
grow
public void grow(int h,
int v)
shrink
public void shrink(int h,
int v)
intersects
public boolean intersects(CollisionRect rect)
setBounds
public void setBounds(int x1,
int y1,
int w1,
int h1)
setBounds
public void setBounds(CollisionRect rect)
move
public void move(int dx,
int dy)
getX
public int getX()
getY
public int getY()
getWidth
public int getWidth()
getHeight
public int getHeight()
intersection
public void intersection(CollisionRect r,
CollisionRect iRect)
toString
public String toString()
- Overrides:
toString
in class Object