mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
added sources for Slick
Former-commit-id: 1647fa32ef6894bd7db44f741f07c2f4dcdf9054 Former-commit-id: 0e5810dcfbe1fd59b13e7cabe9f1e93c5542da2d
This commit is contained in:
85
lib/slick-source/org/newdawn/slick/tests/FlashTest.java
Normal file
85
lib/slick-source/org/newdawn/slick/tests/FlashTest.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package org.newdawn.slick.tests;
|
||||
|
||||
import org.newdawn.slick.AppGameContainer;
|
||||
import org.newdawn.slick.BasicGame;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
/**
|
||||
* A test for image flashes
|
||||
*
|
||||
* @author kevin
|
||||
*/
|
||||
public class FlashTest extends BasicGame {
|
||||
/** The TGA image loaded */
|
||||
private Image image;
|
||||
/** True if the image is rendered flashed */
|
||||
private boolean flash;
|
||||
/** The container for the test */
|
||||
private GameContainer container;
|
||||
|
||||
/**
|
||||
* Create a new image rendering test
|
||||
*/
|
||||
public FlashTest() {
|
||||
super("Flash Test");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
|
||||
*/
|
||||
public void init(GameContainer container) throws SlickException {
|
||||
this.container = container;
|
||||
|
||||
image = new Image("testdata/logo.tga");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
|
||||
*/
|
||||
public void render(GameContainer container, Graphics g) {
|
||||
g.drawString("Press space to toggle",10,50);
|
||||
if (flash) {
|
||||
image.draw(100,100);
|
||||
} else {
|
||||
image.drawFlash(100,100,image.getWidth(), image.getHeight(), new Color(1,0,1f,1f));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
|
||||
*/
|
||||
public void update(GameContainer container, int delta) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point to our test
|
||||
*
|
||||
* @param argv The arguments to pass into the test
|
||||
*/
|
||||
public static void main(String[] argv) {
|
||||
try {
|
||||
AppGameContainer container = new AppGameContainer(new FlashTest());
|
||||
container.setDisplayMode(800,600,false);
|
||||
container.start();
|
||||
} catch (SlickException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#keyPressed(int, char)
|
||||
*/
|
||||
public void keyPressed(int key, char c) {
|
||||
if (key == Input.KEY_SPACE) {
|
||||
flash = !flash;
|
||||
}
|
||||
if (key == Input.KEY_ESCAPE) {
|
||||
container.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user