Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
the snake game don't like me.
#1
I keep geting this error message:

Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: 1

at Snake.snakeCanvas.CheckScore(snakeCanvas.java:173)

at Snake.snakeCanvas.Move(snakeCanvas.java:156)

at Snake.snakeCanvas.run(snakeCanvas.java:288)

at java.lang.Thread.run(Unknown Source)

Can anyone help?
#2
I'm assuming that means you're having problems with this line:
[code2=java]if (score > Integer.parseInt((highScore.split(":")[1])))[/code2]

If this is so, then the problem is that the highScore variable does not actually contain a colon! So the data past the colon could not be retrieved. This can be fixed by adding a check like
[code2=java]if (highScore.contains(":"))[/code2]

So, you could combine them to prevent errors, like so:
[code2=java]if (highScore.contains(":"))
{
if (score > Integer.parseInt((highScore.split(":")[1])))
{
//do stuff here
}
}[/code2]

I hope that this helped!
My Blog | My Setup | My Videos | Have a wonderful day.
#3
It works! I also watched your latest video on this subject a second time and found some stuff I missed. I also got 460 points! <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile -->
#4
I'm glad you were able to find even more stuff that you missed and that you aren't having too much difficulty with the program! It's fun, ain't it?

460 points? Your grandmother could do better in her sleep. <!-- sWink --><img src="{SMILIES_PATH}/icon_e_wink.gif" alt="Wink" title="Wink" /><!-- sWink -->
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Drunk_Snake Game PLEASE HELP!! andre2pi 2 7,147 01-05-2014, 11:15 PM
Last Post: brandonio21
  How to export Snake Game as a Runnable JAR file? bedigursimran 0 4,955 11-19-2013, 10:01 PM
Last Post: bedigursimran
  NumberFormatException with Snake Timkat1994 1 5,570 09-17-2013, 11:11 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)