-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEndScreen.java
More file actions
59 lines (50 loc) · 1.78 KB
/
Copy pathEndScreen.java
File metadata and controls
59 lines (50 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import processing.core.PImage;
public class EndScreen implements Renderable{
private final Main main;
private EndType endType;
private final PImage wonImage, lostImage, newGameImage;
private final float centerX;
private final float titleY;
private final float newGameY;
private final float newGameWidth, newGameHeight;
public EndScreen(){
this.main = Main.getInstance();
this.centerX = Main.getInstance().width / 2;
this.titleY = Main.getInstance().height * .3F;
this.newGameY = Main.getInstance().height * .6F;
this.newGameHeight = Main.getInstance().height * .1F;
this.newGameWidth = Main.getInstance().width * .5F;
this.wonImage = main.loadImage("won.png");
this.lostImage = main.loadImage("lost.png");
this.newGameImage = main.loadImage("new_game.png");
}
public void render(){
main.imageMode(main.CENTER);
switch (endType) {
case WIN:
main.image(wonImage, centerX, titleY);
break;
case LOSE:
main.image(lostImage, centerX, titleY);
break;
}
// new game button
main.rectMode(main.CENTER);
main.fill(33, 136, 56);
main.rect(centerX, newGameY, newGameWidth, newGameHeight);
main.image(newGameImage, centerX, newGameY);
}
public void show(EndType endType){
this.endType = endType;
}
public void click(){
if(main.mouseX >= centerX - newGameWidth / 2 && main.mouseX <= centerX + newGameWidth / 2 &&
main.mouseY >= newGameY - newGameHeight / 2 && main.mouseY <= newGameY + newGameHeight / 2){
main.bringToTitleScreen();
}
}
public enum EndType{
WIN,
LOSE
}
}