Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.Input;
- import org.newdawn.slick.SlickException;
- import org.newdawn.slick.util.Log;
- public class BugTest extends BasicGame{
- public final static Color down = Color.yellow;
- public final static Color released = Color.white;
- public final static String[] names = {"LSHIFT", "RSHIFT", "LCTRL", "SPACE", "X"};
- public final static int[] codes = {Input.KEY_LSHIFT, Input.KEY_RSHIFT, Input.KEY_LCONTROL, Input.KEY_SPACE, Input.KEY_X};
- public static void main(String[] args) throws Exception
- {
- BugTest test = new BugTest();
- AppGameContainer container = new AppGameContainer(test);
- container.setShowFPS(false);
- container.setDisplayMode(640, 480, false);
- container.start();
- }
- private boolean[] states = { false, false, false, false, false };
- public BugTest() {
- super("Shift hang test");
- }
- @Override
- public void update(GameContainer container, int delta)
- throws SlickException {
- Input i = container.getInput();
- for(int x = 0; x < codes.length; x++)
- {
- if(i.isKeyDown(codes[x]))
- {
- Log.info(String.format("Down: %s", names[x]));
- states[x] = true;
- }
- else
- {
- states[x] = false;
- }
- }
- }
- @Override
- public void render(GameContainer container, Graphics g) throws SlickException {
- g.setColor(Color.white);
- g.drawString("Keys registered for the test: ", 0, 0);
- for(int index = 0; index < codes.length; index ++)
- {
- g.setColor(states[index] ? down : released);
- g.drawString(String.format("%s: %s", names[index], states[index] ? "down" : "released"), 20, (index +1 )* 20);
- }
- }
- @Override
- public void init(GameContainer container) throws SlickException {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement