I recently put up a website featuring a Flash game I’ve been working on for a few months.  It is entitled, “The Bogstras: The Video Game” and features several of my family members as characters.  My reason for creating this game is twofold: First, I wanted to learn more about game development and needed a hands-on project, and secondly, I needed a Christmas gift for my in-laws. The title was a no-brainer.  “Bogstra” is a portmanteau of “Terpstra” (my family name) and “Boger” (my wife’s family name).  After a few days of jotting down design concepts and cooking up a game plan, the journey had begun!

The object of the game is simple – pick a character, and complete a mission based around that character’s personal interests.  Complete each character’s mission and win the game!  It seemed like a simple enough idea when it popped into my head last September.  I set a goal to release the game the day before Christmas, and provide everyone featured in the game with a hard copy burned to a well-styled CD (with awesome cover art).  But alas, as with most software projects, “The Bogstras” fell victim to underestimated time requirements and the game was released in late January.  The good news is, my family didn’t mind too much.  They were still thrilled to see and play the game, and I managed to learn quite a bit about making games.

HOW

Choosing Flash and Actionscript 3 as a development platform was pretty much my only choice.  It’s the only language I’m comfortable with that is capable of building decent games.  Although even if I was an expert in C++ or XNA or whatever the hip new game platform might be, AS3 would still be the natural choice given the fact that the game is deployable via the web, and everyone has Flash Player installed.  I also happened to have a license of Flash Builder 4.6 available from my workplace.  And just so you know, a purchased license for Flash Builder allows for installation on 2 personal machines per user. Highly convenient.

With my base language and development tools already sitting in my lap, I went searching for a game framework to help me get started.  After reviewing many interesting  frameworks, I finally narrowed it down to Flixel and Flashpunk.  I’m not entirely certain why, but I chose Flashpunk.  After perusing the tutorials, and slapping together a couple prototype levels to test out the code myself, development was fully underway.  Flashpunk makes is super easy to get a simple game concept up and running very quickly, as it provides code for the game loop, containers (worlds), entities, collision detection, spritemaps, and so on…

My prototyped levels mainly consisted of little boxes moving around the screen shooting things and bumping into each other.  It quickly became clear that I would need some help with graphics.  I wanted the in-game characters to resemble the real-life people, so I decided to hire a pro for that. Nearly everything else was harvested from hundreds of Google searches.  Of course, no tile set or pixel art collection was ever perfect, so I had to do some pixel pushing myself.  I found an amazing free (shareware) tool called GraphicsGale.  It’s sole purpose is pixel art and animation.  It made working with spritesheets, tilesets, and other pixel-perfect graphics a breeze.  I know I only scratched the surface of possible features, but what I did use was invaluable.  Although there were times where I needed to do some complex layering, or had to work with large jpeg images.  For that, Paint.NET (also free) filled in all the gaps. With GraphicsGale and Paint.NET, I was never left wanting for any gfx editing features.

After smushing together some code and graphics, I was ready to start building levels.  Flashpunk has built in functionality to take advantage of grid-based tilesets, and there is a nice tutorial on the Flashpunk website on how to implement this functionality.  However, there was also a nice tutorial on how to take some severe shortcuts by using a tilemap generator – namely, Ogmo Editor. With this tool, it is a much simpler task to lay out repeating tiles and design levels from tilesets visually, rather than completely in code.  Ogmo exports the layout information in XML format, which is easily read and interpreted by Actionscript.  Using Ogmo was a tremendous time saver, and I highly recommend it for use with any 2d, tile-based flash game.

Since all of the background music was composed by talented musicians (not me), sound was pretty much an afterthought.  There were a few places were sound effects were necessary to enhance gameplay, and for that I turned to BFXR by increpare.  If you need a quick way to generate some bleeps, bloops, chimes, dings and zaps, then there is no better tool. Just keep clicking until you hear something you like, and save it as a .wav file.  The only hangup is that sounds must be in mp3 format to be embedded in a swf file, so Audacity‘s batch encoding feature was recruited for this task.  Incidentally, BFXR is a derivative project of SFXR by Dr. Petter, but adds quite a few new features, and comes in an installable Adobe AIR package.

A handful of other tools used in the project were subversion (svn) provided by ProjectLocker, WordPress, and good ol’ pencil and paper.

WHO

Every great triumph has its cast of heroes.  The champions behind the aesthetic appeal of the Bogstras (which receives the lions share of praise) are true talents.  All nine of the characters, and their corresponding animations were hand drawn by Cecile Souza Santos, of Brazil.  I found her through the job postings section in the PixelJoint forums.  Her past work was very impressive, and her 16-bit RPG style was exactly what I was looking for.  Needless to say, she was a good fit for this project.  She is still active in the PixelJoint forums, and on DeviantArt with the handle Clest.

The music tracks were conceived and composed by Jordan B. Sanders – frontman for the Order of Týr.  Jordan is a co-worker of mine, and just happens to be an expert chiptune composer.  I’ve heard his music, both live and recorded, and knew that his work would be tip-top. And it was.

Last but not least are the countless individuals providing tips, tutorials, sample code, free images, and answered questions on the FlashPunk forums, StackOverflow, GitHub, and elsewhere on the internet.  If I were left solely with my own wits, this project never would have happened.  It is truly astonishing that I can shout a question out into the world, and no matter how technical or esoteric, I can be reasonably sure it will get answered.

Despite that the game was four weeks late, and has dozens of features left on the cutting room floor, I’m still pretty proud of it.  This was my first completed independent game project, and I think it turned out OK given the goals I began with.  I’m glad to have this done and behind me, but it also illuminated some interesting paths ahead.  There are definitely some game development concepts that need revisiting (A* pathfinding, pixel-perfect collision, Verlet integration, to name a few), and plenty of un-implemented ideas that could easily be retrofitted into a new game.  So enough jibba jabba, and back to work! (as soon as I catch that damn dog).

 

So I came across a situation where I had a whole bunch of items in a collection, and I needed to know how many of each kind there were.  In other words, I needed to know the number of each unique element in an IList, Array, ArrayCollection, or what-have-you.  I looked for some help online, and fiddled around and got it working.  Then a few weeks later I had to do the same thing, and darn near forgot how I did this.  Here is the trick – SORT!

Sort the items in the array (alphabetically, numerically, chronologically, etc…) so that unique items are grouped together.  Then simply loop over the collection counting identical items, and when a new item occurs, make a note of how many you have of the first item, and start counting again.  Below is a quick example.  Click “Generate” to create a list of 50 items, where each item is going to be a fish, cat, dog or pony.  Then click “Count” to count the number of each one.  Also notice how the original list is now sorted so all the ‘dogs’ and ‘cats’ are together.

Sorry, either Adobe flash is not installed or you do not have it enabled

Here’s the meat of the code:

sortedList = new Array();

//Sort Newlist Alphabetically
newList.sort();

/*  Create an object to keep track of each unique item in the array. For example
*   { Name: 'cat'
*     Value: 7  }
*/

var countObject:Object;

//Create a var to store the previously examined item in the list.
var previousItem:String;

//Loop over all the items in the newArray
for each ( var currentItem:String in newList )
{
//If the current item in the list is different from the previous item, then create a new countObject and start counting the new item.
if (previousItem == null || currentItem != previousItem)
{
//Create a new object
countObject = new Object();

//Set the name to the current item in the loop
countObject.name = currentItem;

//Count this item
countObject.value = 1;

//Put the object in the sorted list so we can see it later
sortedList.push(countObject);

//Done. Set the current item to the previous item.
previousItem = currentItem;
}
else  //Otherwise, we haven't switched to a new item yet, so keep counting the current item.
{
/*  Find the last countObject in the sortedList, then add 1 to the value of that object.
*   For example, if we have looped over 3 cat items in a row, and the current item is also cat, then:
*   { Name: cat, Value: 3 + 1 }
*/

sortedList[sortedList.length - 1].value += 1;
}
}

and Full Source for the above example.

 

If you are remotely interested in Actionscript, Flash, computer animation, games, or pretty stuff on computers – go get Kieth Peters’ book, “Foundation Actionscript 3.0 Animation: Making Things Move.”  Then check out
Keith Peters blog (but really his other sites).  After reading parts 1 and 2 of the book, which cover basic animation, I felt compelled to take one of the examples a bit further.

In Part 2: Basic Motion, the concepts of moving pixels programatically around the screen by shifting the x and y position every frame is introduced.  A ‘veloctiy’ is assigned to both the x and y values to determine how many pixels the object moves per frame.  The fountain example in the book demonstrates these concepts by shooting a bunch of colored balls from the bottom of the screen, with slightly random values for the x and y velocity.

I added some controls, just for fun.  Use the up and down arrow keys to increase or decrease the height, and use left/right to change the direction.  Also, if you look at the code, I changed the concept of x and y velocities to speed and angle. So rather then setting a velocity value for the x and y values of each ball, I set a speed and angle, and use this information to update the balls’ positions.  The original code remains in comments for reference.  Take a look.

FOUNTAIN DEMO |  SOURCE CODE

 

As a follow-up to my last post, I’m posting an app I made with Flex to demonstrate the effects of ColorTransform, both on a single colored object, and a Jpeg image.  Click the link below to start the app.  Once it shows up, use the color picker to choos a color.  This will change the color of the large square displayed on the screen.  Slide the slider controls around to create a color transformation.  As the color transformation occurs, you will see the newly created color appear as a circle within the square.  The jpg image will also reflect the color transformation.

COLORTRANSFORM DEMO |  SOURCE CODE

Continue reading »

 

ColorTransform is this mysterious class that had me baffled for quite a while.  You punch in a bunch of numbers, and somehow it is supposed to create one color from another.  But how?  How do the colors change? How do I get this thing to change the color of something on the screen when I want it to?  A fair bit of guesswork and luck was my answer.  Then I got learned up.  The Adobe LiveDocs got me started, but as for actually putting ColorTransform to good use in a real, live Flex project called for some additional know-how.

First, learn about colors on computers. You need to know what RGB stands for, and the difference between hexadecimal and decimal numbers.  Here’s a fun site called “Color Tutorial” (aptly named) to get you started.  And here’s a nice little page that demonstrates how RGB and hexadecimal numbers fit together.

Once you understand how colors are constructed from numbers, then understanding ColorTransform comes naturally.  All it does is jumble up the numbers with some simple math.  The math is explained in the AS3 documentation like this:

When a ColorTransform object is applied to a display object, a new value for each color channel is calculated like this:

New red value = (old red value * redMultiplier) + redOffset
New alpha value = (old alpha value * alphaMultiplier) + alphaOffset
New green value = (old green value * greenMultiplier) + greenOffset
New blue value = (old blue value * blueMultiplier) + blueOffset
If any of the color channel values is greater than 255 after the calculation, it is set to 255. If it is less than 0, it is set to 0.

So there you have it.  A DisplayObject has some colors, and you can transform those colors by fiddling with the RGB values.  You can even transform the alpha channel (transparency).  But how do you know what colors you will end up with?  That was a head scratcher.  Unless you have color codes memorized and are quick with the arithmetic, it’s darn tough to get an exact idea.  Here are a few resources that explain ColorTransform, and show it in action:

There, lots of nice examples.  However, in order to really take advantage of colors and ColorTransform, you should really know how to manipulate color values on your own.  In the flashandmath page, you may have notices a line like this:

RGB=(red<<16) | (green<<8) | blue;

What?  Yeah, this is an example of a bitwise shift operation.  Double what?  Well, follow the link from flashandmath to get a brief rundown.  The gist of it is, the little carrots >> help separate the R, G and B values from a color value, or put separate R, G, and B values back together as a single color with the << symbol.  The nitty gritty is still a little fuzzy, but you don’t need to understand all the nuts and bolts to use the tool.

Of course, I haven’t mentioned HSV as an alternative to RGB.  But these resources are just the tip of the iceberg when it comes to color manipulation.  Check out these sites for extra credit if you are feeling ambitious:

Enjoy!

 

It was necessary for my well being in recent weeks to learn as much as I can about the Swiz micro-architecture for Adobe Flex.  Lucky for me I had a simple Flex app sitting around just waiting to be converted from a giant mish-mash of mxml and ActionScript 3.0 to a nice, well organized micro-architected piece of software.  After much trial and error and gnashing of teeth, a successfully compiled application written with Swiz emerged, and is now posted for the enjoyment of whomever enjoys cats and coding.

A few caveats to remember when viewing the app and its source:

  1. The source is not exactly ‘code-complete’ – I’m sure there are bad practices in spades.  Kind criticism welcome.
  2. There is no real service call made by this app.  Rather than throwing my Petfinder.com API key out for everyone to gawk at, I’m using a static XML file that was spit out by a previous API service call.
  3. This is currently using a beta version of Swiz 1.0.
  4. This was originally written with Flex Builder 3, but ultimately released with Flash Builder 4.
  5. I had help.  Thanks a million to Jordan Sanders for a few handy pointers and putting up with my questions.  Also, thanks to David Tucker, Ben Clinkenbeard, Brian Kotek, and Richard Lord for instruction and examples.

PETFINDER APP DEMOSOURCE CODE

If people actually look at this post and are interested, I may be inclined to add more explaination, do follow up posts, develop the app further, etc… If you are interested in using the source code for whatever purpose, go right ahead.

 

Who: The House of Mews in Memphis, TN

What: A brand, spanking new website built from scratch.

Why: The House of Mews proprieter often complained that it was too difficult to sort through the hundreds of emails generated from forms on the old website.  It was also a pain for vounteers to update the adoption listings.  To view a list of available cats, site users had to navigate away from the House of Mews site and onto petfinder.com  Drupal 6 and Adobe Flex fixed these problems, and then some.

How:

Drupal 6 was used to convert the old HTML site to a CMS.  Also, site visitors can now register on the site to submit rescue requests, and rather than having that info clog up the email inbox, it goes into a searchable list (thanks to Views and CCK).

A similar method is in place to accept volunteer applications, but since these are rare, email notifications are sent out whenever one is completed. This was done with the Rules module for Drupal 6.

The real-time cat browser on the homepage pulls in data from Petfinder.com and creates an easily navigable listing of adoptable cats.  Volunteers who are used to uploading cat information to Petfinder don’t have to learn new software, and site visitors no longer have to leave the HoM site to view cats up for adoption. Win!

The cat browser was created with Adobe Flex 3.  It was amazingly simple – in fact, it was the very first Flex/Actionscript app I’ve ever created.  FYI – I’m currently converting this app to use the Cairngorm framework, and will be releasing the source code on this website some day.

 

So I’m currently working on a project for the House of Mews in Memphis, TN.  It’s a volunteer project, and kind of a long story on how I got wrapped into it – so I’ll save it for another time.  Anyway, a problem I’ve run into is how to effectively communicate ideas to the House of Mews proprietor.  Using words like content management system, web services, and flex app only draw blank stares.  Bumbling through a long discription of site features elicits some nodding, but the only response I get are questions like, “Can we keep the same music from the old site?”

Argh.

Enter Balsamiq.  The folks at Balsamiq Studios were nice enough to give me a free license since I’d be using it for a non-profit project.  I can’t be more grateful.  This app blows visio out of the water.  It’s so ridiculously easy to use. I cranked out a handful of wireframes in about an hour.  Since it’s all drag and drop, it appeals to the whole ‘instant gratification’ thing.  And when you’re done, you have this neat drawing that looks like you drew it yourself on a piece of paper.

Showing this to the ‘client’ avoided comments like, “that’s the wrong font,” and “that shade of red needs to be lighter.”  Instead I get, “Ohh, so you can click on the little pictures, and the cat’s bio appears. Great!”

Smile.

Here’s an example of a ‘first draft’.

Neat, right? Too bad it looked like crapola when I built it.  So I started over.  After shuffling things around, adding new ideas (and subtracting new ideas), I wound up with this – the mighty ‘work in progress’.

Go try Balsamiq.

 

Problem:  Artists Link needed a website that included a member directory that listed its members in alphabetical order with thumbnails next to each person.  Clicking the person brings up the bio, with a full size pic.  Additional pics are optional.

They also needed the usual organizational website stuff, like info pages, news and events, and contact us.  All of this had to be woven together in a nice tidy package that is dead simple to edit and update.

Solution: Drupal 6 with heavy use of CCK and Views.  Big thanks to the Color Wall theme. Views Slideshow provided the nifty image cycle on the front page.  It randomly selects images from each persons profile and prominently displays them on the front page.  Since the Member content type and member list view were already set up, all I had to do was install the Views Slideshow Module and toss a slideshow in a block.  Easy!

ImageCache saved me tons of effort by creating 3 different sizes of each profile pic.  Combined with lightbox2, ImageCache is pretty darn powerful.  All sorts of clicky functionality can be applied just by uploading one pic. Neat!

 

A great way to get a blog or simple website up and running very quickly is to use WordPress.  Blogging couldn’t be easier when using WordPress, as it provides a handy interface for writing and categorizing posts, adding features via widgets, creating RSS feeds for syndication, and allowing for static pages.  Another insanely useful feature is the ability to change the look and feel with the click of a few buttons using themes.

Themes allow your blog or site to take on a look of its own.  There are literally thousands of WordPress themes available for download. Many (most, even) are available directly on the WordPress website.  Searching Google for wordpress themes will get you a few million results, but many websites simply repost the free sites available on wordpress.org and wrap advertisements around them.  Premium themes are also available for purchase at many places, but again, some sites are more reputable than others.

However, if you want to graduate past premade themes and make your site completely unique, you need to learn how WordPress themes are created and make your own.  This may seem like a daunting task when viewing the WordPress.org documentation, but I stumbled upon a little gem that can’t be beat.  Go directly to Wpdesigner.com created by a young man named SmallPotato and view his tutorials.  The site is now defunct, but the tutorials remain, and are priceless.  There are actually two tutorials, one as HTML, and another as an eBook in 3 parts:

After reviewing these tutorials and referencing the WordPress Codex a few times (for widget code in WP 2.5 and 2.6), I was able to construct my own WordPress themes from scratch.  There are tons of WordPress tutorial sites out there, but this is by far the best place to start (IMHO).  Good luck!

© 2012 Eric Terpstra Suffusion theme by Sayontan Sinha