Class 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 BLINKY
      static java.lang.String DOWN
      Used to reference looking down
      static java.lang.String INKY
      Used to reference INKY
      static java.lang.String LEFT
      Used to reference looking left
      static java.lang.String PINKY
      Used to reference PINKY
      static java.lang.String POKEY
      Used to reference POKEY
      static java.lang.String RIGHT
      Used to reference looking right
      static java.lang.String STRAIGHT
      Used to reference looking straight
      static 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 type
      void erase()
      Erase a Ghost by drawing white over its body
      double getBottom()
      Get the bottom most position of the Ghost
      double getLeft()
      Get the left most position of the Ghost
      double getMiddleX()
      Get the mid-point X position of the Ghost
      double getMiddleY()
      Get the mid-point Y position of the Ghost
      double getRight()
      Get the right most position of the Ghost
      double getTop()
      Get the top most position of the Ghost
      void lookDown()
      Change the Ghost to look down
      void lookLeft()
      Change the Ghost to look left
      void lookRight()
      Change the Ghost to look right
      void lookStraight()
      Change the Ghost to look straight
      void lookUp()
      Change the Ghost to look up
      void move()
      Move the Ghost using its default speed
      void 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 Blinky
      void setInky()
      Set the Ghost to be Inky
      void setPinky()
      Set the Ghost to be Pinky
      void setPokey()
      Set the Ghost to be Pokey
      void setScared​(boolean scared)
      Set if the Ghost is scared.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
      • 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 Ghost
        y - Bottom most position of the Ghost
        width - Width of the Ghost
        height - 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 Ghost
        y - Bottom most position of the Ghost
        width - Width of the Ghost
        height - Height of the body (without the head) of the Ghost
        name - 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 Ghost
        y - Bottom most position of the Ghost
        width - Width of the Ghost
        height - Height of the body (without the head) of the Ghost
        name - 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