Class Background

java.lang.Object
fr.paris.saclay.sidescroller.drawables.Drawable
fr.paris.saclay.sidescroller.drawables.Background

public class Background extends Drawable
Drawable responsible for creating the background.
  • Constructor Details

    • Background

      public Background(GamePanel gamePanel, String theme)
      Creates a Background instance, saves the GamePanel reference and sets the theme (background related to the level selected in the initial menu).
      Parameters:
      gamePanel - reference.
      theme - theme types: grass, mushroom, castle (each one related to a different level).
  • Method Details

    • update

      public void update()
      Handles Background movement. The player cannot exceed xPosition = 0 to the left and the half of the screen when walking on the right. Since the player has different speed while jumping, the camera is updated differently.
      Specified by:
      update in class Drawable
    • draw

      public void draw(Graphics2D graphics2D)
      Renders the component into the scene.
      Specified by:
      draw in class Drawable
      Parameters:
      graphics2D - the rendering environment.
    • getDeltaX

      public int getDeltaX()
      Gets delta x.
      Returns:
      the delta x