Hey there guys!
I'm developing a tetris like game for mobile. I had a hadache getting the movement mechanics to work, since I'm a newbie, and because I wanted to move the blocks with swipe controls on the mobile. In the end, I came up with this function.
It may be a little messy, but it worked perfectly. I'm using 16x16 tiles, so this is why there is so many /16 and *16. Is to always keep the blocks inside the 16px grid. The "touchDistanceForFrames1to5" is to compensate the distance between the touch and the block (so the block won't simply teleport to the touch's X location).
Now to the problem: I can't make the blocks collide to the laterals of the game area (I've created 2 very tall retangles for the collisions, one to the left and other to the right). I got all sorts of problems. I simply couldn't make the blocks stay inside the playable area. I've tried on collision, is overlapping, nothing worked.
Any tips on how to get this collision working? Or maybe to simplify all this mess with the movements?
Thankssssss!