How about Console Quake style

sorry for my english, I’m french

well, I’m not new to program games in Java but now I want to furnish more features for my games. The problem is that I want to realize a console as same as quake to modify values of the game.

I try to do it with MS DOS console and X Term console, it runs, i do a bufferedReader, I read it with readLine and I cut it with StringTokenizer, it’s simple

now the problem is, i have a JFrame in fullscreen mode and a implementation of a KeyListener
I want to pressed a command( a string if you want) and draw it in the same time with paint method of my JFrame component
ex:
g.drawString(inputString, 50, 50);

and a problem is also to draw it on the JFrame even if the command line is not finished !

please help me I’m very lost !!!
thx a lot ! :-*

Hi

Well try something like this…


public class YourFrame implements KeyListener{
    private static final int CONSOLEKEY = KeyEvent.VK_MINUS;

    private boolean isConsoleActive = true;
    private String consoleCommand = "";
  ....

    public void keyPressed(KeyEvent e) {
    }

    public void keyReleased(KeyEvent e) {
         if (isConsoleActive){
              if (e.getKeyCode() == KeyEvent.VK_ENTER){
                   excecuteConsolecommand(consoleCommand);
                   isConsoleActive = false;
              }else{
                  consoleCommand =+ e.getKeyChar();
              }
         }else if (e.getKeyCode()  == CONSOLEKEY){
             isConsoleActive = true;
         }
    }

    public void paint(Graphics g){
          drawFrame(g);
           if (isConsoleActive){
               drawConsoleOverframe(g);
                g.drawString(consoleCommand, x, y);
           }
    }

   private void excecuteConsolecommand(String command){
       //Do your thing here
   }
}


hi Backmask,
the last night, I have thought about the same system of you and you. You confirm that I’m on a good way ;D
thanks a lot