|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectuk.ac.ic.doc.game.RegularPolygon
public abstract class RegularPolygon
An IGameObject implementation that represents a regular polygon in the game.
| Constructor Summary | |
|---|---|
RegularPolygon(Point position,
double rotation,
double size,
int sides)
Constructs a new regular polygon of the given position, rotation and size with the given number of sides. |
|
| Method Summary | |
|---|---|
void |
draw(java.awt.Graphics2D graphics,
Point scale)
Draws this object on the given graphics context at the given scale. |
Point |
getPosition()
Returns the current position of this object. |
double |
getRotation()
Returns the current rotation of this object. |
double |
getSize()
Returns the current size of this object. |
boolean |
isExitingScreen()
Tests whether this object is exiting the screen. |
boolean |
isOverlapping(IGameObject polygon)
Tests whether or not this object is overlapping the given object. |
void |
moveBackward(double amount)
Moves this object the given amount away from the direction it is currently facing. |
void |
moveForward(double amount)
Moves this object the given amount in the direction it is currently facing. |
abstract void |
onCreate(IGame game)
Called when the object is added to the game. |
void |
setPosition(Point position)
Sets the position of this object. |
void |
setRotation(double angle)
Sets the rotation of this object. |
void |
setSize(double size)
Sets the size of this object. |
void |
strafeLeft(double amount)
Moves this object the given amount 90-degrees clockwise to the direction it is currently facing. |
void |
strafeRight(double amount)
Moves this object the given amount 90-degrees counter-clockwise to the direction it is currently facing. |
void |
turnClockwise(double amount)
Turns this object clockwise by the given amount. |
void |
turnCounterClockwise(double amount)
Turns this object counter-clockwise by the given amount. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RegularPolygon(Point position,
double rotation,
double size,
int sides)
position - The initial position of this object, in terms of proportion
of window size (e.g. (0, 0) is top-left and (1, 1) is
bottom-right).rotation - The initial angle of this object, in terms of proportion of
total rotation clockwise from the vertical (e.g. 0 is facing
upwards, 0.25 is facing right, 0.5 is facing downwards and 0.75
is facing left).size - The initial size of this object, in terms of proportion of
window size (e.g. 0.5 makes this object half the size of
the game window).sides - The number of sides this regular polygon has. Must be
greater than 2.| Method Detail |
|---|
public Point getPosition()
public double getRotation()
public double getSize()
public void setPosition(Point position)
position - The new position of this object, in terms of proportion
of window size (e.g. (0, 0) is top-left and (1, 1) is
bottom-right).public void setRotation(double angle)
angle - The new angle of this object, in terms of proportion of
total rotation clockwise from the vertical (e.g. 0 is facing
upwards, 0.25 is facing right, 0.5 is facing downwards and 0.75
is facing left).public void setSize(double size)
size - The new size of this object, in terms of proportion of
window size (e.g. 0.5 makes this object half the size of
the game window).public void moveForward(double amount)
amount - The amount to move forward, in terms of proportion of window
size.public void moveBackward(double amount)
amount - The amount to move backwards, in terms of proportion of window
size.public void strafeLeft(double amount)
amount - The amount to strafe left, in terms of proportion of window
size.public void strafeRight(double amount)
amount - The amount to strafe right, in terms of proportion of window
size.public void turnClockwise(double amount)
amount - The amount to rotate this object by, in terms of proportion of
total rotation clockwise from the vertical (e.g. 0 is no
change, 0.25 is 90-degrees, 0.5 is 180 degrees and 0.75 is 270
degrees).public void turnCounterClockwise(double amount)
amount - The amount to rotate this object by, in terms of proportion of
total rotation counter-clockwise from the vertical (e.g. 0 is
no change, 0.25 is 90-degrees, 0.5 is 180 degrees and 0.75 is
270 degrees).
public void draw(java.awt.Graphics2D graphics,
Point scale)
draw in interface IGameObjectgraphics - The graphics context on which to draw the object.scale - The scale at which to draw the object.public boolean isExitingScreen()
isExitingScreen in interface IGameObjectpublic boolean isOverlapping(IGameObject polygon)
isOverlapping in interface IGameObjectobject - The object to test for overlap with.
public abstract void onCreate(IGame game)
onCreate in interface IGameObjectgame - The game that the object is being added to.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||