Package com.screens
Class MinigameScreen
- java.lang.Object
-
- com.screens.MinigameScreen
-
- All Implemented Interfaces:
com.badlogic.gdx.Screen
public class MinigameScreen extends java.lang.Object implements com.badlogic.gdx.ScreenMinigameScreen, 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 voidcheckAlienDespawn()======================================================================= 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 timervoiddispose()Constants.AlienTypegenerateType()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 patrolscom.badlogic.gdx.graphics.OrthographicCameragetCamera()java.util.ArrayList<Alien>getOnScreenETs()intgetScore()voidhide()voidpause()voidrender(float delta)voidresize(int width, int height)voidresume()voidsetCanSpray(boolean b)Means that the water can spray and destroy aliens in that locationvoidsetScreenDimensions(int width, int height)voidsetTouch(int x, int y)Sets the position of the water object and set where the player clickedvoidshow()voidspawnAlien()======================================================================= 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 timervoidtoGameScreen(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
-
-
-
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 overMinigameSpriteinGameScreen- Parameters:
game- to change screen and access shared batchgameScreen- to return back to after minigame completionsprite- the minigame sprite that triggered the game
-
-
Method Detail
-
show
public void show()
- Specified by:
showin interfacecom.badlogic.gdx.Screen
-
render
public void render(float delta)
- Specified by:
renderin interfacecom.badlogic.gdx.Screen
-
resize
public void resize(int width, int height)- Specified by:
resizein interfacecom.badlogic.gdx.Screen
-
pause
public void pause()
- Specified by:
pausein interfacecom.badlogic.gdx.Screen
-
resume
public void resume()
- Specified by:
resumein interfacecom.badlogic.gdx.Screen
-
hide
public void hide()
- Specified by:
hidein interfacecom.badlogic.gdx.Screen
-
dispose
public void dispose()
- Specified by:
disposein interfacecom.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 watery- position of water
-
setCanSpray
public void setCanSpray(boolean b)
Means that the water can spray and destroy aliens in that location- Parameters:
b-trueif water can sprayfalseotherwise
-
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()
-
-