help!, problem with exception

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

help!, problem with exception

Postby ovostick » Tue Sep 20, 2011 9:41 am

hello, i'm new to lejos and the lejos forum, so sorry if this is a stupid question.
i have a small game i made, and it runs fine. but after maybe 2 minutes of playing it gives me this:
java Exception:
Classes: 5
Methods: 0

On the NXT'S LCD display. im really confused and any help would be greatly appreciated.
the code is:
Code: Select all
import lejos.nxt.*;
import java.util.*;
class funcs {
    public void addenimie (int n,int b) {
        LCD.drawString("||",n,b);
    }
}
public class moveygame {

   /**
    * @param args
    */
   public static void main(String[] args) {
      LCD.clear();
      funcs funcs = new funcs();
      funcs.addenimie(5, 3);
      //_posx = the virtical position
      //_posy = the horizontal position
      //x = 15 y = 7
      //(x,y);
      
      
      //SET UP VARS FOR GAME
      int player_posx = 6;
      int end = 0;
      int player_posy = 4;
      int enimey1_posx = 0;
      int amo = 20;
      int sleeptime = 80;
      int already = 0;
      int fire = 0;
      int shooty = 4;
      int shootx = 0;
      int score = 0;
      Random gen = new Random();
      int num = gen.nextInt(15);
      int enimey1_posy = num;
      //Calebration of the motor.    VVVVVVVVVVVVV
      while(1 < 2){
         if(Button.ENTER.isPressed()){
            Motor.A.resetTachoCount();
            break;
         }else{

         }
         try{
            Thread.sleep(200);
         } catch(InterruptedException e){
            
         }
         int test = 0;
         LCD.clear();
         LCD.drawString("Calebrate \nthe MOTOR",0,0);
         LCD.drawString("To calebrate,\nTurn the wheel\n so the red\n pegs are facing\n left, Then \nPress enter",0,1);
         LCD.refresh();
      }
      // the main loop where the game runs!                VVVVVVVVVVVVV
      while(end == 0){
         LCD.drawString("| |",enimey1_posx,enimey1_posy);
         TouchSensor touch = new TouchSensor(SensorPort.S1);
         player_posx = Motor.A.getTachoCount() / 12;
         LCD.clear();
         LCD.drawString("/^\\",player_posx,player_posy);
         LCD.drawString("\\-/",player_posx,player_posy + 1);
         LCD.drawString("Score:",7,7);
         LCD.drawInt(score,13,7);
         if(fire == 1){
            
            LCD.drawString(" *",shootx,shooty);
         }
         LCD.drawString("Amo:",0,7);
         LCD.drawInt(amo,4,7);
         LCD.refresh();
         if(touch.isPressed()){
            if(already == 0){
               if(amo == 0){
                  LCD.drawString("No amo",9,0);
                  LCD.refresh();
               }else{
                  fire = 1;
                  shooty = 4;
                  already = 1;
                  amo = amo -1;
                  shootx = player_posx;
               }
            }
            
         }
         try {
            Thread.sleep(sleeptime);
            
         } catch(InterruptedException e){
            
         }
         if(shooty < 1){
            try{
               Thread.sleep(90);
            } catch(InterruptedException e){
               
            }
            fire = 0;
            already = 0;
            shooty = 4;
         }else{
            
            shooty = shooty - 1;
         }
         if(enimey1_posy == 7){
            enimey1_posy = 0;
            enimey1_posx = gen.nextInt(15);
            
         }else{
            enimey1_posy = enimey1_posy + 1;
         }

      }
   }
   }


OH and my version of lejos is 0.4.0, for some reason thats the only version that works for me.
Thanks
ovostick
New User
 
Posts: 3
Joined: Tue Sep 20, 2011 9:34 am

Re: help!, problem with exception

Postby s.frings » Tue Sep 20, 2011 10:02 am

When you compile the program, the compiler outputs a list of classes and methods. Just find the numbers from LCD display in that list and you have more details.
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm

Re: help!, problem with exception

Postby ovostick » Tue Sep 20, 2011 10:17 am

s.frings wrote:When you compile the program, the compiler outputs a list of classes and methods. Just find the numbers from LCD display in that list and you have more details.

But My compiler does not output a list of classes and methods ??
ovostick
New User
 
Posts: 3
Joined: Tue Sep 20, 2011 9:34 am

Re: help!, problem with exception

Postby skoehler » Tue Sep 20, 2011 10:20 am

ovostick wrote:
s.frings wrote:When you compile the program, the compiler outputs a list of classes and methods. Just find the numbers from LCD display in that list and you have more details.

But My compiler does not output a list of classes and methods ??

The compiler does not, but the linker does.

Do you use nxj or nxjlink? If so, add a "-v" to the parameters.
skoehler
leJOS Team Member
 
Posts: 1390
Joined: Thu Oct 30, 2008 4:54 pm

Re: help!, problem with exception

Postby ovostick » Tue Sep 20, 2011 10:25 am

skoehler wrote:
ovostick wrote:
s.frings wrote:When you compile the program, the compiler outputs a list of classes and methods. Just find the numbers from LCD display in that list and you have more details.

But My compiler does not output a list of classes and methods ??

The compiler does not, but the linker does.

Do you use nxj or nxjlink? If so, add a "-v" to the parameters.


well uh, Im actually using Eclipse to compile and download it to the NXT brick, not command or anything. so sorry i don't know.
ovostick
New User
 
Posts: 3
Joined: Tue Sep 20, 2011 9:34 am

Re: help!, problem with exception

Postby skoehler » Tue Sep 20, 2011 11:17 am

ovostick wrote:
skoehler wrote:
ovostick wrote:
s.frings wrote:When you compile the program, the compiler outputs a list of classes and methods. Just find the numbers from LCD display in that list and you have more details.

But My compiler does not output a list of classes and methods ??

The compiler does not, but the linker does.

Do you use nxj or nxjlink? If so, add a "-v" to the parameters.


well uh, Im actually using Eclipse to compile and download it to the NXT brick, not command or anything. so sorry i don't know.


Then you should have an nxd file, which can be viewed with the nxjdebugtool command line tool (Use --dump).
Or turn on "link verbose" in the options of your run configuration (use the menu next to green play button to edit the run configurations).
skoehler
leJOS Team Member
 
Posts: 1390
Joined: Thu Oct 30, 2008 4:54 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff