From 68d145d4ad8dac7fca1a7a00a12ad5134eae0169 Mon Sep 17 00:00:00 2001 From: yangxvlin <1768528843@qq.com> Date: Wed, 31 Mar 2021 22:52:59 +1100 Subject: [PATCH] finish Q3d with println commented --- src/Q3.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Q3.java b/src/Q3.java index 1b94540..8fd0e8b 100644 --- a/src/Q3.java +++ b/src/Q3.java @@ -35,6 +35,12 @@ public class Q3 extends AbstractGame { // (x2; y2) is given by: d_12 = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)) private static final double SCORE_DISTANCE = 20; + // (d) Instead of printing the greeting to the console, draw the text to the screen using the font provided + // (res/conformable.otf). Draw it in size 24 font at coordinate (32, 32). (See the Font class in Bagel + // documentation.) + private final Font font = new Font("res/conformable.otf", 24); + private static final Point FONT_POSITION = new Point(32, 32); + public static void main(String[] args) { new Q3().run(); } @@ -57,7 +63,8 @@ public class Q3 extends AbstractGame { // (d) if (new Point(playerX, playerY).distanceTo(BALL_POSITION) <= SCORE_DISTANCE) { - System.out.println("Great job!"); + // System.out.println("Great job!"); + font.drawString("Great job!", FONT_POSITION.x, FONT_POSITION.y); } playerImage.draw(playerX, playerY); -- GitLab