Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 5:12 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jul 11, 2012 8:05 pm 
Offline

Joined: Wed Jul 11, 2012 7:41 pm
Posts: 3
Good evening,

I started playing with LWJGL to make a Pong clone, and eventually needed to use Slick2D to add text to my game.
I downloaded a custom font and used this piece of code:
Code:
      try {   
         String fontPath = "./pong/font.ttf";
         font = new UnicodeFont(fontPath, 72, false, false);
         font.addGlyphs("0123456789");
         font.getEffects().add(new ColorEffect(Color.WHITE));
         font.loadGlyphs();
      } catch (Exception e) {
         e.printStackTrace();
      }   


I then use this piece of code, to print the score of the players:
Code:
      font.drawString(100, 50, "" + scoreP1);
      font.drawString(WIDTH - 120, 50, "" + scoreP2);


The problem is that when the score of P2 contains a "0" (0, 10, 20, 30, etc.) nothing more is displayed, except the scores.
The score of P1 doesn't affect the drawing of the game.

The downloaded font is called "pixel-siggy".

Any help is aprecciated.

Best regards,
Pedro


Attachments:
File comment: 10-11
pong1.png
pong1.png [ 31.46 KiB | Viewed 125 times ]
File comment: 10-10
pong.png
pong.png [ 42.43 KiB | Viewed 125 times ]


Last edited by pmh.pereira on Thu Jul 12, 2012 9:09 am, edited 1 time in total.
Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 9:07 am 
Offline
User avatar

Joined: Wed Jun 20, 2012 8:10 pm
Posts: 54
Have you tried to use : String.valueOf(scoreP1) to be sure the object is actually a string?

_________________
Seventeen


Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 9:08 am 
Offline

Joined: Wed Jul 11, 2012 7:41 pm
Posts: 3
Solved the problem using AngelFont. :)


Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 9:11 am 
Offline

Joined: Wed Jul 11, 2012 7:41 pm
Posts: 3
Seventeen wrote:
Have you tried to use : String.valueOf(scoreP1) to be sure the object is actually a string?


I actually tried using fixed strings like "0", "10", "100".
Everytime the string contained a 0 (zero) nothing more was drawed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group