GTGE API

com.golden.gamedev.object.collision
Class CollisionRect

java.lang.Object
  extended by com.golden.gamedev.object.collision.CollisionRect
All Implemented Interfaces:
CollisionShape

public class CollisionRect
extends Object
implements CollisionShape

Optimized java.awt.Rectangle with double precision. The default sprite collision bounding box.


Field Summary
 int height
          The height of this collision rect.
 int width
          The width of this collision rect.
 double x
          The x-coordinate of this collision rect.
 double y
          The y-coordinate of this collision rect.
 
Constructor Summary
CollisionRect()
          Creates new CollisionRect.
 
Method Summary
 int getHeight()
          Returns the height of this collision shape.
 int getWidth()
          Returns the width of this collision shape.
 double getX()
          Returns the x-position of this collision shape.
 double getY()
          Returns the y-position of this collision shape.
 void grow(int h, int v)
          Grows this collision rect by h width, and v height.
 boolean intersects(CollisionShape shape)
          Returns whether this collision shape intersects with other collision shape area.
 void move(double dx, double dy)
          Moves this collision shape by specified delta.
 void setBounds(CollisionRect rect)
          Sets the boundary of this colllision rect to be same with specified collision rect.
 void setBounds(double x1, double y1, int w1, int h1)
          Sets the boundary of this colllision shape to specified boundary.
 void setLocation(double x1, double y1)
          Moves this collision shape to specified location.
 void shrink(int h, int v)
          Shrinks this collision rect by h width, and v height.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
The x-coordinate of this collision rect.


y

public double y
The y-coordinate of this collision rect.


width

public int width
The width of this collision rect.


height

public int height
The height of this collision rect.

Constructor Detail

CollisionRect

public CollisionRect()
Creates new CollisionRect.

Method Detail

grow

public void grow(int h,
                 int v)
Grows this collision rect by h width, and v height.


shrink

public void shrink(int h,
                   int v)
Shrinks this collision rect by h width, and v height.


intersects

public boolean intersects(CollisionShape shape)
Description copied from interface: CollisionShape
Returns whether this collision shape intersects with other collision shape area.

Specified by:
intersects in interface CollisionShape

setBounds

public void setBounds(double x1,
                      double y1,
                      int w1,
                      int h1)
Description copied from interface: CollisionShape
Sets the boundary of this colllision shape to specified boundary.

Specified by:
setBounds in interface CollisionShape

setBounds

public void setBounds(CollisionRect rect)
Sets the boundary of this colllision rect to be same with specified collision rect.


setLocation

public void setLocation(double x1,
                        double y1)
Description copied from interface: CollisionShape
Moves this collision shape to specified location.

Specified by:
setLocation in interface CollisionShape

move

public void move(double dx,
                 double dy)
Description copied from interface: CollisionShape
Moves this collision shape by specified delta.

Specified by:
move in interface CollisionShape

getX

public double getX()
Description copied from interface: CollisionShape
Returns the x-position of this collision shape.

Specified by:
getX in interface CollisionShape

getY

public double getY()
Description copied from interface: CollisionShape
Returns the y-position of this collision shape.

Specified by:
getY in interface CollisionShape

getWidth

public int getWidth()
Description copied from interface: CollisionShape
Returns the width of this collision shape.

Specified by:
getWidth in interface CollisionShape

getHeight

public int getHeight()
Description copied from interface: CollisionShape
Returns the height of this collision shape.

Specified by:
getHeight in interface CollisionShape

toString

public String toString()
Overrides:
toString in class Object

GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id