AI for Games 1.1.1
Loading...
Searching...
No Matches
game2dai.Domain Class Reference

Public Member Functions

 Domain (double lowX, double lowY, double highX, double highY)
 
 Domain (Domain d)
 
void setDomain_xywh (double lowX, double lowY, double width, double height)
 
void move_centre_xy_to (double wx, double wy)
 
void move_centre_x_to (double wx)
 
void move_centre_y_to (double wy)
 
void move_centre_xy_by (double wx, double wy)
 
void move_centre_x_by (double wx)
 
void move_centre_y_by (double wy)
 
boolean contains (Vector2D p)
 
boolean contains (Vector2D p, double scale)
 
boolean contains (double px, double py)
 
String toString ()
 

Public Attributes

double lowX
 
double highX
 
double lowY
 
double highY
 
final Vector2D centre
 
double width
 
double height
 

Detailed Description

Objects of this class represent a rectangular region of the world. It can also used to store the viewport or display area of the screen. They can be used to constrain moving entities to particular regions.
WARNING although the attributes are public, this is for speed of reading and they should only be changed using the methods provided in this class.

Author
Peter Lager

Constructor & Destructor Documentation

◆ Domain() [1/2]

game2dai.Domain.Domain ( double  lowX,
double  lowY,
double  highX,
double  highY 
)

Create a Domain object given the top-left and bottom-right coordinates.

Parameters
lowX
lowY
highX
highY

◆ Domain() [2/2]

game2dai.Domain.Domain ( Domain  d)

Create a Domain that is a copy of another one.

Parameters
ddomain to be copied

Member Function Documentation

◆ contains() [1/3]

boolean game2dai.Domain.contains ( double  px,
double  py 
)

See if this point is within the domain

Parameters
pxx position of point to test
pyposition of point to test
Returns
true if the point is on or inside the boundary of this domain

◆ contains() [2/3]

boolean game2dai.Domain.contains ( Vector2D  p)

See if this point is within the domain

Parameters
pthe point to test
Returns
true if the point is on or inside the boundary of this domain

◆ contains() [3/3]

boolean game2dai.Domain.contains ( Vector2D  p,
double  scale 
)

See if this point is within a box scaled by the second parameter.
fraction must be >0 otherwise the function always returns false. A value of 1 will test against the full size domain and a value of 0.5 means the point p must be in the middle half both horizontally and vertically.

Parameters
pthe point to test
scalethe scale of the domain to consider
Returns
true if the point is on or inside the boundary of this scaled domain

◆ move_centre_x_by()

void game2dai.Domain.move_centre_x_by ( double  wx)

Move the domain centre horizontally by the world distance given.

Parameters
wxworld x centre position

◆ move_centre_x_to()

void game2dai.Domain.move_centre_x_to ( double  wx)

Centre the domain about the given horizontal position.

Parameters
wxworld x position

◆ move_centre_xy_by()

void game2dai.Domain.move_centre_xy_by ( double  wx,
double  wy 
)

Centre the domain about the given position.

Parameters
wxworld x centre position
wyworld y centre position

◆ move_centre_xy_to()

void game2dai.Domain.move_centre_xy_to ( double  wx,
double  wy 
)

Centre the domain about the given world position.

Parameters
wxworld x position
wyworld y position

◆ move_centre_y_by()

void game2dai.Domain.move_centre_y_by ( double  wy)

Move the domain centre vertically by the world distance given.

Parameters
wyworld y centre position

◆ move_centre_y_to()

void game2dai.Domain.move_centre_y_to ( double  wy)

Centre the domain about the given vertical position.

Parameters
wyworld y position

◆ setDomain_xywh()

void game2dai.Domain.setDomain_xywh ( double  lowX,
double  lowY,
double  width,
double  height 
)

Set the domain size.

Parameters
lowXtop-left x coordinate
lowYtop-left y coordinate
widthdomain width
heightdomain height

◆ toString()

String game2dai.Domain.toString ( )

Return the Domain as a String


The documentation for this class was generated from the following file: