Apr 09

This will come as no surprise to my closest friends, but I am a long time game development admirer. Although I’ve never done anything professionally I did spend some time in the past studying this amazingly interesting field - it’s my dark hobby. As hardware evolves and gamers demand more and more reality from their consoles, the game development industry is one of the few that basically didn’t suffer with the latest economic crisis.

3D games are getting more and more sophisticated to the point that it’s very hard for a single person, or even a small team, to develop something worthwhile - think of all the people you need to develop a game such as God of War III: screenwriters, artists, musicians, sound engineers, 3D artists, animators, programmers, level designers, combat designers, actors, voiceovers…

So I just wanted to have the experience of writing a full game, end-to-end, and that’s where FallingDreams comes in. To be able to do that in a short amount of time, it had to be something simple and that’s why I chose Tetris. Although simple, it does share most of the steps common to modern games development. It was a very interesting project to work at and you can grab the result here. The source code is also available on my github account, here.

FallingDreams is written in Java (JDK 6) and as such it should work fine on Windows, Linux and Mac OS. I tried to be as loyal as possible to the original Tetris rules, but you might find one thing or two that don’t work as one’d exepct.

Enjoy! ;)


Disclaimer: This was my first ‘full game’ and is not intended to be production ready. The code has definitely got room for improvement and it served as my playground where I experimented different design techniques, both game and general software related. And it doesn’t have a single line of tests - crucify me :P

As I said, it’s not supposed to be considered bug free but I’m sure people interested in games development can benefit from the source files. Feel free to fork it as well! It would be cool to see what people would do with it :)

Tagged with:
Feb 25

Learning new programming languages is fun. And if it’s your 2nd, 3rd…Nth programming language you will eventually look for features you already know and love.

Coming from Ruby - but after having done my fair amount of Java for many years, among other things - I end up looking for features like blocks, open classes and syntax sugar like automatic generation of attribute accessors. These are hard to let go of.

Having decided to learn Objective-C recently, I was delighted to find out that all of these are available - for better or for worse - and wanted to share this analogy with its Ruby counterparts.

- Attribute accessors

In ruby, this class definition

class Person
  attr_accessor :name
end

implements for you the getters and setters of the instance variable name.

In Objective-C, the combination of the @property and @synthesize directives provides you with roughly the same result:

// in the interface file
@interface Person : NSObject
{
	NSString *name;
}
 
@property(retain) NSString *name;
 
@end
 
//in the implementation file
@implementation Person
 
@synthesize name;
 
@end

Now the compiler is responsible for writing those getters/setters for you.

- Open classes & blocks

Blocks in ruby are the structures that allow you to - among other things - iterate over arrays like this:

my_array.each do |item|
  puts(item)
end

Objective-C doesn’t have an ‘each’ method in its root array class (NSArray) but since it does support blocks and open classes, you could just write it yourself:

//in the interface file
@interface NSArray (each)
-(void) each: (void (^)(id *))block;
@end
 
//in the implementation file
@implementation NSArray (each)
 
-(void) each: (void (^)(id *))block {
	for (id *object in self) {
		block(object);
	}
}
@end

Yes, I know the syntax isn’t appealing, but using it in your program is a bit better:

[myArray each: ^(id *item){ 
    NSLog(@"Current item: %@", item); 
}];

Given the syntactic differences, the code above is very similar to its ruby counterpart. Iterating over an array is just one of the many things blocks are useful for. Others might include dealing with files, network sockets etc…

Blocks are powerful structures and are not created everyday, but it’s nice to know that you can resort to them when the time comes. ;)

Tagged with:
Jun 08

This is basically a compilation of a few tools/habits that I use to keep focused and at a high level of productivity when working alone. Works great for me and I hope there are useful tips for you as well.

Music
This is one of my favorites. When working alone I hate having noisy people around, which happens quite often if you work in an open office space like me. - It is great for pair programming but I find it inefficient otherwise. Thus, I came up with the term the Heavy Metal effect. Ok, just fit your favorite music genre there but the important thing is that it must act as a barrier to the outside world. It won’t work if you put something new and start babbling the lyrics!
Password Manager
In my day to day I have a number of web sites open like API documents, programming related groups, email… There are also the ones you open a few times a day like the company bug tracker, review board and etc. I find that having a password manager, in my case LastPass, saves a lot of time. The big advantage of it over similar tools like 1Password is that it works on mac, linux or windows. It’s just a firefox plugin.
Multiple Workspaces
Probably the most obvious item on this list to developers but I’s never too much to reinforce it. Multiple workspaces are great. And they are available in whatever platform you happen to be locked in. In my case, I split my environment in at least 3 workspaces:
-Development - where I keep things like my IDE, Browser and Terminal
-Documentation - where I keep API documents, tutorials and related stuff
-Communication - where I have my email, both personal and business, twitter and etc. This allows me to easily set a time per day to do each of my stuff without having noise from things that aren’t important to what I’m focusing in that very moment.
App Launcher
A must! On Mac I use QuickSilver and on Linux, Gnome Do. I won’t say much here. If you don’t use some sort of application launcher, do yourself a favor, stop reading and install one. You have no idea of how comfortable and time saver they are.
Batch tasks
Maybe this wasn’t the best title but I couldn’t think of anything better.
As a result of having a communication workspace that I use a few times a day, I find stuff that I’m interested in but don’t have the time to dig at the moment. So I need a way to queue that and read later when I’m home. The tools of the trade in this case are Twitter + Evernote.
Evernote is roughly a to-do manager. And since they released their Twitter integration it’s been dead easy to queue those things I talked about earlier. Just send a direct message to evernote and the item gets added instantly.

Now, what about you? What works for you?

Tagged with:
preload preload preload