File tree 4 files changed +17
-13
lines changed
4 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ Startscreen startscreen;
14
14
Game game;
15
15
Highscore highscore;
16
16
17
- PFont font;
17
+ PFont normalFont;
18
+ PFont bigFont;
18
19
19
20
float playerPosX;
20
21
float playerPosY;
@@ -34,9 +35,10 @@ void setup() {
34
35
// scale = 3;
35
36
// On Android
36
37
scale = displayDensity;
37
- font = createFont (" SansSerif" , 60 * scale);
38
38
textWidth = 22 ;
39
39
textWidthBig = 100 ;
40
+ normalFont = createFont (" SansSerif" , textWidth * scale);
41
+ bigFont = createFont (" SansSerif" , textWidthBig * scale);
40
42
gameWidth = width ;
41
43
gameHeight = height ;
42
44
startscreen = new Startscreen ();
Original file line number Diff line number Diff line change @@ -38,10 +38,10 @@ class Highscore{
38
38
}else {
39
39
shape (restartButton, gameWidth/ 2 , gameHeight- (gameHeight/ 5 ));
40
40
textAlign (CENTER );
41
- textFont (font, textWidth * scale );
41
+ textFont (normalFont );
42
42
fill (50 );
43
43
text (restart, gameWidth/ 2 , gameHeight- (gameHeight/ 5 )+ (textAscent ()/ 2 ));
44
- textFont (font, textWidthBig * scale );
44
+ textFont (bigFont );
45
45
fill (yellow);
46
46
text (score, gameWidth/ 2 , gameHeight/ 2 );
47
47
}
Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ class Startscreen{
13
13
float buttonXRight;
14
14
float buttonYTop;
15
15
float buttonYBottom;
16
-
16
+
17
17
public Startscreen ( ) {
18
18
rectMode (CENTER );
19
19
init();
20
20
}
21
21
22
22
void init ( ) {
23
- textFont (font, textWidth * scale );
23
+ textFont (normalFont );
24
24
start = " START" ;
25
25
startButtonWidth = textWidth (start)* 3 ;
26
26
startButtonHeight = textAscent ()* 3.5 ;
Original file line number Diff line number Diff line change @@ -4,22 +4,24 @@ Helper class printing the current game state on screen
4
4
*/
5
5
class StatsPrinter {
6
6
7
+ float dynamicTextHeight;
7
8
float offset;
8
9
String scoreText;
9
10
String livesText;
10
-
11
- public StatsPrinter (){
12
- textFont (font, textWidth * scale);
13
- offset = textAscent ();
11
+
12
+ public StatsPrinter () {
13
+ textFont (normalFont);
14
+ dynamicTextHeight = textAscent ();
15
+ offset = 5 * scale;
14
16
}
15
-
17
+
16
18
void print (int lives , int score ) {
17
19
scoreText= " Score: " + score;
18
20
livesText = " Lives: " + lives;
19
21
fill (255 );
20
22
textAlign (LEFT );
21
- text (scoreText, 0 + offset, textWidth + offset);
23
+ text (scoreText, offset, dynamicTextHeight + offset);
22
24
textAlign (RIGHT );
23
- text (livesText, gameWidth- offset, textWidth + offset);
25
+ text (livesText, gameWidth - offset, dynamicTextHeight + offset);
24
26
}
25
27
}
You can’t perform that action at this time.
0 commit comments