This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinigame.java
94 lines (81 loc) · 1.61 KB
/
Minigame.java
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* A minigame
*
* Last edit: 6/3/2020
* @author Eric
* @version 1.0
* @since 1.0
*/
import java.awt.*;
import javax.swing.*;
public abstract class Minigame {
/**
* Contains the minigame graphics / GUI
*/
protected MinigameDrawing drawing;
/**
* The score of the game
*/
protected int score = 0;
/**
* The score of the game
*/
protected boolean start = true;
/**
* The score of the game
*/
protected boolean end = false;
/**
* Info box
*/
protected Dialogue infoCard;
/**
* The BGM of the game
*/
protected BGM bgm;
/**
* Increase the score by an amount
* @param add
*/
protected void changeScore(double amount) {
score += amount;
}
/**
* Set the score to an amount
* @param set
*/
protected void set(int amount) {
score = amount;
}
/**
* Reset the score to zero
*/
protected void clear() {
score = 0;
}
/**
* Get the current score
* @return score
*/
protected double getScore() {
return score;
}
public abstract class MinigameDrawing extends JComponent {
/**
* Draw the actual display
* @param g the Graphics object to draw on
*/
public abstract void display(Graphics g);
/**
* Paint method of JComponent
* @param g the Graphics object to draw on
*/
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
try {
display(g);
} catch (Exception e) {}
}
}
}