View Full Version : So many errors D:

11-29-2013, 08:11 AM
Hey guys,

We as the Alice Appreciation Society where set a task in university to make a game on Alice with a two week deadline. We came up with a zombie FPS however we started to get some bugs with the ending screen.

We've used a decrement operator within a loop to reduce player lives when the proximity of an enemy is within 2 metres of the player. However, once the lives reaches 0, the game displays a bug. It states:

Error during simulation.

Throwable that caused the error:

java.lang.ArrayIndexOutOfBoundsException: -1 not in range [0,5)

We have an array for our enemies (six zombies). Something is wrong with the way we have implemented this array into the game. If anybody could take a look at this soon and offer some suggestions, we'd be eternally grateful.

Kindest regards,


11-30-2013, 08:32 AM

That kind of error indicates that your program went out of range when dealing with arrays. When using parallel arrays for things like your zombies, all relevant arrays should be the same length, or problems can occur.
Also cross-check all logic that decrements array pointers to make sure that you don't accidently slip past zero.

12-13-2013, 11:56 AM
The problem is in the zombieXai methods. You step through each zombie using indexes and comparing zombie to zombie+1. This works fine until you get to either an empty item in the list (item 6 = none) or you get to the last item where you are trying to compare the last zombie to the last zombie +1, which doesn't exist.

Usually either you would not use the last element or you would compare it to the first one at index zero. The index 0 alternative involves using modular arithmetic which is not directly available in Alice but can be simulated.

The major suggestion I would make is to get rid of your zombie ids and different methods and events for each zombie and use the list functions.
In a mouse clicked event you can call a method and pass it the "object under the cursor" then use this object to each one in the list until you find the matching one. Also you can get rid of zombieMaximum by using the length of the list if you need to know the number of items in the zombie list. WARNING: remove item 6 from you list, or make it a zombie.
Finally, you can get rid of the zombiesAlive list. This can be done by simply removing dead zombies from the list and checking for a length of 0.

So you would be going for something like:

if the mouse is clicked on anything call zombieAi with the item under the cursor.

ZombieAI curZombie

For all in zombieArray one zombie at a time
if(curZombie == zombie) then
do your stuff here.
do nothing

01-02-2014, 12:17 AM

As per me, you have concern your problem with some expert in particular field.
Because it requires expert attention.

Thank You.