I am a beginner at Java
public void drawScore() {
scoreFont = createFont("Bauhaus 93", 26, true);
textFont(scoreFont);
fill(255,255,255);
textAlign(CENTER);
text("Score: " + score, width - 90, 40);
}
I don’t know how to make it so that it actually functions when I run the program.
1 Like
glv
July 25, 2019, 8:31pm
2
1 Like
kosi559:
drawScore() {
In draw() say:
drawScore();
this calls / runs the function you defined above
1 Like
actually, to save processor time, it’s wise to initialize the font in setup()
(which runs only once, whereas draw()
runs on and on 60 times per second (and so does drawScore()
when you call it from draw()
))
So I did a bit of a re-write here
Chrisir
PFont scoreFont;
int score=0;
void setup() {
size (1400, 800);
background(0);
scoreFont = createFont("Bauhaus 93", 26, true);
}
void draw() {
background(0);
drawScore();
}
void drawScore() {
textFont(scoreFont);
fill(255, 255, 255);
textAlign(CENTER);
text("Score: " + score,
width - 90, 40);
}
//
1 Like