beatLines - A 557kb game in Unity with under 200 lines of code (that includes the comments!)

I’ve always been a believer that the early days of learning game design and development should be like learning a musical instrument…you practice by playing the stuff you listen to. So why not practice game development by making the stuff you play? Then, when you’re good at the basics, you can move onto your own stuff… I really think one of the worst mistakes you can make in the early days is to get carried away and try to make ‘Left 4 Dead’ when you don’t even know how to make Pong…

On the flip side to that, it’s always fun to have small pet projects when you’re bogged down with all the difficult stuff. Creating something basic, with a quick turnaround is a good way to give yourself a quick pat on the back.


So, In order to help some of the newcomers along, I’ve attempted to show how easy it can actually be to create a game in Unity…by recreating one of my favourite games, Elektroplankton.

I loved Elektroplankton on the DS. It was a great mix of quirky and retro-chic…with a nice bit of music generation thrown in. So, for a few hours over the last few weekends I’ve been playing around with recreating the core mechanics. I don’t really have enough time to create proper beats and hooks, so it’s just placeholder sounds. Anyway, Here it is, and it’s called ‘beatLines’.

Source Code…

beatLines source code download

In order for it to be of any use to people, I’ve provided the source code, so you can see how it was made, and go about making your own changes. I’ve commented on most of the lines to give a good idea of how it all works, so hopefully you can work it all out.

Whilst the game is under 200 lines of code, which is a 1/3 comments, it still isn’t the best way in which to make something like this…why? Well, I wanted to cover some things that might become useful in your future developments. The main things that are covered here are…

Triggers
Playing Audio
Turning scripts on or off
Assigning objects to GameObject variables at run-time.
Switching textures
Setting min/max int values
OnMouseOver
Basic input from left and right mouse buttons
Referencing static variables from scripts attached to other objects

So, for example, each time we click on a waypoint, we change the position it faces. We are in fact loading a new texture. We would be better off actually using one texture and rotating the object to actually face the desired direction. If you want to experiment with optimising the code further, then it’s all setup for you, otherwise it can act as a nice reference point to see how you can do certain things…

It’s desperately crying out for some really cool beats, because at the moment it’s just placeholder sounds. If you want to add your own stuff, go ahead. Alternatively, if you’d like to contribute some sounds, then give me an email.

Web Player Version
beatLines - A 557kb game in Unity with under 200 lines of code, including comments.

Sounds provided by http://www.superflashbros.net/as3sfxr/ (thanks to @iainlobb )

4 notes

Show

  1. therussmorris posted this