# Love2D : How can I keep up with lots of small sprites' collision data?

So I'm using a SpriteBatch to keep up with lots of small pieces for a falling-piece puzzle game. I have an array of Quads (for different color blocks), and they are randomly added to the aforementioned SpriteBatch. Right now, the game determines when the current piece has hit the ground, then that piece is stopped and a new piece spawns that the player now can control.

In order to figure out when to stop dropping the piece, I need to do a collision check. This shouldn't be hard, because I should only have to check the falling piece (unless the current falling piece causes a chain reaction). But, what type of data structure should I use? I can't use the position data of the individual Quads, because the boundary boxes will actually be a different size/shape than the pieces (think triangle pieces, but I will need to use a slightly skinnier rectangle to fit upside-down pieces in between right-side up pieces).

Should I just duplicate the (x, y) pairs using offsets with a width and height, and store them in an array, or am I missing a more obvious/efficient way? I'm guessing that the play screen could fill up with several hundred of these pieces, and if I add two player mode, double that.

• Are you making a tetris clone? And are you using the physics engine for collisions? Commented Mar 25, 2013 at 23:31
• Have you tried it? A hundred collision checks every second is nothing. Don't solve problems you don't have! :)
– Anko
Commented Mar 26, 2013 at 11:03
• Thanks for the response. For clarity, it is not a Tetris clone (triangular pieces that can either point up or down in a staggered configuration). I'm not using the physics engine, because the Love2D page said it was overkill for a situation like this. I'm already in the process of trying it now, but part of the issue is that I need to use a quad of a different size for the collisions. If you draw a square around a triangle, there is too much dead space to allow for "proper" stacking. Commented Mar 26, 2013 at 13:06
• Are these blocks fixed to a grid? What do you mean by them having different sizes? Screenshots or drawings would help.
– Anko
Commented Apr 17, 2013 at 15:14
• Are the triangles always aligned to that grid? If so, you could simplfy it by ignoring the fact that all of your blocks are triangular and just checking whether the location below in the grid is filled or not.
– Anko
Commented Apr 26, 2013 at 14:05

if slotThatIsNext.empty == false then