Creating a run-time environment for a command-line game

I just started out with Java and decided to create a fun playable command-line game as i presume it to be a good starting point for game-programming in Java. So how can i create a pop-up frame which should behave just like a compiler for the game to run inside ?

Funny you should ask that … because not too long ago today I was taking a peek at some really old code of mine from uni where I did just that - talk about coincidences!!!

Take a look at TextConsole.Java, Command.Java and CmdHandler.java

// Example use of the classes
	static CmdHandler cmdClear = new CmdHandler ( "clear", true ) {

        public void action(Command command, TextConsole console) {
            config.clearPlayers();
            console.writeln ( "players have been cleared");
        }
	    
	};

// ... ...
	static CmdHandler [] menuCmd = {cmdNew, cmdViewPlayers, cmdStart, cmdQuickstart, cmdAddPlayer, cmdHelp, cmdClear};
		
	static CmdHandler [][] menuSet =  {menuCmd};

This made it really really easy for us to add new commands to our game. You will have to excuse some of the poor coding practices exhibited, this was a second year uni project :wink: