Window

Description

The Window class will create and handle the majority of the managers that will be used. The managers that will be created include, but not limited to: Loader, GameManager, GameContentManager, AudioManager, MenuManager, InputManager, and CinematicManager. Along with handling the managers, the Window class will also oversee the game through game states. There are six game states that will be used: Gameplay, Menu, Pause, Gameover, Loading, and Cinematic. With each state, a specific class will be used to handle it. The GameManager will handle Gameplay, MenuManager will handle Menu, Pause, and Gameover, and CinematicManager will handle Cinematic.

  • Gameplay will be when the player is playing the game. The GameManagers game loop will be run in this state. When the player pauses the state will switch to Pause. When the player beats a level the state will switch to Loading. If the player dies the state will switch to Gameover.
  • Menu - When the current game state is Menu, Pause, or Gameover, then it will check for controls for the state and call those functions according to the buttons pressed. Update and Draw will be called for the main menu. When starting a new game it will switch to Cinematic. When loading a game it will switch to Loading state.
  • Pause - When the current game state is Menu, Pause, or Gameover, then it will check for controls for the state and call those functions according to the buttons pressed. Update and Draw methods will be called for the pause menu. If the player un-pauses the state will switch to Gameplay. If the player exits it will switch to Menu.
  • Gameover - When the current game state is Menu, Pause, or Gameover, then it will check for controls for the state and call those functions according to the buttons pressed. Update and Draw methods will be called for the game over menu. If the player wants to retry the state will switch to Gameplay. If the player decides to quit then it will switch to Menu state.
  • Cinematic - Will get a list of slides from the loader and will cycle through them with a rate and/or with certain input. In the window class, when it has all of the delegates for controls, it will call the cinematic manager and the cinematic manager will cycle through the slides. At the very end, it will go right to the Gameplay state. The final cinematic will be a special case because that goes back to the menu. The credits will be an option in the main menu.
  • Loading - will be in this state when levels are loading and everything is being initialized. After loading is finished the state will either switch to Cinematic if its a new game, or the start of a new level, or it will switch to Gameplay if a saved game was loaded.
StateMachineDiagram.jpg

This class will have static objects that need to be accessed by other game components, which include Loader, GameContentManager, AudioManager, and CinematicManager. It will also include a separate project InputManager.

Relationships

  • Loader : will load in XML files and pass the data to the managers that need that data
  • InputManager : will add sets of event listeners for the game states that will correspond to controls we press and methods we use when those buttons are pressed.
  • GameManager : manages everything related to gameplay including the camera, player, HUD, EffectManager, and LevelManager.
  • GameContentManager : Loads in and stores all content for the game including audio and images
  • AudioManager : has all audio used in the game and takes care of playing, pausing, and stopping music and sound effects in the game
  • MenuManager : takes care of updating, drawing, and executing menus in the game which includes the main menu and pause menu
  • CinematicManager : takes care of playing cinematics before levels

Members

  • gameState state - the state the game is in
  • Loader loader - the loader for the game. Accessed by the LevelManager to load level data and the CinematicManager to load cinematic data. Will be static so the LevelManager can call the savegame method.
  • InputManager gameplayInput - input manager for the gameplay state.
  • InputManager menuInput - input manager for the menu/pause/gameover states.
  • InputManager cinematicInput - input manager for the cinematic state.
  • GameManager gameManager - the game manager - static
  • GameContentManager content - the content manager for the game. Accessed by other classes that need to load or access audio/images. - static
  • AudioManager audioManager - the audio manager for the game. Accessed by any class that will need to play background music/sound effects - static
  • MenuManager menuManager - the menu manager for the game
  • CinematicManager cinematicManager - the cinematic manager for the game
  • int currentLevel - this will the number of the current level. This will be used when when loading to grab the correct XML file
    ("Level" + currentLevel + ".xml")

Methods

  • Update
    • calls UpdateControls
    • will call update on GameManager in Gameplay state
    • will call update on MenuManager in Menu, Gameover, and Pause state
    • will call update on CinematicManager in cinematic state
    • loading state won't have anything in update. The loading process is explained below.
  • Draw
    • will call draw for GameManager while in Gameplay state
    • will call draw for MenuManager while in Menu, Gameover, and Pause state
    • will call draw for CinematicManager while in Cinematic state
    • will draw the loading screen when in loading state
  • Simulate
    • will call Simulate for any manager that uses threading and is currently active(based on the game state)
  • Window
    • constructor will make and initialize all of the managers
    • It will then set up all of the input event listeners for the different game states
    • first gameState will be set to Menu
  • ChangeState
    • will change the state to which one is passed in. A static method so any class that needs to change the game state can.
  • UpdateControls
    • Each game state will have a set of controls that are associated with it.
    • This will update the correct controls based on the current game state, by updating the listeners in InputManager.

Other Notes

Loading Process

  • When the state is changed to loading in the ChangeState method the currentLevel variable will be used to pass in the correct path to the level xml to the Loader.
  • The Loader will load in the XML document and then go about initializing all the data from it so that data can be passed on to the managers.
  • Each manager that needs data from the loader will have a method that will take in the data as parameters. The loader will use its reference to Window so it can access the methods used to pass in the data. For example, window.cinematic.SetCinematic(slidesData)
  • After the Loader has passed over all the data to the managers, and those managers have initialized everything they need to, it will call ChangeState in this class to switch to the cinematic state.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License