A good structure is what allows teams to work on separate computers and to understand the game as a whole.
First of all, you must realize that a game is nothing more than a bunch of objects reacting to input, collisions or logic events.
For example, what objects do you think this image has?
Now take a look at this image below, have you ever thought of games like this? just a bunch of objects? You can try and look at one of your favorite games and try and see all the different objects there are.
An image with all the object visuals is called a Sprite sheet.
For the first Structure Workshop, we are going to add a coin to the game. As in almost anything in programming, there are many ways to do things, so it will be interesting to see how you come up with a solution.
Here is a look at what the template folder looks like:
Basically the .fla file has all the visuals of the game.
The swf is the file that you open in browsers to play
the main.as is an object. in this case it is an object that the game calls automatically.
What we need to do is create a new .as file, this time it is going to be a coin.as file.
I will skip a bit over the format, and for now, if you don't want to go in depth, we can skip that part and just do a copy and paste.
This is the basic structure for all objects that will be seen on screen:
package {
//This is for the computer to know what functions and variables to use.
import flash.display.MovieClip;
//The class name can be anything you want, it could be Coin
public class YourClassName extends MovieClip{
//Variables go here, above all functions
//The name of the variable can also be anything you like.
var exampleVar:int = 0;
//The name of this first function should ALWAYS be exactly the same as the class name,
//it is called the Constructor.
public function YourClassName() {
// constructor code
}
}
}
Now for this workshop you must think of all the variables needed for the coin, like points, and if it is on screen or something, again, there is not just one correct way to code.
Helpful Keywords
Some of the things you might need to search for are:
- How to create a movieclip in flash
- How to link a class to a movieClip
- What variables do MovieClips have (remember that our object "extends" from movieClip, that means it has all the functions and variables a movieClip has).
This is a tough workshop, but I am sure that with some good google skills you will find the answers.
Please make sure to send me your sketches, and ideas on how you solved this workshop.
Thanks