Hello all it has again been a while since the last time I did any development but I did stumble on something that made me giggle.
{ 0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E } = smile
0x7E = 01111110
0x81 = 10000001
0xA5 = 10100101
0x81 = 10000001
0xBD = 10111101
0x99 = 10011001
0x81 = 10000001
0x7E = 01111110
111111
1 1
1 1 1 1
1 1
1 1111 1
1 11 1
1 1
111111
//To set a bit in a byte on you do the following.
byte = byte | (1 << index);
//To set a bit in a byte off you do the following.
byte = byte & ~(1 << index);
//To read a bit form a byte you do the following.
boolean bitIsOn = ((byte >> index) & 1) == 1;
//Convert bytes to pixels
for(int y = 0; y < 8; y++) {
byte smileData = smile[y];
for(int x = 0; x < 8; x++) {
if(((smileData >> x) & 1) == 1) {
image.setPixel(x, y, 0xFFFFFFFF);
}
}
}
public void drawASCII(String string, int x, int y, int color) {
for(int index = 0; index < string.length(); index++) {
char c = string.charAt(index);
drawASCII(c, offset, y, color);
x += 8;
}
}
public void drawASCII(char c, int x, int y, int color) {
int minX = Math.max(0, x);
int maxX = Math.min(x + 8, width);
int minY = Math.max(0, y);
int maxY = Math.min(y + 8, height);
for(int yy = minY; yy < maxY; yy++) {
for(int xx = minX; xx < maxX; xx++) {
if(Font.hasData(c, xx - x, yy - y)) {
drawPixel(xx, yy, color);
}
}
}
}
Oooh! Oooh! Me too!
I made this originally for js13k. :) It's a 5x5 font, capital A-Z only.I was originally going to just use a long but there is no way of doing this in Java because I would need to use an unsigned long because there is no way to bit shift to the upper bytes in a long, I could use Bignum but this would give me object overhead and be a huge pain to work with. I am probably going to stop development in Java 1.1 because i seriously doubt that anyone is going to create a VM for Windows95 or old version of Linux just to test out my game.
and thank you!