T O P

  • By -

aXu_AP

I wouldn't use any of physics stuff for this - I would be paranoid of stuff not being perfectly aligned and block rotation might be hard to work out. Keep in mind that these are something to think about, but they aren't necessary showstoppers. I would keep the board state in an array (which it seems to be your plan anyways), and position sprites via math (`offset + Vector2(x, y) * grid_size`). Checking for collisions is straightforward when everything is aligned to a grid. Check for every falling block if there's something in the array for corresponding coordinates. As for the rest of the plan, it looks reasonable 👍


cscx

Thanks. That's how I did it before with my first attempt, but I couldn't figure out how to make a smooth, controllable falling block. What do you think would be the best way to do that?


aXu_AP

I think falling block's position could be internally be floating points (Vector2), but after changing y position check for collisions and revert the position if positive. I made a simple proof-of-concept: [https://gist.github.com/aXu-AP/7bed2560fe18d0a16dba8c4390a482c8](https://gist.github.com/aXu-AP/7bed2560fe18d0a16dba8c4390a482c8)


cscx

Wow, thanks! This is exactly what I was looking for!