So i've been working on a game based on my rough and unfinished
Space game. The idea is almost the same, Except this one will have enemies, shooting and all that stuff. My problem is with the enemies. Right now i can spawn the enemies (press y ingame) but they don't do anything, I wanted to make sure i can de-spawn them before i start writing some sort of AI for them, And that's where the problem is. If i spawn 2 enemies, then shoot (space ingame) the first one i spawned, The game crashes. If i however shoot the 2nd one first, then the first one, It's all good..So yeah..that's where you guys come in..any help is appreciated.
Here's the code that deletes the enemies so you don't have to look for it:
Code: Select all
for i=1, #enemies do
for c=1, #bullets do
if checkcollision(bullets[c].x, bullets[c].y, 10, enemies[i].x, enemies[i].y, 50) then
table.remove(enemies, i)
end
end
end
That's in enemy.lua
The code is pretty messed up right now, Plus a bunch of bugs..Any suggestion regarding that are welcome too..
also, Don't worry about the ship being referred to as "car" in the code..the idea started as a car game. lol