public class Graphic
extends java.lang.Object
Constructor and Description |
---|
Graphic(java.lang.String type)
This constructor creates a Graphic object at position 0,0 with a
direction of 0 (facing the right), and the specified appearance.
|
Modifier and Type | Method and Description |
---|---|
void |
draw()
This method draws a Graphic to the screen at its current location, and
facing in its current direction (orientation).
|
float |
getDirection()
This method retrieves the orientation of the current Graphic as an
angle measured in radians, where 0: facing right, and PI/2: facing down,
PI: facing left, and 3PI/2 (or the equivalent -PI/2): facing up.
|
float |
getDirectionX()
This method retrieves part of the orientation of the current graphic as a
point that is one unit away, and in the direction this Graphic is facing.
|
float |
getDirectionY()
This method retrieves part of the orientation of the current graphic as a
point that is one unit away, and in the direction this Graphic is facing.
|
java.lang.String |
getType()
This method retrieves the type of the current Graphic.
|
float |
getX()
This method retrieves the x-position in pixels of the current Graphic.
|
float |
getY()
This method retrieves the y position in pixels of the current Graphic.
|
boolean |
isCollidingWith(Graphic other)
Determines whether this Graphic is overlapping or colliding with another
Graphic on the screen.
|
void |
setDirection(float angle)
This method allows you to update the direction that a Graphic is facing,
by specifying an angle (in radians) of rotation, where 0: facing right,
and pi/2: facing down, pi: facing left, and 3pi/2: facing up.
|
void |
setDirection(float x,
float y)
This method allows you to update the direction that a Graphic is facing,
by specifying any position on the screen that you would like it to face
toward.
|
void |
setPosition(float x,
float y)
This method allows you to update the position of a Graphic.
|
void |
setType(java.lang.String type)
Sets the type of graphic used to represent this object.
|
void |
setX(float x)
This method allows you to update the horizontal position of a Graphic.
|
void |
setY(float y)
This method allows you to update the vertical position of a Graphic.
|
public Graphic(java.lang.String type)
type
- - defines the appearance of the newly created object.public void setType(java.lang.String type)
type
- The type of graphic used to represent this object.public java.lang.String getType()
public float getX()
public float getY()
public float getDirection()
public float getDirectionX()
public float getDirectionY()
public void setX(float x)
x
- - is the x-position that you would like to move this Graphic to.public void setY(float y)
y
- - is the y-position that you would like to move this Graphic to.public void setPosition(float x, float y)
x
- - is the x-position that you would like to move this Graphic to.y
- - is the y-position that you would like to move this Graphic to.public void setDirection(float angle)
angle
- The angular amount of rotation you would like to apply to
this Graphic.public void setDirection(float x, float y)
x
- - is the x-coordinate of the position for the Graphic to face.y
- - is the y-coordinate of the position for the Graphic to face.public boolean isCollidingWith(Graphic other)
other
- - is the Graphic being checked against for collisions.public void draw()