Here's the bullet collision, by the way. It's a good thing I'm deleting all bullets that leave the screen or I bet this process would start to slow down real quick.
Nice! If you have a chance, it may be worthwhile to make a modular set of functions to determine intersecting objects that you can then use inside enemybulltecollide() and other collision checks. I'm currently using a couple functions for different purposes:
function in_range(value, imin, imax)
return value >= min(imin,imax) and value <= max(imin,imax) --min/max calls are unnessary if imin and imax are correctly ordered
end
function range_intersect(min1, max1, min2, max2)
return in_range(min1,min2,max2) or in_range(max1,min2,max2) or in_range(min2,min1,max1)
end
function rect_intersect(r1, r2)
return range_intersect(r1.x + r1.off_x, r1.x + r1.off_x + r1.width - 1,r2.x + r2.off_x, r2.x + r2.off_x + r2.width - 1) and range_intersect(r1.y + r1.off_y, r1.y + r1.off_y + r1.height - 1,r2.y + r2.off_y, r2.y + r2.off_y + r2.height - 1)
end
Where each object has an x/y position (.x,.y), an x/y collision box offset if I don't want it to start at x/y (.off_x/.off_y), and a width/height for the collision box (.width/.height).