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(); } } }