Coverage Summary for Class: GameOverScreen (com.mozarellabytes.kroy.Screens)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
GameOverScreen | 0% (0/ 1) | 0% (0/ 3) | 0% (0/ 21) |
1 package com.mozarellabytes.kroy.Screens;
2
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.Screen;
5 import com.badlogic.gdx.graphics.GL20;
6 import com.badlogic.gdx.graphics.OrthographicCamera;
7 import com.badlogic.gdx.graphics.Texture;
8 import com.badlogic.gdx.graphics.g2d.GlyphLayout;
9 import com.mozarellabytes.kroy.Kroy;
10 import com.mozarellabytes.kroy.Utilities.GameOverInputHandler;
11
12 /** This screen is shown after the game has ended.
13 * It tells the player if they have won or lost.
14 */
15
16 public class GameOverScreen implements Screen {
17
18 /** The game - to be able to use the fonts from game */
19 private final Kroy game;
20
21 /** The texture that makes up the background screen */
22 private final Texture backgroundLogo;
23
24 /** Camera to set the projection for the screen */
25 private final OrthographicCamera camera;
26
27 /** The format that the text will be displayed in */
28 private final GlyphLayout layout;
29
30 /** The text that will be displayed to the screen */
31 private String text;
32
33 /** Constructor for the game screen
34 * @param game LibGdx game
35 * @param won <code> true </code> if the game was won
36 * <code> false </code> if th game was lost
37 */
38 public GameOverScreen(Kroy game, boolean won) {
39 this.game = game;
40 camera = new OrthographicCamera();
41 camera.setToOrtho(false, Gdx.graphics.getDisplayMode().width, Gdx.graphics.getDisplayMode().height);
42
43 backgroundLogo = new Texture(Gdx.files.internal("images/backgroundLogo.png"), true);
44 backgroundLogo.setFilter(Texture.TextureFilter.MipMapLinearNearest, Texture.TextureFilter.MipMapLinearNearest);
45
46 Gdx.input.setInputProcessor(new GameOverInputHandler(game));
47
48 layout = new GlyphLayout();
49 if (won) {
50 this.text = "We did it! Good job little guy.";
51 } else {
52 this.text = "Mission Failed. We'll get 'em next time.";
53 }
54 this.text = this.text + "\n" + " Click to return to the main menu...";
55 layout.setText(game.font26, this.text);
56 }
57
58 @Override
59 public void show() {
60
61 }
62
63 /** Renders the game over screen
64 *
65 * @param delta The time in seconds since the last render. */
66 @Override
67 public void render(float delta) {
68 Gdx.gl.glClearColor(51/255f, 34/255f, 99/255f, 1f);
69 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
70
71 camera.update();
72 game.batch.setProjectionMatrix(camera.combined);
73
74 game.batch.begin();
75 game.font26.draw(game.batch, this.text, camera.viewportWidth/2 - layout.width/2, camera.viewportHeight/2 - layout.height/2);
76 game.batch.end();
77 }
78
79 @Override
80 public void resize(int width, int height) {
81
82 }
83
84 @Override
85 public void pause() {
86
87 }
88
89 @Override
90 public void resume() {
91
92 }
93
94 @Override
95 public void hide() {
96
97 }
98
99 /** Called when this screen should release all resources. */
100 @Override
101 public void dispose() {
102 backgroundLogo.dispose();
103 }
104
105
106 }