T-T-Tetris Breaker

I’m still after 4 months never sure how to start these articles, but basically this is my piece on how in my 4th month of game development I made Tetris!

This month has been a little different for several reasons:

  1. Dave & I worked on 2 separate games, not the same one – I made Tetris, he made Asteroids
  2. It’s the first month I’ve done development work in a full-time role (sadly it’s not games development, but that’s what this blog is working toward)
  3. I only had 3 weeks available to me as I was away in Croatia for the last week in September
  4. The game isn’t technically speaking complete
  5. I’m not releasing the game to be played

All the above have provided interesting challenges. I’m very happy to be in a full-time job finally earning my way in the world, unfortunately it’s nothing to do with games, and it’s not a coding job either that I could get further in-job experience with – but patience, I’ll get there. However both the job and the weeks holiday left me with a lot less time than normal to complete the game, hence No.4 but also partly not.


I gave Dave the task of making Asteroids because I felt he needed to further develop his base coding experience. Really getting to grips with the bog-standard stuff in Unity code like the “Update()”, “Start()”, “FixedUpdate()”, “OnCollisionEnter2D()” etc. I didn’t help him one iota, he managed it himself with a bit of googling and I’m proud of him for that, hopefully it’s given him a further hunger to develop along side myself to make some cool games in time.

The last 2 points are ones that need explaining. I can’t release Dave’s game without his wanting, and since I’m not releasing my own I feel it a little silly. Basically I’m not doing it because it’s not fully complete but also I’m coding for me right now, I’m spending my time developing classic games because I want to see how they’re put together so I can draw upon that experience later on down the line. I had to think at the beginning, “How is Tetris set up really though?”. That’s also why it isn’t complete, the core functionality is there, however things like score, difficulty ramping, a menu system – I’ve done all those several times before, it’s a couple of lines of code and none of them would be a new learning experience or the attempt at some interesting design to improve the game. So the game isn’t fully complete due to that and I don’t see a point in releasing it to be played really. This is for me right now, and I don’t want to waste your time with very familiar games.


As for how Tetris was made itself, I was surprised how simple it ended up being. Basically I took a game object of a block, made several and arranged them into the classic Tetris shapes. Those items are housed in an array which randomly instantiates an object between 0 and the array max. Simple stuff really.

Movement is all array based. The screen is effectively a 2D array¬†of Transforms. This is because Transforms allow us to store and manipulate game objects data, and since we’re working with parent/child dynamics due to multiple game objects making up a whole Tetris piece, Transforms allow us to affect hierarchically too. The majority of the coding is all in this Grid and all it really deals with is Transforms so it’s important to understand them.

What’s important in the tutorial I went through was the idea of building upon each function made, so start with something very simple and go up and up from there. So the first thing done was to create functions to check if the blocks were inside the correct positions. From there it then went on into given a certain array row value, go through each element on that row, destroy the game object there and set it’s position to null. This would wipe an entire row of objects only. The need for setting the position to null is because while the game object might be deleted the position in the array that it corresponds to needs to be deleted at the same time.


From there on it was a case of moving objects down by iterating through rows again, then moving entire rows down, then seeing if rows were full and finally deleting full rows which involved deleting the row and then decreasing the rows which we’d already written functions for. So despite the growing complexity, because of starting simple and building up, it was easy to maintain.

I want to keep this brief as it’s not the most interesting of projects, and I did it mainly to just understand the mechanics of how that type of block movement was achieved in Tetris. I’ve already done some block movement with Snake, but I wanted to see how different this was. I’m incredibly glad I did it, but I am after 4 months now looking for bigger projects with more challenges, something like Mario is being considered as it includes the use of character animation as well as the normal 2D movement I’ve been learning about. It also allows for some minor AI and some Camera control! These are all things I’ve not had to worry about before, but I’m looking forward to tackling them in the next few months so that I can be in a position maybe another 4 months from now to say: “Right, development on my own game begins now!” and I can know with confidence it’ll at least be half-way decent!

This post has been a bit just straight to the point and not the most informative, and that’s because there hasn’t been much to tell, it’s mainly been a project of curiosity for me. I knew I wouldn’t have much time to start a bigger project than normal and I was interested in how it worked. So if you’ve somehow managed to stick through until now, bravo! But until next time, thanks for reading, have an awesome day, and keep on designing!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s