I'm working on a shoot-em-up style game in Love and have run into an issue with Tables, when I try to add a bullet to my table of bullets the project errors and it says that the length of field is nil the problem seems to focus around this block of code. The problematic code is within a class written for a basic enemy (name the Slider).
The odd thing is that this implementation of a bullet style system works perfectly with my Player class and everything works perfectly.
Code: Select all
function slider:shoot(target_x, target_y)
self.bullets[#self.bullets + 1] = {
x = self.act_x,
y = self.act_y,
angle = math.atan2(target_y - self.act_y, target_x - self.act_x)
}
end
Here is my Love file (as a side note, the classes are stored within the "lib" folder)-
Thanks in advance and sorry for the bother, it's my first (proper) attempt at making a game in Love.