Results 1 to 7 of 7
  1. #1
    ChaosProjects is offline NOOBTOCODE
    Join Date
    May 2013
    Location
    Virginia.
    Posts
    10
    Rep Power
    0

    Default need help with space invader game

    Ive been trying to get the window to pop up just the black canvas but iget this error



    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    Game cannot be resolved to a type
    JFrame cannot be resolved to a type
    Jframe cannot be resolved to a type
    JPanel cannot be resolved to a type
    JPanel cannot be resolved to a type
    Dimension cannot be resolved to a type
    The method setBounds(int, int, int, int) is undefined for the type game
    Cannot use this in a static context
    The method setIgnoreRepaint(boolean) is undefined for the type game
    The method createBufferStrategy(int) is undefined for the type game
    strategy cannot be resolved
    The method getBufferStrategy() is undefined for the type game
    gameRunning cannot be resolved
    lastLoopTime cannot be resolved
    lastLoopTime cannot be resolved
    Graphics2D cannot be resolved to a type
    Graphics2D cannot be resolved to a type
    strategy cannot be resolved
    Color cannot be resolved
    strategy cannot be resolved

    at game.game.main(game.java:10)

  2. #2
    monkeyjr97 is offline Senior Member
    Join Date
    Nov 2012
    Posts
    258
    Rep Power
    2

    Default Re: need help with space invader game

    post the code that goes with this error? otherwise how can we point you in the right direction.

    Sounds like you havent imported or specified that you want a new JFrame / JPanel

    The method setIgnoreRepaint(boolean) is undefined for the type game
    The method createBufferStrategy(int) is undefined for the type game

    These look like you havent defined any methods for your Game Objects, have you copied somebodies code by any chance? you maybe missing files if you have.

    But please post your code so we can see what is going on :D

  3. #3
    ChaosProjects is offline NOOBTOCODE
    Join Date
    May 2013
    Location
    Virginia.
    Posts
    10
    Rep Power
    0

    Default Re: need help with space invader game

    ok one second

  4. #4
    ChaosProjects is offline NOOBTOCODE
    Join Date
    May 2013
    Location
    Virginia.
    Posts
    10
    Rep Power
    0

    Default Re: need help with space invader game

    /**
    * @param args
    */
    public static void main(String argv[]) {
    // TODO Auto-generated method stub
    new Game();
    // create a frame to contain our game
    JFrame container = new Jframe("Space Invaders 101");

    //get hold the content of the frame and set up the
    // resolution of the game
    JPanel panel = (JPanel) container.getContentPane();
    panel.setPreferredSize(new Dimension(800,600));
    panel.setLayout(null);

    // setup our canvas size and put it into the content of the frame
    setBounds(0,0,800,600);
    panel.add(this);
    // Tell AWT not to bother repainting our canvas since we're
    // going to do that our self in accelerated mode
    setIgnoreRepaint(true);

    // finally make the window visible
    container.pack();
    container.setResizable(false);
    container.setVisible(true);
    //create the buffering strategy which will allow AWT
    //to manage our accelerated graphics
    createBufferStrategy(2);
    strategy = getBufferStrategy();

    while (gameRunning) {
    //work out how long its been since the last update, this
    //will be used to calculate how far the entites should
    //move this loop
    long delta = System.currentTimeMillis() - lastLoopTime;
    lastLoopTime = System.currentTimeMillis();

    // Get hold of a graphics content for the accerlerated
    // surface and blank it out
    Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
    g.setColor(Color.black);
    g.fillRect(0,0,800,600);

    // finally, we've completed drawing so clear up the graphics
    // and flip the buffer over
    g.disopse();
    strategy.show();

    // finally pause for a bit. Note: this should run us at about
    // 100 fps but on windows this might vary each loop due to
    // a bad implementation of timer
    try { Thread.sleep(10); } catch (Exception e) {}
    }

  5. #5
    ChaosProjects is offline NOOBTOCODE
    Join Date
    May 2013
    Location
    Virginia.
    Posts
    10
    Rep Power
    0

    Default Re: need help with space invader game

    And yes I was following a tutorial online. i dont think hes writing in Eclipse like i am.

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: need help with space invader game

    What has which IDE you use got to do with anything?

  7. #7
    ChaosProjects is offline NOOBTOCODE
    Join Date
    May 2013
    Location
    Virginia.
    Posts
    10
    Rep Power
    0

    Default Re: need help with space invader game

    Ive been told some ease the use of javascript, explain errors, and show examples of which options you have with certain commands as in (System.currentTimeMillis)
    lastLoopTime. This is also my first day using Javascript. what IDE do you use? Could you also name some for me?

Similar Threads

  1. Replies: 1
    Last Post: 11-09-2012, 09:07 PM
  2. Space Warrior - Multiplayer Space Shooter
    By stes in forum Reviews / Advertising
    Replies: 2
    Last Post: 01-11-2012, 08:19 AM
  3. Replies: 0
    Last Post: 11-04-2011, 01:36 PM
  4. Problem with Space Invaders Game
    By andyman99008 in forum New To Java
    Replies: 8
    Last Post: 12-19-2010, 09:20 PM
  5. Replies: 0
    Last Post: 07-05-2009, 12:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •