mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-09 21:31:51 +09:00
added sources for Slick
Former-commit-id: 1647fa32ef6894bd7db44f741f07c2f4dcdf9054 Former-commit-id: 0e5810dcfbe1fd59b13e7cabe9f1e93c5542da2d
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package org.newdawn.slick.tests;
|
||||
|
||||
import org.newdawn.slick.AppGameContainer;
|
||||
import org.newdawn.slick.BasicGame;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.ImageBuffer;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
/**
|
||||
* A test for image buffer maniupulation rendering
|
||||
*
|
||||
* @author kevin
|
||||
*/
|
||||
public class ImageBufferTest extends BasicGame {
|
||||
/** The image we're currently displaying */
|
||||
private Image image;
|
||||
|
||||
/**
|
||||
* Create a new image buffer rendering test
|
||||
*/
|
||||
public ImageBufferTest() {
|
||||
super("Image Buffer Test");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
|
||||
*/
|
||||
public void init(GameContainer container) throws SlickException {
|
||||
ImageBuffer buffer = new ImageBuffer(320,200);
|
||||
for (int x=0;x<320;x++) {
|
||||
for (int y=0;y<200;y++) {
|
||||
if (y == 20) {
|
||||
buffer.setRGBA(x, y, 255,255,255,255);
|
||||
} else {
|
||||
buffer.setRGBA(x, y, x,y,0,255);
|
||||
}
|
||||
}
|
||||
}
|
||||
image = buffer.getImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
|
||||
*/
|
||||
public void render(GameContainer container, Graphics g) {
|
||||
image.draw(50,50);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
|
||||
*/
|
||||
public void update(GameContainer container, int delta) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.newdawn.slick.BasicGame#keyPressed(int, char)
|
||||
*/
|
||||
public void keyPressed(int key, char c) {
|
||||
if (key == Input.KEY_ESCAPE) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ImageBufferTest());
|
||||
container.setDisplayMode(800,600,false);
|
||||
container.start();
|
||||
} catch (SlickException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user