I haven't checked the code out yet (because it's telling me it's an invalid zip file, or it's just my computer stuffing up) but for your creating enemies question, you could just create a table that stores no. of enemies in that table. I'm pretty inexperienced, so better people can correct me if I'm wrong.
Code: Select all
enemies = {}
for i = 1, 7 do
enemy = {}
enemy.width = 30
enemy.height = 10
enemy.x = i*100
enemy.y = enemy.height + 50
table.insert(enemies, enemy)
end
indention might be wrong and whatnot, but this code tells it to create a table called "enemies", with 7 tables inside it called "enemy" that have the width, height, x-pos and y-pos. For your question about bullets and it colliding with enemies, it has something to do with the CheckCollision() function.
Code: Select all
function CheckCollision(ax1, ay1, aw, ah, bx1, by1, bw, bh)
local ax2,ay2,bx2,by2 = ax1 + aw, ay1 + ah, bx1 + bw, by1 + bh
return ax1 < bx2 and ax2 > bx1 and ay1 < by2 and ay2 > by1
end
There have been a lot of questions asked about CheckCollision and how it works so just search those up.
I can't get the link right now but search up in google: Love2d pew pew and click on the first link, it'll show you a pretty rough tutorial on making a space-invaders esque game.