Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed the font-size [issue 7] #10

Merged
merged 8 commits into from
Dec 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public final class Renderer2048 {
private static final int TILE_SIDE = 200;
private static final int PADDING = 20;
private static Map<Integer, Color> tileColorMap = new HashMap<>();
private static int fontSize = 100; //set the font size here
Taz03 marked this conversation as resolved.
Show resolved Hide resolved

private Game2048 game;
private final BufferedImage image;

//runs when the class is firstly loaded for one time
Taz03 marked this conversation as resolved.
Show resolved Hide resolved
static {
tileColorMap.put(0, new Color(205, 190, 180));
tileColorMap.put(2, new Color(240, 230, 220));
Expand Down Expand Up @@ -96,7 +98,7 @@ public byte[] getData() {
};

graphics.setColor(Color.BLACK);
graphics.setFont(new Font("Arial", Font.BOLD, 120));
graphics.setFont(new Font("Arial", Font.BOLD, fontSize));
FontMetrics metrics = graphics.getFontMetrics();
graphics.drawString(text,
(image.getWidth() - metrics.stringWidth(text)) / 2,
Expand Down