Flash game programming may sound like a ball of laughs – lol – and it is! It brings into play a whole new range of mathematical disciplines that replace the traditional web designer’s compatibility challenges. But don’t let that stop you – flash game programming is just plain fun and rewarding!
Bingo, a far as programming goes, is a very simple game to code – however, this project also required the creation of the complete server management to support it (player stats, leader boards, galleries etc). The biggest challenge was chat without proxy server software on the server so all traffic needed to be purely http. So the system was designed to follow a simple flow – a cron file on the server would create a game every 5 minutes, the flash client would pick up and role-play that game and the server would update the winner’s stats once it knew the game had ended.
Poker is a fun game, loads of fun to play and even more fun to code. As far as the flow of the game goes it was pretty simple to code, so the challenges were in the hand evaluation and the AI of the five computer controlled opponents. It required a built-in value system to be placed on certain card combinations based on their probability of becoming better hands in later rounds, and the AI players could then follow a set pattern of bluff or raise to take advantage of that so their game play style was different from each other.
Roulette is a wheel based game that required a random start and end position for the ball. Players win based on the outcome of that final resting spot so the animation had to time perfectly regardless of starting position. Fortunately I had a 3D wheel to begin with, so making animations based on movement were relatively simple, but the timing had to be a visual ‘fudge’ in the end based on the fact that people can’t see the numbers when it’s in full swing anyway.
Slots is possibly the simplest game to write ever – each tumbler is represented by a single movie clip that contains all of the patterns in a set order and the roll is merely a random number of loops through the animation of it moving from top to bottom. The speed of the animation is decided by a timer so that each tumbler can slow and eventually stop in sequence. Flash is perfect for this sort of replication since each symbol is only held in memory once making the file size of a slots game entirely dependant on the complexity of those symbols.
In order to accomplish this project for a friend’s web site I had to come to grips with the mathematics of physics … arrgghhhhhh … my old school days return to haunt me for not paying attention in class – lol. This sort of game cannot be created simply by using animations that play on request and required a thorough understanding of how flash interprets physics in a coordinate based system. Flash doesn’t natively support degrees so all of the possible deflection angles have to be recalculated. Fortunately the internet is a great resource for Actionscript learning and I managed to find many web sites offering helping formulas.
Xword, as it was called, was a side game included in my Bingo client based on customer requests for something different to play between games besides the industry standard slots. It needed to be fed by an external text file so that we could update it as often as the players requested, so the game had to be designed to cover all possible scenarios. Using a 12 by 12 grid, I designed a game that only needed to know the text for the clues pull-down, the answer to that clue, and the starting position of the word. Based on that it could backward engineer how long the word was, what other words intercepted it, and the total number of correct answers needed to solve the whole thing. Flash cookies were used to store the correct answers so that a user could complete the puzzle at their own leisure.
Now, this was fun! One animation of a horse running (hand drawn from an original animation study done in the 19th Century) and three layers of background bush. Flash could replicate the horse and re colour it, and then simply run each of the animations for a set period of time from a different starting frame. Every horse was given two random numbers that were updated at four different stages of the course, one for their speed and one for the goal (x coordinate). This made the game truly random, since each horse would travel at a random speed to a random location (left to right) of the screen – even the horse with the highest speed or highest right-hand coordinate wasn’t guaranteed to win because it may have been at the back from the previous checkpoint.