Programming my first simple java game

I want to program a Java Applet called: a knight's tour.
The game goes as follows:
When you start the applet a chessboard will be shown.
When you click on a compartment the knight will appear. Then you've got to click on the next compartment. The applet has to check if this is a "knight move" and if the square has'nt been visited yet.
You win when you have visited all the compartiments.
Can anywone help me? The chessboard isn't a problem. But for example, when you click on a point, how can I ask the color of that specific location?
Thanks for the reaction.

I very much agree with yawmark. I'm also not really sure how far you want to take this in terms of being an actual chess game, since - to my mind at least - your post is not too clear. Since you mentioned that you did not really understand Java very well, I again 2nd what yawmark said. Still, since you were considerate and frank, I had a few minutes and so coded up what I meant in my prior post. As I said, I'm sure there are better approaches, but since I'm not really sure where you're headed with this, I thought I'd post the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class ChessGame  extends JFrame {
  private boolean isRed;
  private JLabel  jl;
  public ChessGame() {
    super( "ChessGame" );
    Container c = this.getContentPane();
    JPanel jp = new JPanel();
    jp.setLayout( new GridLayout( 8, 8, 0, 0 ) );
    for ( int idx = 1; idx < 65; idx++ ) {
      jp.add( buildJButton() );
      if ( idx % 8 == 0 ) isRed = !isRed;
    c.add( jp );
    jl = new JLabel( "click on a square" );
    c.add( jl, BorderLayout.SOUTH );
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setBounds( 100, 100, 500, 500 );
    setVisible( true );
  public JButton buildJButton() {
    final JButton jb = new JButton( "" );
    jb.setBorderPainted( false );
    if ( isRed ) jb.setBackground( Color.red );
    else         jb.setBackground( Color.black );
    isRed = !isRed;
    jb.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent ae ) {
        if ( ( ""+jb.getBackground() ).startsWith( "java.awt.Color[r=0" ) )
          jl.setText( "black" );
        else
          jl.setText( "red" );
    return( jb );
  public static void main( String[] argv ) {
    new ChessGame();
}HTH

Similar Messages

  • How to make "Levels" in simple java game

    I just wanted to know if anybody knew how to make "Levels" in a java game. In my case, it is to change two polygons that are used in the background. I think you have to use an array of some kind, but i dont really know.
    Here is my source, the polygons are by the massive ///////// areas.
    I cut out the majority of the program, because it was too long.
    public class collision extends Applet implements MouseListener,MouseMotionListener
        private  Image rickImage,mazeImage;
       Image Buffer;
       Graphics gBuffer;
       int x, y;
       int[] LeftWallX = {0,204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,0};
       int[] LeftWallY = {500,499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1};
       //int[] PlayAreaX = {204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
      // int[] PlayAreaY = {499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       int[] RightWallX = {500,500,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
       int[] RightWallY = {500,0,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       boolean mouseInside, collide;
       boolean rolled = false;
       boolean msg = true;
       int sX=204,sY=490,sW=12,sH=9;
       //Declare the rectangles
       Rectangle  movingRect,finshBloc,startBloc,oopsBloc;
       //Declare the polygons
       Polygon leftWall,playerArea,rightWall;
            ///Initiate
            public void init()
                 rickImage = getImage(getDocumentBase(), "rick.jpg");
                 mazeImage = getImage(getDocumentBase(), "maze1.jpg");
                 collide=false;
                 Buffer=createImage(getSize().width,getSize().height);
                 gBuffer=Buffer.getGraphics();
                 rightWall=new Polygon(RightWallX,RightWallY,18);
                 playerArea= new Polygon(PlayAreaX,PlayAreaY,31);
                 leftWall= new Polygon(LeftWallX,LeftWallY,17);
            public void paint(Graphics g)
                 drawStuff();
                 g.drawImage (Buffer,0,0, this);
    */

    I'm not exactly sure in your case what you are trying to accomplish. If all you want to do is make new polygons for your levels then you will simply need a Vector of type level (or polygon). Store multiple levels/polygons in that vector. This can be done many ways, probably the most efficient way would be to create a class Level of sorts and create each level object from there. This way you have all your levels stored into that vector.
    I have made programs where the levels/mazes are randomly generated based on certain parameters (this way you would not need to define any specific level). This can be done inside the Level class and added to the vector so that when a level is randomly generated there are literally infinite possibilities. I would suggest posting all your code or at least a breakdown UML diagram of what is going on in your entire program.

  • Simple java game

    I'm trying to create a simple game where you specify where you would like to start in a 2d array, then use directional buttons to move the character around. However, rather than store the value of 's', it stores it's value in the character set.. here is my code:
    import java.util.*;
    public class Map1
         static Scanner console = new Scanner(System.in);
         public static void main(String[] args)
              char character;
              char[][]map = new char[10][10];
              char x, y;
              int printing;
              boolean end = false;
              System.out.println("Indicate where you would like your ship to start by entering a value"
                             + "\nbetween 0 and 9 for x, followed by a value for y");
                             x = console.next().charAt(0);
                             y = console.next().charAt(0);
              System.out.println("The value you entered for x is: " + x);
              System.out.println("The value you entered for y is: " + y);
              map[x][y] = 's';
              System.out.println(map[x][y]);
              System.out.println("Ok, now your directional keys are:"
                             + "\nA moves you to the left, W moves you up,"
                             + "\nD moves you to the right, and S moves you down"
                             + "\nTo end the game and view your map, press x.");
              System.out.println("So now, choose your direction!");
              character = console.next().charAt(0);
              do
                   switch(character)
                        case 'a':
                        case 'A':
                             map[x--][y] = 's';
                             break;
                        case 'w':
                        case 'W':
                             map[x][y--] = 's';
                             break;
                        case 's':
                        case 'S':
                             map[x++][y] = 's';
                             break;
                        case 'd':
                        case 'D':
                             map[x][y++] = 's';
                             break;
                        case 'x':
                        case 'X':
                             end = true;
                             System.out.println("Thank you for playing, here is your map.");
                             for (printing = 0; printing < map.length; printing++)
                                  System.out.println(map[x][y]);
                             break;
                        default:
                             System.out.println("The value you entered is invalid. Please try again.");
              while (!end);
    }

    To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the tags it generates.
    Declare x and y as int instead of char and use nextInt () instead of next.charAt (0) to read the values inputted. Fragments:        //char x, y;
            int x, y;
            x = console.nextInt ();//.charAt (0);
            y = console.nextInt ();//.charAt (0);That's not all that's wrong, you also need to read the input for directional movement inside rather than before the loop, but try to fix that yourself.
    db

  • Help Making a SIMPLE JAVA GAME *TINY GLITCH*

    got a tinnnny glitch and ive tried everything to get it to work, but so far no luck.
    Heres what my program does:
    1. Aliens spawn at top left (top 4 rows) and move to the right and dissapear (DONE)
    2. Shooting rectangle at bottom middle (moves left and right) and shoots bullets (DONE)
    3. When bullets make contact with alien the alien dissapears (DONE)
    4. When you shoot 20 bullets game over (DONE)
    5. When all the aliens fly by the screen game over (DONE)
    GLITCH
    1. When an alien is killed any bullet that goes over the exact same spot of collision the bullet dissapears! +so does an alien going over same collision spot
    MISSING
    1. Score, every alien kill + 10 CANNOT get a working score funtion to +10 fo every alien successfully hit :(
    My SRC jus copy and paste and compile, any help appreciated
    http://www.geocities.com/porche_masi/Assignment3.txt
    //ignore spelling mistakes in comments and outputs lol
    ive spent way to many hours over these 2 stupid problems, hope new eyes can spot the problem

    I'm not going to look at your code, but it sounds like when you're killing things you're not removing them from your future calculations. So if an alien is killed, it should either be removed from the list of aliens, or a "dead" flag should be set on it which causes it to be ignored in future calculations.
    edit I did look at your code actually, and that is a really, really bad use of multithreading. You shouldn't just create a new thread every time a bullet is fired. You should maintain a list of bullets, have the main thread drive the UI, and have a secondary thread to update the game logic (recalculate collisions, etc).
    Edited by: endasil on Nov 21, 2007 3:16 PM

  • Problem while executing simple java program

    Hi
    while trying to execute a simple java program,i am getting the following exception...
    please help me in this
    java program :import java.util.*;
    import java.util.logging.*;
    public class Jump implements Runnable{
        Hashtable activeQueues = new Hashtable();
        String dbURL, dbuser, dbpasswd, loggerDir;   
        int idleSleep;
        static Logger logger = Logger.getAnonymousLogger();      
        Thread myThread = null;
        JumpQueueManager manager = null;
        private final static String VERSION = "2.92";
          public Jump(String jdbcURL, String user, String pwd, int idleSleep, String logDir) {
            dbURL = jdbcURL;
            dbuser = user;
            dbpasswd = pwd;
            this.idleSleep = idleSleep;
            manager = new JumpQueueManager(dbURL, dbuser, dbpasswd);
            loggerDir = logDir;
            //preparing logger
            prepareLogger();
          private void prepareLogger(){      
            Handler hndl = new pl.com.sony.utils.SimpleLoggerHandler();
            try{
                String logFilePattern = loggerDir + java.io.File.separator + "jumplog%g.log";
                Handler filehndl = new java.util.logging.FileHandler(logFilePattern, JumpConstants.MAX_LOG_SIZE, JumpConstants.MAX_LOG_FILE_NUM);
                filehndl.setEncoding("UTF-8");
                filehndl.setLevel(Level.INFO);
                logger.addHandler(filehndl);
            catch(Exception e){
            logger.setLevel(Level.ALL);
            logger.setUseParentHandlers(false);
            logger.addHandler(hndl);
            logger.setLevel(Level.FINE);
            logger.info("LOGGING FACILITY IS READY !");
          private void processTask(QueueTask task){
            JumpProcessor proc = JumpProcessorGenerator.getProcessor(task);       
            if(proc==null){
                logger.severe("Unknown task type: " + task.getType());           
                return;
            proc.setJumpThread(myThread);
            proc.setLogger(logger);       
            proc.setJumpRef(this);
            task.setProcStart(new java.util.Date());
            setExecution(task, true);       
            new Thread(proc).start();       
         private void processQueue(){       
            //Endles loop for processing tasks from queue       
            QueueTask task = null;
            while(true){
                    try{
                        //null argument means: take first free, no matters which queue
                        do{
                            task = manager.getTask(activeQueues);
                            if(task!=null)
                                processTask(task);               
                        while(task!=null);
                    catch(Exception e){
                        logger.severe(e.getMessage());
                logger.fine("-------->Sleeping for " + idleSleep + " minutes...hzzzzzz (Active queues:"+ activeQueues.size()+")");
                try{
                    if(!myThread.interrupted())
                        myThread.sleep(60*1000*idleSleep);
                catch(InterruptedException e){
                    logger.fine("-------->Wakeing up !!!");
            }//while       
        public void setMyThread(Thread t){
            myThread = t;
        /** This method is only used to start Jump as a separate thread this is
         *usefull to allow jump to access its own thread to sleep wait and synchronize
         *If you just start ProcessQueue from main method it is not possible to
         *use methods like Thread.sleep becouse object is not owner of current thread.
        public void run() {
            processQueue();
        /** This is just another facade to hide database access from another classes*/
        public void updateOraTaskStatus(QueueTask task, boolean success){
            try{         
                manager.updateOraTaskStatus(task, success);
            catch(Exception e){
                logger.severe("Cannot update status of task table for task:" + task.getID() +  "\nReason: " + e.getMessage());       
        /** This is facade to JumpQueueManager method with same name to hide
         *existance of database and SQLExceptions from processor classes
         *Processor class calls this method to execute stored proc and it doesn't
         *take care about any SQL related issues including exceptions
        public void executeStoredProc(String proc) throws Exception{
            try{
                manager.executeStoredProc(proc);
            catch(Exception e){
                //logger.severe("Cannot execute stored procedure:"+ proc + "\nReason: " + e.getMessage());       
                throw e;
         *This method is only to hide QueueManager object from access from JumpProcessors
         *It handles exceptions and datbase connecting/disconnecting and is called from
         *JumpProceesor thread.
        public  void updateTaskStatus(int taskID, int status){       
            try{
                manager.updateTaskStatus(taskID, status);
            catch(Exception e){
                logger.severe("Cannot update status of task: " + taskID + " to " + status + "\nReason: " + e.getMessage());
        public java.sql.Connection getDBConnection(){
            try{
                return manager.getNewConnection();
            catch(Exception e){
                logger.severe("Cannot acquire new database connection: " + e.getMessage());
                return null;
        protected synchronized void setExecution(QueueTask task, boolean active){
            if(active){
                activeQueues.put(new Integer(task.getQueueNum()), JumpConstants.TH_STAT_BUSY);
            else{
                activeQueues.remove(new Integer(task.getQueueNum()));
        public static void main(String[] args){
                 try{
             System.out.println("The length-->"+args.length);
            System.out.println("It's " + new java.util.Date() + " now, have a good time.");
            if(args.length<5){
                System.out.println("More parameters needed:");
                System.out.println("1 - JDBC strign, 2 - DB User, 3 - DB Password, 4 - sleeping time (minutes), 5 - log file dir");
                return;
            Jump jump = new Jump(args[0], args[1], args[2], Integer.parseInt(args[3]), args[4]);
            Thread t1= new Thread(jump);
            jump.setMyThread(t1);      
            t1.start();}
                 catch(Exception e){
                      e.printStackTrace();
    } The exception i am getting is
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe
    Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
    JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820] Please help me.....
    Thanks in advance.....sathya

    I am not willing to wade through the code, but this portion makes me conjecture your using an Oracle connect string instead of a class name.
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe

  • Help with a simple Java program

    I'm making a sort of very simple quiz program with Java. I've got everything working on the input/output side of things, and I'm looking to just fancy everything up a little bit. This program is extremely simple, and is just being run through the Windows command prompt. I was wondering how exactly to go about making it to where the quiz taker was forced to hit the enter key after answering the question and getting feedback. Right now, once the question is answered the next question is immediately asked, and it looks kind of tacky. Thanks in advance for your help.

    Hmm.. thats not quite what I was looking for, I don't think. Here's an example of my program.
    class P1 {
    public static void main(String args[]) {
    boolean Correct;
    char Selection;
    int number;
    Correct = false;
    System.out.println("Welcome to Trivia!\n");
    System.out.println("Who was the first UF to win the Heisman Trophy?\n");
    System.out.print("A) Danny Wuerffel\nB) Steve Spurrier\nC) Emmit Smith\n");
    Selection = UserInput.readChar();
    if(Selection == 'B' | Selection == 'b')
    Correct = true;
    if(Correct == true)
    System.out.println("\nYou have entered the correct response.");
    else
    System.out.println("\nYou missed it, better luck next time.");
    System.out.println("(\nHit enter for the next question...");
    System.in.readLine();
    Correct = false;
    System.out.println("\nWhat year did UF win the NCAA Football National Championship?\n");
    number = UserInput.readInt();
    if(number == 1996)
    Correct = true;
    if(Correct == true)
    System.out.println("\nYou have entered the correct response.");
    else
    System.out.println("\nYou missed it, better luck next time.");
    Correct = false;
    System.out.println("\nWho is the President of the University of Florida?\n");
    System.out.println("A) Bernie Machen\nB) John Lombardi\nC) Stephen C. O'Connell\n");
    Selection = UserInput.readChar();
    if(Selection == 'A' | Selection == 'a')
    Correct = true;
    if(Correct == true)
    System.out.println("\nYou have entered the correct response.");
    else
    System.out.println("\nYou missed it, better luck next time.");
    }

  • Simple card game with concurrent programming

    Hi, I need help to program this problem in JAVA using concurrent programming, because I don�t understand how it can be solved.
    Four card players are sitting in a table game. Each player has initially three cards � an ace, a king and a queen. The most valuable card is the ace and the less valuable is the queen. One move corresponds to the following interaction: each player puts a card in the table. The player who puts the most valuable card wins that move. A move can be gain by several players (if for example several players throw the ace). The game control is distributed, that is, each player is always trying to play but he only can play once in each move. After three moves, when the players have no more cards, the system indicates the punctuation of each player and the game ends.
    Thanks in advance.

    It would be easier without concurrency. Do you have to use threads? Anyway I have just posted a piece of code that coordinates processes. Each player would be one process (thread) so you start 4 of them. You then have to figure out how too keep track of the score.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=350773&tstart=0&trange=15

  • A simple Java program to be compiled with ojc and executed with java.exe

    Hi ,
    This thread is relevant to Oracle Java Compiler (file ojc) and jave.exe file.
    I have written a simple java program which consists of two simple simple classes and using the JDev's 10.1.3.2 ojc and java files , i'm trying to execute it after the successful compilation....
    The problem is that trying to run it... the error :
    Exception in thread "main" java.lang.NoClassDefFoundError: EmployeeTest
    appears.
    How can i solve this problem...????
    The program is as follows:
    import java.util.*;
    import corejava.*;
    public class EmployeeTest
    {  public static void main(String[] args)
       {  Employee[] staff = new Employee[3];
          staff[0] = new Employee("Harry Hacker", 35000,
             new Day(1989,10,1));
          staff[1] = new Employee("Carl Cracker", 75000,
             new Day(1987,12,15));
          staff[2] = new Employee("Tony Tester", 38000,
             new Day(1990,3,15));
          int i;
          for (i = 0; i < 3; i++) staff.raiseSalary(5);
    for (i = 0; i < 3; i++) staff[i].print();
    class Employee
    {  public Employee(String n, double s, Day d)
    {  name = n;
    salary = s;
    hireDay = d;
    public void print()
    {  System.out.println(name + "...." + salary + "...."
    + hireYear());
    public void raiseSalary(double byPercent)
    {  salary *= 1 + byPercent / 100;
    public int hireYear()
    {  return hireDay.getYear();
    private String name;
    private double salary;
    private Day hireDay;
    For compilation... i use :
    D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdev\bin\ojc -classpath D:\E-Book\Java\Sun_Java_Book_I\Corejava EmployeeTest.java
    For execution , i issue the command:
    D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
    NOTE:I tried to use the jdk of Oracle database v.2 but the error :
    Unable to initialize JVM appeared....
    Thanks , a lot
    Simon

    Hi,
    Thanks god....
    I found a solution without using Jdev.....
    C:\oracle_files\Java\Examples>SET CLASSPATH=.;D:\E-Book\Java\Sun_Java_Book_I\Corejava
    C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\javac EmployeeTest.java
    C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
    What does Ant has to do with this?Sorry, under the Ant tree a classpath label is found....I'm very new to Java and JDev...
    You need to include the jar file that has the Day method in it inside project properties->libraries.I have not .jar file.. just some .java files under the corejava directory.... By the way , I have inserted the corejava directory to the project pressing the button Add Jar/Directory.... , but the problem insists..
    Thanks , a lot
    Simon

  • Simple java pathfinder game

    Hi
    Is any1 willing to make me a simple java pathfinder game in return for some money? details will be given on request...

    Sod off and do your own homework.

  • Java game AI

    Hi there, I am currently creating a battleship game which allows you to play against a computer or a human or run the game as a spectator watching the computer battle its own AI. I am having trouble finding an efficient way to program the AI when I hit a ship on the opponents map.
    Current logic: I hit an enemy ship and add all the possible directions into a queue and resolve them in order, up down left right. If there is an 'o' (miss) or 'x' (hit), currently in one of the suggested directions, it will be removed (since it has already been searched) and move on to the next coordinate.
    Problem: The AI is extensive in it's checking. It finds a long ship, 10 char long, and checkes all around the the ship making sure nothing else is there. Although this method is very accurate, it takes too many turns to verify that it has found the whole ship, therefore losing almost all the time.
    Any ideas?
    -Thanks in advance
    EDIT: Sample from AI vs AI.
    x = hit
    o = miss
    Computer2's Map
    0123456789
    0 .......xxo
    1 .ooo..o.o.
    2 ....o.....
    3 ..........
    4 .....ooooo
    5 ...ooooxxo
    6 .ooxxxxxo.
    7 .oooooooo.
    8 .......o..
    9 .o........
    Edited by: Krytical on Jul 15, 2009 2:55 PM

    I think you are not putting enough into it.
    AI is hard, no matter how simple the game may seem. I have written about 16 games (I might have missed one or two in a hasty count) and worked on a couple open source game projects. Of those 16, 2 of them include an option to play against the computer, i.e. they have a good enough AI. The rest are all strictly multiplayer or single player with no opponents (simulations). Of those two, both are also and where first multiplayer games. That is because until I can play a game enough to fully understand it strategically (even though I wrote it), it is impossible to write a working AI.
    So here is my advice, play a few dozen games against other players, the more different people you play against the better. Jot down your strategies in every situation, and ask you opponent if they would be kind enough to do likewise (it helps to tell them it is for writing an AI, otherwise they think you are just trying to learn their secrets for the next time you play). Then try out some of the strategies you get from others and see if you understand it, when it is best to use that strategy, and how well it works.
    At this point, you should try to code several of those strategies and see how well the computer does with it. Then code a way for the computer to weigh the possible effectives of the different strategies and randomly choose between them based on the weighted scale. As in, if start A is 5 times more likely to succeed than strat B in situation X then the computer should have 5 times more likelihood of choosing strat A over strat B for situation X.
    As a starting point, here is my strat for battleship in a way that should help with how to code it. I always look at which direction has the longest distance to where I have previously fired. But I also limit it to 4 spaces as that is the length of the longest ship (plus the one hit). So if I choose say F6 (isn't it letters across the top?) and get a hit, then I look around F6. Looking down I have already gotten a miss on F9 leaving 2 blank spaces. Looking left I have recorded a miss on A6, leaving 4 spaces that way. Looking up I have a miss on F5, so there is definately not one that way and this makes it less likely the boat runs north and south (up and down). To the right the nearest shot was a hit on a boat I already sunk but it is 7 spaces away, so I exceed the limit and reduce it to 4 spaces. So what do we have, 2 spaces down, no spaces up and 4 spaces to both the left and the right. At this point I am just going to randomly choose to go left or right and keep going that way until I get a miss or my opponent announces I sunk a ship, if a miss with no sinking I go the other way until said declaration. Should I get a miss on both sides without an additional hit then I will re-evaluate and since the only way left to go in that case would be down, that is how I would go. If I got a hit going either way but missed on both sides then I know I have two ships and I simply put the new hit on the back burner until I have sunk the first.
    Now this should all be relatively easy to code and should make the AI much more formidable. But there is actually far more I do when playing that game. For example, if the 5 length ship has already been sunk and the longest left is 4 length, then I only go 3 blank spaces each way in weighing my options. Similarly if the 2 length ship and both 3 length ships are sunk then I first check to ensure there is a total of at least 4 spaces along either axes (there must be on at least one of them). This will be a little more coding work, but will make the computer AI even more robust and formidable.
    If I was playing against your AI I would always place my ships from left to right, because I know the AI is then always going to waste at least 2 shots whenever it gets a hit. In AI the more unpredictable the AI is the better, this is why it is important to keep things random, and give the computer as many strategy choices as possible to weigh and then semi-randomly choose from.
    Also, this is the wrong place on these forums for this question, there is actually a java games section here, I think it is under other. Also there is actually a fairly active java game forum, but I don't recall the url for it atm. You will have far better chances of getting a response in one of those more appropriate places.
    JSG

  • JAVA Game DEV

    Does anyone know of a site which will walk a total newbie through making a very simple game in Java. It doesn't matter how crappy the game is, just something to get the newbie started.
    The website is for me :)
    Thanks,
    Christopher Gillis

    I recomend books like "Black Art of Java Game Programming". Although it is old. It is still very relevant.
    The sites that I learnt from are:
    http://www.gamejug.org/tutorials/
    http://www.electricfunstuff.com/jgdc/tutorials/jgdc_tutorials.htm
    http://blazinggames.com/books/jgd/ch01/page02.html
    They are good sites for amatures.
    I also found insparation and some code at:
    http://www.javaonthebrain.com
    Hope that helps!!

  • Making some basic Java games

    Can anyone help on how to make some basic java games for my website if you could that would be helpful
    thanks,
    Louie

    Well, first of all you program the Framework, add Graphics / sounds / Data , then you put it in your HP - There you are!

  • Develop AI for a bot in first-person shooting game

    Hi, i'm working on a web-based first-person shooting game incorporating VRML and java. As for the AI part of the bot, somebody suggested me using JESS(Java Expert System Shell). I've looked through some tutorial about the API and usage of the software, but that's of little help when it comes to building a complex program contolling the AI of the bot. How do i start? any good reference or sample available on the net? thx for your help!

    Do you mean artificial behaviour (i.e. having the bad guys act like bad guys), rather than actual artificial intelligence?
    There's at least one good article on Artificial Behaviour on Gamasutra.com - it discusses the AI in Thief and Half-Life:
    http://www.gamasutra.com/gdc2003/features/20030307/leonard_01.htm
    (You will need to make a free account with Gamasutra to view this).
    In particular, it covers some pseudocode for the basics of the artificial behaviour.
    I hope this is of some use to you, it's at least interesting to read.

  • Problem compiling a simple java file

    Hi,
    When I try to compile the following simple java file
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HowdyServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    out.println("<html>");
    out.println("<body>");
    out.println("<center><h1>Hi</h1></center>");
    out.println("</body>");
    out.println("</html>");
    at the command prompt as follows
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac -classpath
    "C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip" *.java
    Or
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac *.java
    Or
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac HowdyServlet.java
    I get the following errors and I cannot compile this java file -
    HowdyServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    HowdyServlet.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    HowdyServlet.java:5: cannot find symbol
    symbol: class HttpServlet
    public class HowdyServlet extends HttpServlet {
    ^
    HowdyServlet.java:6: cannot find symbol
    symbol : class HttpServletRequest
    location: class HowdyServlet
    public void doGet(HttpServletRequest request,
    ^
    HowdyServlet.java:7: cannot find symbol
    symbol : class HttpServletResponse
    location: class HowdyServlet
    HttpServletResponse response)
    ^
    HowdyServlet.java:8: cannot find symbol
    symbol : class ServletException
    location: class HowdyServlet
    throws IOException, ServletException {
    ^
    6 errors
    I have installed the latest JEE 5 SDK on Win XP Home. I have the following variable set as follows,
    CLASSPATH = .;C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
    PATH = C:\Sun\AppServer\jdk\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem;C:\Sun\AppServer\lib\ant\bin
    ANT_HOME = C:\Sun\AppServer\lib\ant
    I have spent hours scratching my head but don?t have a clue. I was wondering if you have any idea as why I might be getting these errors.
    Thank you for your time.
    Green

    Hello, did you read the answers?
    You have to put j2ee.jar or servlet-api.jar in your classpath. Those JAR files are included in the Java EE package somewhere. Remove the QTJava.zip junk from the classpath.
    If you don't know what the classpath is and how to set it, read this:
    Setting the class path
    How Classes are Found
    And I'll repeat what the others say: if you are very new to Java, then Java EE will probably be way over your head. First learn the language and the standard API. If you understand that well, start with Java EE. Or do you already know what servlets are, and that you need a servlet container to run them, and how to deploy them etc.?

  • How to update the file in simple java archive file on Netweaver2004s

    We have a J2EE application containing few properties file packed inside a java archive. These properties are Configuration properties which we are required to change few times after deployment.We are using SAP Visual Administrator to deploy\undeploy our application.We found out that Visual Administrator dose not support update of files packed in a simple Java Archive in Single File Update Option. It only allows updates of EJB Modules archive.
    Please let us know if there is any other way we can update a file inside a simple java archive.

    Well, Thanks for the help but,. i didn't understand
    try not opening the file every time. As I only know that I need to open a file if i would like to update the records..
    The update is not happening :
    Firstly it shows like this (new.txt):
    STOPSecondly it must show like this (new.txt) BUT NOT HAPPENING AS I EXPECTED:
    STOPSTOPBut it's not hapenning

Maybe you are looking for