After a lot more work, my <1kb Roguelike has evolved somewhat since I first posted it, but this is the final version. This challenge was a lot of fun.
Now a zombie apocalypse game, the game features a zombie which chases you around. Collecting all the '$' on a level will make the stairs appear, and on the third level an '&' which is the big $100 gold coin you came looking for in these zombie infested wherevers. Collecting it wins you the game. Being slow gets you eaten. The game also supports the diagonals, and 5 for wait, and is impossible to crash by falling off the edge of the map.
The code is 948 bytes and written in Java with 2 secondary classes I wrote in about 5 minutes for better input... only one method called g() is used by my code and it essentially replicates getch(). I dont count these in my source size since everyone else seems to be using libraries and stuff for io as well. Here is the code:
The input stuff I wrote which it works with follows:
import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JFrame; import javax.swing.JLabel; public class F{ public static JFrame frame; public static Keyboard vKeyboard; public static int i(){ if(frame == null){ frame = new JFrame(); frame.setSize(305, 50); frame.add(new JLabel("This Window is used for input as long as it has focus")); vKeyboard = new Keyboard(); frame.addKeyListener(vKeyboard); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } int key = -1; while(key == -1){ frame.requestFocus(); try{ Thread.sleep(50); } catch(Exception e){ System.out.println(e); } key = vKeyboard.key; vKeyboard.key = -1; } return key; }
}
class Keyboard implements KeyListener{ public int key; public Keyboard(){} public void keyTyped(KeyEvent e){} public void keyReleased(KeyEvent e){} public void keyPressed(KeyEvent e){ key = e.getKeyChar(); }
> After a lot more work, my <1kb Roguelike has evolved somewhat since I > first posted it, but this is the final version. This challenge was a > lot of fun.
> Now a zombie apocalypse game, the game features a zombie which chases > you around. Collecting all the '$' on a level will make the stairs > appear, and on the third level an '&' which is the big $100 gold coin > you came looking for in these zombie infested wherevers. Collecting it > wins you the game. Being slow gets you eaten. The game also supports > the diagonals, and 5 for wait, and is impossible to crash by falling > off the edge of the map.
> The code is 948 bytes and written in Java with 2 secondary classes I > wrote in about 5 minutes for better input... only one method called > g() is used by my code and it essentially replicates getch(). I dont > count these in my source size since everyone else seems to be using > libraries and stuff for io as well. Here is the code:
Ok here it goes with some small adjustements to use libjcsi, so it is now flickerless and wont need a separate window for input! It runs over 882 bytes now (no IO included, didnt want to mess too much with the original source so it is kept as a separate class as the original. With some adjustments all would fit <1024 bytes)
import net.slashie.libjcsi.jcurses.JCursesConsoleInterface; class F { static JCursesConsoleInterface c = new JCursesConsoleInterface(); static int i(){return c.inkey().code - 69;} static void p(int x, int y, String ch){c.print(x,y,ch,7);} static void p(int x, int y, char ch){p(x,y,ch+"");} static void c(){c.cls();}