1 Reply Latest reply: May 8, 2010 3:17 PM by 843853 RSS

    Java Applet text based game

      Hello im starting to learn java. I know little bit of python, but i know more about c an c++,i wanna start working with java. Im having a problem. When i use the textfield an type straight it doesnt show the next set of text. An i wanna also do is make the text not show all up at once. Mabey like a slow scroll an after the user inputs something it should scroll. I dont know i would like to get the problem im having fixed before i move on to something else. Thanks
      import java.applet.Applet;
      import java.awt.*;
      import java.util.Scanner;
      public class Main extends Applet
           private static final long serialVersionUID = 1L;
           String text;
           Scanner user_in = new Scanner(System.in);
           Label lab1;
              TextField t1;
           public void init()
                 t1 = new TextField(12);
          public void paint(Graphics g)
               super.paintComponents(g);//calls super-class 
              Color black = new Color(0,0,0);//creates color Black 
              Color white = new Color(255,255,255);
              setBackground(black); // Sets the background 
                     g.drawString("Welcome to Immortal Online ",10,50);
                   g.drawString("You see a town ahead."+"\n"+"Type 'Straight' and hit enter to go to town,'right' to go to the field,"+"\n"+" or 'left' to go to the forest.",10,65);
                   text = t1.getText();
                   if (text.equalsIgnoreCase("text"))
                        g.drawString("You are now in town", 10, 85);
                        g.drawString("What do you want to do",10, 95);
      Edited by: Schade419 on May 7, 2010 6:03 PM