HT Games
Home  >> Computer Games

How to Design a Game in ActionScript

Design a game in ActionScript by writing a detailed description of the game, studying existing game code samples and thinking in terms of objects as you design. ActionScript is an object-oriented language, which means you design and program by thinking in terms of what the properties, behaviors and other features are of a weapon, tool or other item in your game. Start with simple games, such as text-based quizzes or hangman-style games. A logical next step is to program board games like chess or checkers.

Instructions

    • 1

      Write a detailed description of what you want the game to do and how you want gameplay to progress. Include the game's goal, protagonists' and opponents' characteristics, and the game's setting.

    • 2

      Write a detailed description of the game's user interface. Specifically, answer questions like how will the player control her character, where will the information she needs to play the game appear on the screen and where will her character's life points appear. As you write, study the ActionScript Graphics class which lets you create vector graphics like rectangles, Bezier curves and other shapes. See Adobe's Basics of the Drawing API Web page for more information about ActionScript graphics classes (see Resources).

    • 3

      Write on a separate page a specification for all objects in the game, including props, vehicles and tools. Write answers to these and related questions: What do the tools and weapons look like, how do they work and where do the game's players find them, as well as what game events make use of each object. Read Adobe's Working With Objects Web page for an overview of creating objects in ActionScript (see Resources).

    • 4

      Download and read ActionScript code samples from pages like Adobe's ActionScript samples page (see Resources). Retype listings of ActionScript programs to better understand them. Delete statements from programs and observe the effect when you run the programs.

    • 5

      Open a text editor or word processor, then type the statements for the class files that contain your program. Your game's main class must extend either the "MovieClip" or "Sprite" classes. Use the following code fragment as a guide:

      public class myGame extends MovieClip {
      }

      Reread the code samples you studied for guidance in writing your own statements. Write your program in phases, starting with just the statements that create the user interface, then write code that implements the game's objects. Finally, type statements implementing the logic for the gameplay. Save your files with the extension ".as" so that Flash recognizes them.

    • 6

      Open Flash, then click the "ActionScript 3.0" link to create a new program that uses ActionScript. Click the "File" menu's "Save" command, then navigate to the folder holding your ".as" files. Type a name in the "Filename" text box, then click "Save" to save the Flash file. Click in the "Class" text box of the Properties panel, then type the name of your game's main class to link the Flash file with your game. Press "Ctrl" and "Enter" simultaneously to run your game.


https://www.htfbw.com © HT Games