java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
fr.paris.saclay.sidescroller.controllers.components.GamePanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Runnable, Accessible

public class GamePanel extends JPanel implements Runnable
Main screen displayed, it is the core controller of the game.
See Also:
  • Field Details

    • upPressed

      public boolean upPressed
      Flags identifying if certain keyboard keys are pressed.
    • rightPressed

      public boolean rightPressed
      Flags identifying if certain keyboard keys are pressed.
    • leftPressed

      public boolean leftPressed
      Flags identifying if certain keyboard keys are pressed.
  • Constructor Details

    • GamePanel

      public GamePanel(MainFrame parent)
      Creates a GamePanel instance.
      Parameters:
      parent - parent reference.
  • Method Details

    • showMenu

      public Action showMenu()
      Shows pause menu.
      Returns:
      Action.
    • setDebugHitbox

      public void setDebugHitbox()
      Sets debug hitbox.
    • setDebugEnemyGeneration

      public void setDebugEnemyGeneration()
      Sets debug enemy generation.
    • startGame

      public void startGame()
      Starts game and generates level.
    • run

      public void run()
      Thread main method.
      Specified by:
      run in interface Runnable
    • update

      public void update()
      Handles update for each entity/drawable.
    • checkCollision

      public List<Entity> checkCollision()
      Check collisions of drawn entities.
      Returns:
      list of entities colliding.
    • getPlayerPositionX

      public int getPlayerPositionX()
      Gets player position x.
      Returns:
      the player position x
    • paintComponent

      public void paintComponent(Graphics graphics)
      Overrides:
      paintComponent in class JComponent
    • getPlayerSpeed

      public int getPlayerSpeed()
      Gets player speed.
      Returns:
      the player speed
    • setRunning

      public void setRunning(boolean running)
      Sets running.
      Parameters:
      running - the running
    • play

      public void play()
      Play.
    • stop

      public void stop()
      Stop.
    • notifyCameraMoved

      public void notifyCameraMoved()
      Notify camera moved.
    • setGameOver

      public void setGameOver()
      Sets game over.
    • isPlayerAttacking

      public boolean isPlayerAttacking()
      Is player attacking boolean.
      Returns:
      the boolean
    • getPlayer

      public Player getPlayer()
      Gets player.
      Returns:
      the player
    • getDrawableBackground

      public Drawable getDrawableBackground()
      Gets drawable background.
      Returns:
      the drawable background
    • isDebugHitbox

      public boolean isDebugHitbox()
      Is debug hitbox boolean.
      Returns:
      the boolean