NOTHING IS WORKING!

4 replies [Last post]
Offline
Joined: 01/31/2014

 I was starting a project, and I had 2 classes: game and ball. I tryed to put in the code exactly for game, but it threw up some errors about the getKey() method. Then, it gives me an arguments error when I try to add a ball. Also, Itonly made a enviromnt once, then i had to redo the class. Ihave been raging all day,, so please help fast!

 YOLOOOOOOOOOOOOOOOOO!

Offline
Joined: 11/23/2013
 Hi, please paste your code

 Hi, please paste your code so that I can take a look at it.

 

getKey() : did you type in the imports in the beginning of the file?

 

what errors are you getting exacly ??

 

 

 

Offline
Joined: 01/31/2014
 I am importing, and I put in

 I am importing, and I put in exactly the code in the third lesson and the terminal window opens and I get this:

 

java.lang.IllegalStateException: Provider may only be changed before input is created!

at com.jme.input.MouseInput.setProvider(MouseInput.java:107)

at env3d.Env.<init>(Env.java:151)

at env3d.Env.<init>(Env.java:137)

at Game.play(Game.java:13)

 

 YOLOOOOOOOOOOOOOOOOO!

Offline
Joined: 11/23/2013
Try this...

 Hello, I thnk it's a problem with the mouse or keyboard input.

 

Replace your game class with this:

 

 

import org.lwjgl.input.Mouse; 

public class Game

    public Game()

    { 

    }

 

    public void play()

    {

        

        // A variable to determine if the game is finished

        boolean finished = false;         

        // Create the env object so that we can manipulate

        // the 3D environment.

        Env env = new Env(); 

        ///////////////////////////////////

        ////////////////////////////////

        env.setMouseGrab(false);

        env.setDefaultControl(false);

        ////////////////////////////////

        ///////////////////////////////////

        // Create a ball object     

        Ball b = new Ball(5, 1, 5);     

        // Add the object to the environment     

        env.addObject(b);   

     

        while (!finished)

        {

            // Gather the user input

            int key = env.getKey();

     

            // Terminate program when user press escape

            if (key == 1) {

                finished = true;

            }

            // Move the ball     

            b.move();             

            // Update the environment

            env.advanceOneFrame();

        }         

     

        // Exit the program cleanly

        env.exit();

    }

 

notice the 2 lines added near the beginning.

 

Create a new Game by right clicking your game class then "new game" and right click on the game1 and click the void play().

 

If it works, try replacing the env.setMouseGrab(false) to env.setMouseGrab(true) and try the same same with the setDefaultControl()  (this one allows WSAD for movement)  to see what happens.

 

Play around with the code to see if taking some stuff out makes it work since I assume the lessons 1 and 2 worked ?

 

try to remove this part for example: 

 

int key = env.getKey();

if(key==1) {

   finished = true;

}

 

 

 

 you can disable any line of code by putting // in front of it instead of deleting but i'm sure you know that...

 

 

If all of the above does not work, uninstal everything and start fresh making sure you have the new version of env3d that can be found here: 

 

http://sourceforge.net/projects/env3d/files/env3d_template.zip/download

 

and also check your java version to make sure you have the latest 1.7 build. Maybe unistall java and reinstall from oracle.

 

http://www.oracle.com/technetwork/java/javase/downloads/1880261

 

And if after that it still does not work, give me info on what kind of computer you have including 32 or 64 bit, xp/vista/7/8 and graphics card

 

Hope this helps cheers !

 

 

 

 

 

 

 

Offline
Joined: 11/23/2013
forgot the import : )

sorry, I forgot to add this at the beginning of the code:

 

 

  import env3d.Env;