2) Next week I'm going to finish up the HUD, then I'll go on to getting joystick input.
3) Here is the bitmap font code :
package seniorproj;
import java.util.HashMap;
import java.awt.image.*;
import java.awt.*;
public class BitmapFont {
private HashMap img_list;
private int cell_size;
public BitmapFont(int size, Color c){
img_list=new HashMap();
cell_size=size;
//numbers
for(int xx=48;xx<=57;xx++){
BufferedImage b = new BufferedImage(size,size*2,BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = b.createGraphics();
g2.setFont(new Font("Arial",0,size));
g2.setPaint(c);
g2.drawString(Character.toString((char)xx),size/2,size);
img_list.put(Character.toString((char)xx),b);
}
//uppercase
for(int xx=65;xx<=90;xx++){
BufferedImage b = new BufferedImage(size,size*2,BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = b.createGraphics();
g2.setFont(new Font("Arial",0,size));
g2.setPaint(c);
g2.drawString(Character.toString((char)xx),size/2,size);
img_list.put(Character.toString((char)xx),b);
}
//lowercase
for(int xx=97;xx<=122;xx++){
BufferedImage b = new BufferedImage(size,size*2,BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = b.createGraphics();
g2.setFont(new Font("Arial",0,size));
g2.setPaint(c);
g2.drawString(Character.toString((char)xx),size/2,size);
img_list.put(Character.toString((char)xx),b);
}
}
public void render_string(Graphics2D g2,int x, int y, String str, float rw, float rh){
for(int xx=0;xx
HEre is the render function:
ReplyDeletepublic void render_string(Graphics2D g2,int x, int y, String str, float rw, float rh){
for(int xx=0;xx<str.length();xx++){
BufferedImage b = img_list.get(Character.toString((char)str.charAt(xx)));
g2.drawImage(b,x+xx*cell_size,y,(int)(cell_size*rw),(int)(cell_size*2*rh),null);
}
}