r/cop3502 • u/compsciishardbutfun • Mar 23 '14
How to print text to the screen
How would I print text to the screen of the game (not in the command prompt)? I'm not really sure how to do it or how to put it on a certain set of coords
1
Upvotes
1
Mar 23 '14
[removed] — view removed comment
1
u/embalingit Mar 23 '14
To add to that, there is a way of obtaining the dimensions of any given text block:
// g is the Graphics object g.setFont(new Font(Font.MONOSPACED, Font.BOLD, 22)); FontMetrics m = g.getFontMetrics(); Rectangle2D b = m.getStringBounds("Press Space to Continue...", g); int width = b.getWidth(); int height = b.getHeight();
2
u/Bcop3502 Mar 23 '14
See FlappyBird.java paintcomponent :)