Class Ghost
- java.lang.Object
-
- Ghost
-
public class Ghost extends java.lang.Object
Draws little pictures on the graphics pane
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BLINKY
Used to reference BLINKYstatic java.lang.String
DOWN
Used to reference looking downstatic java.lang.String
INKY
Used to reference INKYstatic java.lang.String
LEFT
Used to reference looking leftstatic java.lang.String
PINKY
Used to reference PINKYstatic java.lang.String
POKEY
Used to reference POKEYstatic java.lang.String
RIGHT
Used to reference looking rightstatic java.lang.String
STRAIGHT
Used to reference looking straightstatic java.lang.String
UP
Used to reference looking up
-
Constructor Summary
Constructors Constructor Description Ghost(double x, double y, double width, double height)
Ghost constructor
(used when using new Ghost(...) )Ghost(double x, double y, double width, double height, java.lang.String name)
Ghost constructor
(used when using new Ghost(...) )Ghost(double x, double y, double width, double height, java.lang.String name, java.lang.String direction)
Ghost constructor
(used when using new Ghost(...) )
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
draw()
Draw Ghost at its current location with its current scare status and typevoid
erase()
Erase a Ghost by drawing white over its bodydouble
getBottom()
Get the bottom most position of the Ghostdouble
getLeft()
Get the left most position of the Ghostdouble
getMiddleX()
Get the mid-point X position of the Ghostdouble
getMiddleY()
Get the mid-point Y position of the Ghostdouble
getRight()
Get the right most position of the Ghostdouble
getTop()
Get the top most position of the Ghostvoid
lookDown()
Change the Ghost to look downvoid
lookLeft()
Change the Ghost to look leftvoid
lookRight()
Change the Ghost to look rightvoid
lookStraight()
Change the Ghost to look straightvoid
lookUp()
Change the Ghost to look upvoid
move()
Move the Ghost using its default speedvoid
move(double speed)
Move the Ghost using specified speed in the direction the Ghost is looking (no movement if the Ghost looks straight)void
setBlinky()
Set the Ghost to be Blinkyvoid
setInky()
Set the Ghost to be Inkyvoid
setPinky()
Set the Ghost to be Pinkyvoid
setPokey()
Set the Ghost to be Pokeyvoid
setScared(boolean scared)
Set if the Ghost is scared.
-
-
-
Field Detail
-
BLINKY
public static final java.lang.String BLINKY
Used to reference BLINKY- See Also:
- Constant Field Values
-
PINKY
public static final java.lang.String PINKY
Used to reference PINKY- See Also:
- Constant Field Values
-
INKY
public static final java.lang.String INKY
Used to reference INKY- See Also:
- Constant Field Values
-
POKEY
public static final java.lang.String POKEY
Used to reference POKEY- See Also:
- Constant Field Values
-
UP
public static final java.lang.String UP
Used to reference looking up- See Also:
- Constant Field Values
-
DOWN
public static final java.lang.String DOWN
Used to reference looking down- See Also:
- Constant Field Values
-
LEFT
public static final java.lang.String LEFT
Used to reference looking left- See Also:
- Constant Field Values
-
RIGHT
public static final java.lang.String RIGHT
Used to reference looking right- See Also:
- Constant Field Values
-
STRAIGHT
public static final java.lang.String STRAIGHT
Used to reference looking straight- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Ghost
public Ghost(double x, double y, double width, double height)
Ghost constructor
(used when using new Ghost(...) )- Parameters:
x
- Left most postion of the Ghosty
- Bottom most position of the Ghostwidth
- Width of the Ghostheight
- Height of the body (without the head) of the Ghost
-
Ghost
public Ghost(double x, double y, double width, double height, java.lang.String name)
Ghost constructor
(used when using new Ghost(...) )- Parameters:
x
- Left most postion of the Ghosty
- Bottom most position of the Ghostwidth
- Width of the Ghostheight
- Height of the body (without the head) of the Ghostname
- the name of the Ghost (using the constant Ghost names)
-
Ghost
public Ghost(double x, double y, double width, double height, java.lang.String name, java.lang.String direction)
Ghost constructor
(used when using new Ghost(...) )- Parameters:
x
- Left most postion of the Ghosty
- Bottom most position of the Ghostwidth
- Width of the Ghostheight
- Height of the body (without the head) of the Ghostname
- the name of the Ghost (using the constant Ghost names)direction
- the direction the Ghost is looking (using the constant Ghost directions)
-
-
Method Detail
-
erase
public void erase()
Erase a Ghost by drawing white over its body
-
draw
public void draw()
Draw Ghost at its current location with its current scare status and type
-
move
public void move()
Move the Ghost using its default speed
-
move
public void move(double speed)
Move the Ghost using specified speed in the direction the Ghost is looking (no movement if the Ghost looks straight)- Parameters:
speed
- The user-specified speed in pixels
-
setScared
public void setScared(boolean scared)
Set if the Ghost is scared.- Parameters:
scared
- true scared Ghost, false normal Ghost
-
lookLeft
public void lookLeft()
Change the Ghost to look left
-
lookRight
public void lookRight()
Change the Ghost to look right
-
lookUp
public void lookUp()
Change the Ghost to look up
-
lookDown
public void lookDown()
Change the Ghost to look down
-
lookStraight
public void lookStraight()
Change the Ghost to look straight
-
getLeft
public double getLeft()
Get the left most position of the Ghost- Returns:
- the left most position of the Ghost
-
getRight
public double getRight()
Get the right most position of the Ghost- Returns:
- the rigth most position of the Ghost
-
getTop
public double getTop()
Get the top most position of the Ghost- Returns:
- the top most position of the Ghost
-
getBottom
public double getBottom()
Get the bottom most position of the Ghost- Returns:
- the bottom most position of the Ghost
-
getMiddleX
public double getMiddleX()
Get the mid-point X position of the Ghost- Returns:
- the mid-point X position of the Ghost
-
getMiddleY
public double getMiddleY()
Get the mid-point Y position of the Ghost- Returns:
- the mid-point Y position of the Ghost
-
setBlinky
public void setBlinky()
Set the Ghost to be Blinky
-
setPinky
public void setPinky()
Set the Ghost to be Pinky
-
setInky
public void setInky()
Set the Ghost to be Inky
-
setPokey
public void setPokey()
Set the Ghost to be Pokey
-
-