Appendix A. Where to Go Now
Once you code a game, your work isn't over. Game developing starts before you write the game itself and ends after you have added the last line of code.
I want you to have this list of links that you can't miss if you want to be a respected game developer:
http://www.flashmindmeld.com/: 60 tips from 60 experts about what makes or breaks a successful Flash game.
http://www.mochimedia.com/: the most complete all in one service for Flash game developers, featuring among other things monetizing with advertising and social features.
http://www.newgrounds.com/: one of the most important Flash game portals. Make your game get a good score in this portal, and you can consider it a success.
http://www.kongregate.com/: another important Flash game portal, with a built-in social network. Add badges and rewards to your game and you'll get a lot of plays in this site, which also shares revenues with developers.
http://armorgames.com/: one of the first and most important Flash game portals which also sponsors the best games around the web. Catch their attention and you can be sure your game rocks.
http://www.box2dflash.org/: free open source rigid body physics engine for Flash.
http://www.flare3d.com/: commercial 3D engine for Flash, the most impressive among its competitors.
http://www.flashgamelicense.com/: community which connects developers with sponsors, to let you make money with your Flash game.
http://flashgamedistribution.com/: get your game distributed in every known portal in just a few clicks.
http://www.kindisoft.com/: software house that developed secureSWF, the best tool to protect your SWF files against decompilers.
http://playtomic.com/: the most complete and powerful analytics system for your Flash game. Endless possibilities of tracking what's happening in your game and who's playing it.
And finally, my blog, http://www.emanueleferonato.com/: here you will find daily posts about indie game developing and related topics.
Chapter 1. Concentration
Concentration is a memory game you can play even without a computer, just with a deck of cards. Shuffle the cards, lay them face down on a table and at each turn choose and flip any two cards with faces up.
If they match (both cards are Aces, Twos, Threes, and so on), remove them from the table. If not, lay them face down again and pick another couple of cards. The game is completed when, due to successful matches, all cards have been removed from the table.
Concentration can be played as a solitaire or by any number of players. In this case the winner is the one who removed the most cards.
In this chapter you will create a complete Concentration game from scratch, with a step-by-step approach, learning these basics:
- Creating a Flash document
- Working with packages, classes, and functions
- Printing text
- Commenting your code
- Creating and managing variables and constants
- Creating and managing arrays
- Generating and rounding random numbers to simulate the shuffle of a deck of cards
- Repeating the execution of code a given amount of times with the
for
loop - Creating Movie Clips to be added with AS3 and interacting with them on the fly
- Handling mouse clicks
- Dealing with timers
It's a lot of stuff, but don't worry as the whole process is easier than you can imagine.
Defining game design
Once you start thinking about programming a game, you are already making it. You are in pre-production stage.
During this process, gameplay as well as storyline and environment begin to take shape. Before starting to code or even turning on the computer, it's very important to define the game design. This is the step in which you will decide how the game will work, the rules and the goals of the game, as well as the amount of options and features to include.
I know you just want to start coding, but underestimating the importance of game design is a very common error. Usually we think we have everything in mind, and we want to start coding at once. Moreover, a game like Concentration looks really simple, with just one basic rule (selected cards match/don't match) and, last but not least, we just have to copy an existing game, so why not start typing right now?
Even a basic project like a Concentration remake may give you some troubles if you skip an accurate game design. Here are a few questions you probably would not ask yourself about the game you are about to make:
- How many players can take part in the game?
- How many cards will be placed on the table?
- I don't have a deck of cards. Do I have to buy one and scan all the cards?
- Are card images protected by copyright?
- Where can I find free card images?
- Which resolution should I use to clearly display all cards?
- Who will play my game?
- What difficulty levels can the player choose?
- Will there be any background music or sound effects?
Don't hesitate to ask yourself as many questions as you can. The more decisions you take now, the easier the game will be to make.
Making changes to basic mechanics when the game is on an advanced development stage can dramatically increase developing time. A good game design won't ensure you that you will never have to rewrite some parts of the code, but it reduces the probability of you having to do it.
Anyway, be realistic and know your limits. Questions like "Do I have to use a physics engine to add realism to card flipping, maybe introducing wind or different air resistance" are welcome since you don't want to start doing this and then realize it's not needed, but avoid thinking about features you know you aren't able to add or you will quickly turn a game you are about to publish into a game you'll never make.
At the end of this process, you must have at least a set of basic rules to define how a playable prototype should work.
So here are the decisions I made for the game we will create:
- To be played in solitaire mode.
- The game is intended to be played on a web browser by young children.
- Twenty cards placed on the table. Being for young children, a complete deck of cards could be too difficult.
- Rather than the classic deck of cards, we'll use tiles with primitive colored shapes on them, such as a red circle, a green square and so on. This will let us draw the graphics on our own, without needing a card deck.
- Player will select the cards with a mouse click.
Defining the audience of a game is very important when you are about to fine-tune the game. Being a game for young children, we'll add some educational content in it. Parents love when their children play and learn at the same time.
Setting stage size, frame rate, and background color
You are about to create a Flash game, and like all Flash movies, it will have its stage size (width and height in pixels), frame rate (the number of frames per second) and a background color.
Note
The area where you will add the content to be viewed is called the stage . Any content outside the stage will not be visible when playing the game.
The higher the size and the frame rate, the more CPU-intensive will be the game. But it's not just a CPU-based issue: you also have to set the size according to the device your game is designed to be played in. If you plan to design a Concentration game for smartphones, then a 1280x1024 size is probably a bad choice, because they don't support that kind of resolution.
Although we have decided to create a game to be played in browsers we should still put some effort into thinking about what size it should be.