Building Games with Flex: Tic-Tac-Toe Version 1

Getting Started

Note,  while this isn’t anything like PlayCrafter, it is my small step into the huge world that is game making.  To get into gaming, I figured it would be best to start with the language I use day in and out: Adobe Flex.  To be honest, I can’t remember the last time I coded just for fun with Flex.  Most non-Workday Flex code I’ve built on my own time has been for 360Conferences, for some technical training/presentation or for my articles on Adobe’s sites.  I forgot just how fun programming can be.

I set out late Friday night/early Saturday morning with one goal:  Exit the weekend with a working version of a game.  I didn’t want to put much game theory in.  I didn’t want to OOP the heck out of the code.  I just wanted to build something that I could play and post on the net to share.

My programming goals for the Version 1 code were:

  1. Try to use as few class files as possible
  2. Keep the code as basic as possible
  3. Mentally note what could be optimized
  4. Hardcode game logic when possible

Why impose such “low” goals?  I wanted to leave the weekend with something to actually play.  Plus, this is version 1 so it’s part prototype/part real project.

Even “Fun” Projects Have Time Constraints

The biggest problem I had going into the weekend was the same problem any project has: time.  This weekend was sandwiched in between my birthday and wedding anniversary.  I held a kickoff BBQ for my cub scouts on Saturday afternoon and some running around earlier in the day to prep for it.  On Sunday, I had church and made dinner to take to some friends who just had a baby.  On top of that, I had my 2 little boys who both wanted me to do different things when I was free. I knew the weekend was going to be busy though, so that’s why I had low goals as far as the code went.  The most important thing was coming out with something to play.

I’ve been reading a book, “The Art of Game Design”.  It’s a great book and one you should read even if you’re never going to make a single game in your life.  Jesse’s writing style is superb, the first “textbook” I’ve read in a long time that has a real voice.  He covers things about life in general and ways to connect with your audience/customers, regardless of what business you’re in.

The book has me fired up to get going on game development.  That and the fact that I haven’t made a game since 1988!  I realized though that I was going to have roughly 4 hours of time to put into the game.  With that being decided I quickly set about my way.

Why Tic-Tac-Toe?

I didn’t want to waste a lot of time picking a game.  I wanted something simple where I knew the rules inside-out.  I also wanted a game that everyone knew without explanation.  Therefore, Tic-Tac-Toe seemed like a good place to start.

Another goal I have for this project is to make it iterative.  I want to slowly transform a simple code base full of hard coded logic/styling and transform it over time to something completely customizable in both logic and styling.  If you want to make the game board 5 x 5 instead of 3 x 3, go for it!  Want to replace X and O with images of you and your significant other, you should be able to in a simple and easy way.

Therefore, while the code is simple, I did keep item 3 (from the goal list above) in the forefront as I made this first pass.

Did I make it?

I sure did.  Q&A was probably the hardest part.  Trying to purposely NOT have a winner when playing alone took a while at the start!  Also, trying to remember which paths of winning (across the top, across the side) and with each piece (first with X, then with O) was hard when my boys would pull me away mid test.

I finally wrapped it up early Monday morning. (Early mornings tend to work best for me to do any work as everyone is still sleeping.)

I’m proud to be able to show you my first game, “Tom’s Tic-Tac-Toe”.  I’ll go over the code in another post, but for now you can just enjoy its greatness!  🙂  Okay, more likely, dismiss its simpleness, but keep it mind that it will get better over time.  We all have to start somewhere!

Click here to play

6 thoughts on “Building Games with Flex: Tic-Tac-Toe Version 1

  1. That is funny, I have been reading “Rules of Play” and have been getting the same urge to start making games. Here is simple game i started http://blog.unthinkmedia.com/?p=86 , nothing crazy i just don’t have much time to make it nutty.

    I think i will pick up the book you are reading next. Since my wife is prego I also have become the early morning coder. Best of luck!

    One idea i had for tic tac toe, although I am not the greatest electronics guy is to create a tic tac toe game that makes the users somehow avoid creating a short circuit, or the first user to light up an LED. So you would actually have several types of pieces (Resisters, jumpers, etc), the ultimate nerd twist to tic tac toe. Not sure even how to start that, but it was a thought that passed through my head.

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 )

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