# HG changeset patch # User Matti Hamalainen # Date 1299118495 -7200 # Node ID 43f68fe605deadbacfda71550aa88ca2000c5543 # Parent b586ce4f6d97be86903dd10145a174a08627fa57 More cleanups. diff -r b586ce4f6d97 -r 43f68fe605de game/Engine.java --- a/game/Engine.java Thu Mar 03 04:04:57 2011 +0200 +++ b/game/Engine.java Thu Mar 03 04:14:55 2011 +0200 @@ -23,6 +23,12 @@ BufferedImage aboutImg; boolean aboutSecret; + IDMPoint currPos, currOffs; + Paint textPaint; + Font textFont; + FontMetrics textMetrics; + + public AboutBox() { try { @@ -39,11 +45,6 @@ setSize(600f, 400f); } - IDMPoint currPos, currOffs; - Paint textPaint; - Font textFont; - FontMetrics textMetrics; - public void setTextFont(Font font, FontMetrics metrics) { textFont = font; @@ -70,6 +71,7 @@ { Paint savePaint = g.getPaint(); g.setPaint(textPaint); + g.setFont(textFont); int i = 0; while (i < text.length()) @@ -95,7 +97,7 @@ if (linefeed) { currOffs.x = 0; - currOffs.y += textMetrics.getMaxDescent();; + currOffs.y += textMetrics.getHeight(); } else { @@ -114,23 +116,24 @@ g.setPaint(new Color(0.0f, 0.0f, 0.0f, 0.6f)); g.fill(new RoundRectangle2D.Float(x, y, w, h, 10, 10)); - setTextFont(G.fonts[1], G.metrics[1]); + setTextFont(G.fonts[3], G.metrics[3]); setTextPaint(Color.white); - setCurrPos(x + 15, y + 15); - drawString(g, "RistiPolku (CrossPaths) v0.5"); + setCurrPos(x + 20, y + 30); + drawString(g, "RistiPolku (CrossPaths) v0.5\n"); + setTextFont(G.fonts[1], G.metrics[1]); if (aboutSecret) { - g.drawImage(aboutImg, x + 15, y + 35, aboutImg.getWidth(), aboutImg.getHeight(), null); + g.drawImage(aboutImg, x + 20, y + 55, aboutImg.getWidth(), aboutImg.getHeight(), null); - setCurrPos(x + 225, y + 55); + setCurrPos(x + 225, y + 75); drawString(g, "Dedicated to my\n" + - "favorite woman" + + "favorite woman\n" + "in the world."); - setCurrPos(x + 350, y + 155); + setCurrPos(x + 370, y + 175); drawString(g, "- Matti"); } else @@ -231,12 +234,10 @@ public boolean contains(float x, float y) { - boolean foo = (x >= getScaledX() && + return (x >= getScaledX() && y >= getScaledY() && x < getScaledX() + boardSize * pscale && y < getScaledY() + boardSize * pscale); - System.out.print("contains "+x+", "+y+" ("+getScaledX()+", "+getScaledY()+", "+(getScaledX() + boardSize * pscale)+"): "+foo+"\n"); - return foo; } public void animate(float time) @@ -390,25 +391,9 @@ return true; } -/* - public boolean mouseClicked(MouseEvent e) - { - if (flagGameOver) - return false; - - if (contains(e.getPoint())) - { - pieceFinishTurn(); - return true; - } - else - return false; - } -*/ - public void clicked() { - pieceFinishTurn(); + pieceFinishTurn(); } public boolean keyPressed(KeyEvent e) @@ -474,6 +459,7 @@ G.fonts[0] = Font.createFont(Font.TRUETYPE_FONT, res.getStream()); G.fonts[1] = G.fonts[0].deriveFont(24f); G.fonts[2] = G.fonts[0].deriveFont(64f); + G.fonts[3] = G.fonts[0].deriveFont(32f); } catch (FontFormatException e) diff -r b586ce4f6d97 -r 43f68fe605de game/G.java --- a/game/G.java Thu Mar 03 04:04:57 2011 +0200 +++ b/game/G.java Thu Mar 03 04:14:55 2011 +0200 @@ -15,7 +15,7 @@ public class G { - public static final int numFonts = 3; + public static final int numFonts = 4; public static Font fonts[]; public static FontMetrics metrics[];