Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>main
parent
6a418eb9db
commit
bf59e5c7c2
@ -0,0 +1,46 @@ |
|||||||
|
package sig.engine; |
||||||
|
|
||||||
|
public enum Font { |
||||||
|
PROFONT_12((byte)7,(byte)14,Sprite.PROFONT), |
||||||
|
; |
||||||
|
|
||||||
|
byte glyphWidth,glyphHeight; |
||||||
|
int glyphCountX,glyphCountY; |
||||||
|
Rectangle[] charBounds; |
||||||
|
Sprite spr; |
||||||
|
|
||||||
|
Font(byte glyphWidth, byte glyphHeight, Sprite spr) { |
||||||
|
this.glyphWidth=glyphWidth; |
||||||
|
this.glyphHeight=glyphHeight; |
||||||
|
this.glyphCountX=spr.width/glyphWidth; |
||||||
|
this.glyphCountY=spr.height/glyphHeight; |
||||||
|
this.charBounds = new Rectangle[256]; |
||||||
|
for (int y=0;y<glyphCountY;y++) { |
||||||
|
for (int x=0;x<glyphCountX;x++) { |
||||||
|
if (y*glyphCountX+x<256) { |
||||||
|
charBounds[y*glyphCountX+x]=new Rectangle(x*glyphWidth,y*glyphHeight,glyphWidth,glyphHeight); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
this.spr=spr; |
||||||
|
} |
||||||
|
|
||||||
|
public Rectangle getCharacterBounds(char c) { |
||||||
|
return charBounds[c]; |
||||||
|
} |
||||||
|
|
||||||
|
public byte getGlyphWidth() { |
||||||
|
return glyphWidth; |
||||||
|
} |
||||||
|
|
||||||
|
public byte getGlyphHeight() { |
||||||
|
return glyphHeight; |
||||||
|
} |
||||||
|
public Rectangle getCharInfo(char c) { |
||||||
|
return charBounds[c]; |
||||||
|
} |
||||||
|
|
||||||
|
public Sprite getSprite() { |
||||||
|
return spr; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package sig.engine; |
||||||
|
|
||||||
|
public class Rectangle { |
||||||
|
int x,y,w,h; |
||||||
|
|
||||||
|
public Rectangle(int x, int y, int w, int h) { |
||||||
|
this.x = x; |
||||||
|
this.y = y; |
||||||
|
this.w = w; |
||||||
|
this.h = h; |
||||||
|
} |
||||||
|
|
||||||
|
public int getX() { |
||||||
|
return x; |
||||||
|
} |
||||||
|
|
||||||
|
public void setX(int x) { |
||||||
|
this.x = x; |
||||||
|
} |
||||||
|
|
||||||
|
public int getY() { |
||||||
|
return y; |
||||||
|
} |
||||||
|
|
||||||
|
public void setY(int y) { |
||||||
|
this.y = y; |
||||||
|
} |
||||||
|
|
||||||
|
public int getWidth() { |
||||||
|
return w; |
||||||
|
} |
||||||
|
|
||||||
|
public void setWidth(int w) { |
||||||
|
this.w = w; |
||||||
|
} |
||||||
|
|
||||||
|
public int getHeight() { |
||||||
|
return h; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHeight(int h) { |
||||||
|
this.h = h; |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue