Class Screen

Direct Known Subclasses:
World

public class Screen extends Object
Screen class - a high level class that handles background screens & millisecond timing Has a World Subclass
  • Constructor Summary

    Constructors
    Constructor
    Description
    Screen(processing.core.PApplet p, String screenName, String movingBgFile, float scale, float x, float y)
    Screen Constructor #2: For background images that move - Takes String (Coded as a Sprite, not a Processing background PImage)
    Screen(processing.core.PApplet p, String screenName, processing.core.PImage bgImg)
    Screen Constructor #1: Stationary background image
    Screen(processing.core.PApplet p, String screenName, processing.core.PImage movingBg, float scale, float x, float y)
    Screen Constructor #3: For background images that move - Takes PImage (Coded as a Sprite, not a Processing background PImage)
  • Method Summary

    Modifier and Type
    Method
    Description
    float
     
    processing.core.PImage
    Gets the background as a PImage
    boolean
    Checks if the Screen's background is moveable
    float
    Returns the pixel value for the left edge of the background image
    Gets the name of the Screen to be used for debugging
    long
     
    float
     
    long
    getTimeSince(long lastCheck)
     
    float
    Returns the pixel value for the top edge of the background image
    long
     
    void
    moveBgXY(float speedX, float speedY)
    Moves the background image in the X & Y directions
    void
    pause(int milliseconds)
    Resets the timer for the screen.
    void
     
    void
    setBg(processing.core.PImage bgImg)
    Sets the background image for NON-MOVEABLE backgrounds
    void
    setLeftX(float leftX)
    Moves the left edge of the background to a specified pixel (ie.
    void
    setName(String screenName)
    Sets the name of the Screen to be used for debugging
    void
    setTopY(float topY)
    Moves the top edge of the background to a specified pixel (ie.
    void
    Updates all sprites and images on the Screen Does nothing unless Overridden by World, Grid, and HexGrid
    void
    Updates any movement of the background to be shown
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Screen

      public Screen(processing.core.PApplet p, String screenName, processing.core.PImage bgImg)
      Screen Constructor #1: Stationary background image
      Parameters:
      p - Processing applet
      screenName - String to track Screens
      bgImg - stationary background image
    • Screen

      public Screen(processing.core.PApplet p, String screenName, String movingBgFile, float scale, float x, float y)
      Screen Constructor #2: For background images that move - Takes String (Coded as a Sprite, not a Processing background PImage)
      Parameters:
      p - Processing applet
      screenName - String to track Screens
      movingBgFile - filename for the background image to move
      scale - float that multiplies the size of the image to display
      x - sets the initial left edge of the background
      y - sets the intial top edge of the background
    • Screen

      public Screen(processing.core.PApplet p, String screenName, processing.core.PImage movingBg, float scale, float x, float y)
      Screen Constructor #3: For background images that move - Takes PImage (Coded as a Sprite, not a Processing background PImage)
      Parameters:
      p - Processing applet
      screenName - String to track Screens
      movingBg - PImage for a moving background
      scale - float that multiplies the size of the image to display
      x - sets the initial left edge of the background
      y - sets the intial top edge of the background
  • Method Details

    • setName

      public void setName(String screenName)
      Sets the name of the Screen to be used for debugging
      Parameters:
      screenName - String to track Screens
    • getName

      public String getName()
      Gets the name of the Screen to be used for debugging
      Returns:
      String Can be used to track the Screen
    • setBg

      public void setBg(processing.core.PImage bgImg)
      Sets the background image for NON-MOVEABLE backgrounds
      Parameters:
      bgImg - stationary background image
    • getBgImage

      public processing.core.PImage getBgImage()
      Gets the background as a PImage
      Returns:
      PImage moving OR non-moving background image
    • getIsMoveable

      public boolean getIsMoveable()
      Checks if the Screen's background is moveable
      Returns:
      boolean true if background is moveable, false if stationary
    • moveBgXY

      public void moveBgXY(float speedX, float speedY)
      Moves the background image in the X & Y directions
      Parameters:
      speedX - positive moves right, negative moves left
      speedY - positive moves down, negative moves up
    • setLeftX

      public void setLeftX(float leftX)
      Moves the left edge of the background to a specified pixel (ie. -50.0f)
      Parameters:
      leftX - pixel of left edge of moving background
    • getLeftX

      public float getLeftX()
      Returns the pixel value for the left edge of the background image
      Returns:
      float pixel of left edge of moving background
    • setTopY

      public void setTopY(float topY)
      Moves the top edge of the background to a specified pixel (ie. -50.0f)
      Parameters:
      topY - pixel of top edge of moving background
    • getTopY

      public float getTopY()
      Returns the pixel value for the top edge of the background image
      Returns:
      float pixel of top edge of moving background
    • showBg

      public void showBg()
      Updates any movement of the background to be shown
    • show

      public void show()
      Updates all sprites and images on the Screen Does nothing unless Overridden by World, Grid, and HexGrid
    • distToRightEdge

      public float distToRightEdge()
      Returns:
      float distance to right edge for a moveable background
    • getTotalTime

      public long getTotalTime()
      Returns:
      long total number of milliseconds the game has been running
    • getScreenTime

      public long getScreenTime()
      Returns:
      long milliseconds the Screen has been running
    • getTimeSince

      public long getTimeSince(long lastCheck)
      Parameters:
      lastCheck - milliseconds since last check
      Returns:
      long milliseconds from a previous time
    • getScreenTimeSeconds

      public float getScreenTimeSeconds()
      Returns:
      float seconds the Screen has been running
    • resetTime

      public void resetTime()
    • pause

      public void pause(int milliseconds)
      Resets the timer for the screen. Can be used when Screen first becomes visible
      Parameters:
      milliseconds - how long to pause the app
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      String includes screenName, leftX, and topY