mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-08 04:41:51 +09:00
Former-commit-id: 1647fa32ef6894bd7db44f741f07c2f4dcdf9054 Former-commit-id: 0e5810dcfbe1fd59b13e7cabe9f1e93c5542da2d
83 lines
2.1 KiB
Java
83 lines
2.1 KiB
Java
package org.newdawn.slick.tests;
|
|
|
|
import org.newdawn.slick.*;
|
|
import org.newdawn.slick.util.Log;
|
|
|
|
/**
|
|
* Tests the SpriteSheetFont.
|
|
*
|
|
* @author Onno Scheffers
|
|
*/
|
|
public class SpriteSheetFontTest extends BasicGame {
|
|
/**
|
|
* The font we're going to use to render
|
|
*/
|
|
private Font font;
|
|
|
|
/**
|
|
* Create a new test for font rendering
|
|
*/
|
|
public SpriteSheetFontTest() {
|
|
super("SpriteSheetFont Test");
|
|
}
|
|
|
|
/**
|
|
* @see org.newdawn.slick.Game#init(org.newdawn.slick.GameContainer)
|
|
*/
|
|
public void init(GameContainer container) throws SlickException {
|
|
SpriteSheet sheet = new SpriteSheet("testdata/spriteSheetFont.png", 32, 32);
|
|
font = new SpriteSheetFont(sheet, ' ');
|
|
}
|
|
|
|
/**
|
|
* @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer,org.newdawn.slick.Graphics)
|
|
*/
|
|
public void render(GameContainer container, Graphics g) {
|
|
g.setBackground(Color.gray);
|
|
font.drawString(80, 5, "A FONT EXAMPLE", Color.red);
|
|
font.drawString(100, 50, "A MORE COMPLETE LINE");
|
|
}
|
|
|
|
/**
|
|
* @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer,int)
|
|
*/
|
|
public void update(GameContainer container, int delta) throws SlickException {
|
|
}
|
|
|
|
/**
|
|
* @see org.newdawn.slick.BasicGame#keyPressed(int, char)
|
|
*/
|
|
public void keyPressed(int key, char c) {
|
|
if (key == Input.KEY_ESCAPE) {
|
|
System.exit(0);
|
|
}
|
|
if (key == Input.KEY_SPACE) {
|
|
try {
|
|
container.setDisplayMode(640, 480, false);
|
|
} catch (SlickException e) {
|
|
Log.error(e);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The container we're using
|
|
*/
|
|
private static AppGameContainer container;
|
|
|
|
/**
|
|
* Entry point to our test
|
|
*
|
|
* @param argv The arguments passed in the test
|
|
*/
|
|
public static void main(String[] argv) {
|
|
try {
|
|
container = new AppGameContainer(new SpriteSheetFontTest());
|
|
container.setDisplayMode(800, 600, false);
|
|
container.start();
|
|
} catch (SlickException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|