Every object/enemy in my game are in a big [][] array, and then all the items are put in a [] array, and all the enemies are put in a different [] array,
I ve done the collision for my regular attack and ranged attack, and it works fine, but the problem is i haven’t animated the enemies yet,so they are just sitting there waiting to be attacked
because of that, no two enemies are in the same grid, so i can do collision quite easily
but enemies have to move lol…
my main character class has a column number int that is basically what column he is in, and my enemies has the same thing,
so there is two ways ii think i can do collision
-
have a loop that goes through the entire enemyList and checks each enemie’s column number to see if it is the same as the characters, or if it is one in front of it (if character facing left, then check for the current column and one behind it).
-
make a ArrayList that can hold several enemies, and make an ARRAY OF ARRAYLISTS for the entire level, and then each time an enemy moves, put him in the corresponding array index,
then when i test for collision, I just test my character’s current col position against the current array index, and go through the entire arrayList to test (if !arrayList.isEmpty())
so which way would be faster or is there something better>?