Package com.screens

Class MinigameScreen

  • All Implemented Interfaces:
    com.badlogic.gdx.Screen

    public class MinigameScreen
    extends java.lang.Object
    implements com.badlogic.gdx.Screen
    MinigameScreen, as suggested, a Mini game contained within the game, which allows the player to play a different style of game ("whack-a-mole"), but keeping the same theme (aliens and fire trucks). Players can earn score which is transferred into the main game after 30 seconds
    • Constructor Summary

      Constructors 
      Constructor Description
      MinigameScreen​(Kroy game, GameScreen gameScreen, MinigameSprite sprite)
      ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Changed the background image to keep the minigame more inline with the main game.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkAlienDespawn()
      ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Added a clause to end the game when an alien reaches the end, also decreases the furthest position an alien can spawn by 1 Check if an alien on the screen is ready to be despawned by being clicked on or by the timer
      void dispose()  
      Constants.AlienType generateType()
      Generates a random number between 0.0 and 1.0 then rounds up to the nearest value in the map - this allows a random patrol type to be selected but has a higher probability of choosing lower scoring patrols over higher scoring patrols
      com.badlogic.gdx.graphics.OrthographicCamera getCamera()  
      java.util.ArrayList<Alien> getOnScreenETs()  
      int getScore()  
      void hide()  
      void pause()  
      void render​(float delta)  
      void resize​(int width, int height)  
      void resume()  
      void setCanSpray​(boolean b)
      Means that the water can spray and destroy aliens in that location
      void setScreenDimensions​(int width, int height)  
      void setTouch​(int x, int y)
      Sets the position of the water object and set where the player clicked
      void show()  
      void spawnAlien()
      ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Now increments the current row by 2 each call and spawns an alien at the front of the queue Spawns an alien and resets the spawn timer
      void toGameScreen​(boolean win)
      ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Added ability to lose the game, score affected by win parameter Goes back to the game screen once the user presses escape, when the time runs out, or if the player loses
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MinigameScreen

        public MinigameScreen​(Kroy game,
                              GameScreen gameScreen,
                              MinigameSprite sprite)
        ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Changed the background image to keep the minigame more inline with the main game. Aliens now spawn in the top right window and make their way to the bottom. The player must survive for 30 seconds in order to gain points, if the aliens reach the bottom the player loses and their score is set to 0 and the minigame ends. If the player wins they gain their score and the minigame is removed from the main game. Constructor for minigame screen which is called when the player drives over MinigameSprite in GameScreen
        Parameters:
        game - to change screen and access shared batch
        gameScreen - to return back to after minigame completion
        sprite - the minigame sprite that triggered the game
    • Method Detail

      • show

        public void show()
        Specified by:
        show in interface com.badlogic.gdx.Screen
      • render

        public void render​(float delta)
        Specified by:
        render in interface com.badlogic.gdx.Screen
      • resize

        public void resize​(int width,
                           int height)
        Specified by:
        resize in interface com.badlogic.gdx.Screen
      • pause

        public void pause()
        Specified by:
        pause in interface com.badlogic.gdx.Screen
      • resume

        public void resume()
        Specified by:
        resume in interface com.badlogic.gdx.Screen
      • hide

        public void hide()
        Specified by:
        hide in interface com.badlogic.gdx.Screen
      • dispose

        public void dispose()
        Specified by:
        dispose in interface com.badlogic.gdx.Screen
      • checkAlienDespawn

        public void checkAlienDespawn()
        ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Added a clause to end the game when an alien reaches the end, also decreases the furthest position an alien can spawn by 1 Check if an alien on the screen is ready to be despawned by being clicked on or by the timer
      • spawnAlien

        public void spawnAlien()
        ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Now increments the current row by 2 each call and spawns an alien at the front of the queue Spawns an alien and resets the spawn timer
      • generateType

        public Constants.AlienType generateType()
        Generates a random number between 0.0 and 1.0 then rounds up to the nearest value in the map - this allows a random patrol type to be selected but has a higher probability of choosing lower scoring patrols over higher scoring patrols
        Returns:
        type of alien
      • toGameScreen

        public void toGameScreen​(boolean win)
        ======================================================================= Modified for Assessment 4 @author Archie Godfrey ======================================================================= Added ability to lose the game, score affected by win parameter Goes back to the game screen once the user presses escape, when the time runs out, or if the player loses
        Parameters:
        win - Whether the player won the minigame (true) or not (false)
      • setTouch

        public void setTouch​(int x,
                             int y)
        Sets the position of the water object and set where the player clicked
        Parameters:
        x - position of water
        y - position of water
      • setCanSpray

        public void setCanSpray​(boolean b)
        Means that the water can spray and destroy aliens in that location
        Parameters:
        b - true if water can spray false otherwise
      • getCamera

        public com.badlogic.gdx.graphics.OrthographicCamera getCamera()
      • getOnScreenETs

        public java.util.ArrayList<Alien> getOnScreenETs()
      • setScreenDimensions

        public void setScreenDimensions​(int width,
                                        int height)
      • getScore

        public int getScore()