
Then the buffer is uneven on the bottom of the tile. But for shapes, like the “L”, that is not true when it is rotated. Moreover, the buffer for the bounding box was just a straight line under the bounding box. But the tile has a three by three bounding box, and thus when the piece is entering the opening, so does its bounding box, and so, the extra column is ruining the stacked up tiles as it is moving down, by clearing everything in its trail. Imagine there is room exactly for that “o” piece, i.e. The moving three by three bounding box would override the color on the stack below. If this is vague, imagine a stack of tetris tiles nicely fit together, and an “o” tile is coming down, that is the square piece, and it is two by two. The three by three bounding box was great here, I could copy the box and paste it into the main board and see the tile appear and start moving down.īut here is where it blew up. So I added all the shapes with their rotations on a new sheet called Tiles so I can copy from there and paste on my board. Then simply copy and paste what is above to a row lower, which now is empty.Īt this point I decided to add all the other tetriminos (or tiles). Basically check to see if a row sums up to 24, which is the number of columns in the board, and clear that row if it does. The buffer was the row immediately beneath the bounding box As a result, if the buffer encounters 1s, it must stop.
For stacking, a shadow sheet, called Board_ was writing 1s where a tile rests finally, but not while it is falling.
Lumpty tetris code#
For moving, I would have the code check a cell value and then move the tile to left or right accordingly.For making a tile fall, I had an infinite loop that will move down the range and sleep for a set time.I put the tile in a three by three bounding box, to help me with moving it down and basically interfacing with the bounding box, instead of every cell of the tile. Devise stacking of the tiles on top of each others.Add controllers for moving them right and left.
Make a colored range drop, a range is a set of contiguous cells on a straight line. I started by exploring the deal breakers, like a tile moving down and the ability to move them around. This is a more technical part so you could skip it if not interested. I like the one where the script won’t stop. Unfortunately, though I was laid off, you can still see those videos in this folder. The reason is that I was planning to demo this time lapse to the company on my upcoming second anniversary. I kept video logs of my progress at first but then I stopped midway. Thus I refactored part of project 2 to make it less like an App Script project and more like any other app, with objects, abstractions, and nice methods like addRow or moveDown which would take care of all the references and named ranges for me.Īs part of an inner joke and perhaps because of the influence of some libation one Friday evening, I thought to myself if I can make Tetris on App Scripts, and that is how it started. That was my gateway at that point, I knew this would grow grotesque and I cannot maintain it sanely. In this second project, we had to have multiple tables in one sheet and be able to insert an arbitrary number of rows and columns in any order in any of the tables without the formatting or the application breaking. This first project was well received, and thus we moved on to a second more involved project. I have to confess, App Scripts has a great documentation, and thus it is very fun to work with. But then, of course, I was getting paid to be a resource, so I thought if I think myself so hot, how good of a job I can do really? My first thought was to ask him to go and do what he must, to reach satisfaction posteriorly. If you don’t know, Apps Script is the scripting language for Google apps like Sheets, Docs and Forms etc. I believe it was Q1 of 2018 when my PM (hey Dennis!) asked me to do this Apps Script project on Google Sheets. Make a copy of the Google sheet file and add it to your drive.ĭo expect some wonkiness - read the bugs part please. I might fix it one day.But if anyone feels adventurous, I welcome and appreciate the help. UPDATE: I was and then confirmed that the app no longer responds correctly to arrow inputs. I made a game of Tetris on Google Sheets.