- Shopping Bag ( 0 items )
In This Chapter
* Seeing how to use Flash to write games
* How programming differs from animation
* Exploring basic game design concepts
Computer programming can be a whole lot of fun. That's why I got into it way back when, and it's why I still do it. Truth be told, the main reason I learned how to program was to write games. I couldn't buy much software for my first computer (a TRS-80 Model 1, still in the garage ... sigh). I wanted to play games, so I had to create them myself. Admittedly, I was pretty bad at it, and I failed a lot, but I kept trying. As I grew up, my programming skills were marketable in the "serious" world, but I never lost my fascination with computer games.
Here are some very good reasons to write games:
Most other game development books can be divided into two camps:
I believe that newcomers to programming can master the essential ideas of programming at the same time they're learning to build games. I also feel that those with some programming experience will truly enjoy the uniquely creative aspects of game development. You don't have to know anything about programming or Flash to use this book. (However, if you know these things, you'll still probably see something new.)
In this chapter, I give you an overview of the basics of game designing and planning, writing, and programming in Flash (with ActionScript). Most of all, you're going to have a lot of fun.
Designing and Writing Games
If you've asked around about how to get started in game programming, people have probably told you to learn C++ and take lots of math classes. That's not bad advice, but I have an easier way. The truth is that making games isn't really about any particular computer language. After you learn how to write games, you can transfer those concepts to any environment you wish. There are surprisingly few main concepts behind game development. If you truly understand these ideas, you can translate them to any programming language you want.
In this book, I show you how to program games in Flash. I like Flash because it simplifies the visual side of programming, works on almost every computer made, and has a powerful and reasonably easy programming language. I talk about this more in the upcoming sections, "Game Programming in Flash" and "Game Programming 101."
Too, game programming is different than other kinds of software development. For one thing, games need to be fun. And games are all about communicating with the player as well as providing some sort of immersive world in which the player participates. As a game programmer, you get to be creative and think outside the box.
Making artificial worlds
Typical business programming relies heavily on certain conventions and metaphors. If you're writing a database application, it's de rigueur to make your program much like all the other programs users have seen. In game programming, though, you're often trying to "hide" the computer from the player. For example, if you're making a spaceship game, you want the controls to look and feel like spaceship controls. Imagination is a really important part of playing and writing games.
The importance of interactivity
Games need to react to the player. The player should manipulate a virtual presence, and the game should react accordingly. Some games are turn based, and some are in real time, but all require more immediate feedback than traditional types of programs.
Games are about objects
Many games involve objects bonking into each other, shooting each other (with other objects), avoiding each other, and simply milling around. While you're writing a game, you usually think about objects, their characteristics, and how they interact with the player as well as with each other.
Players compete with the programmer
When you play a really great game, you're not really playing against the computer. Rather, you're really engaging in a stylized conversation with the programmers. As a game developer, you get the chance to set up worlds. The players interact with a stored version of your thoughts and imagination.
Game Programming in Flash
Macromedia Flash is a very good environment for learning basic game programming ideas. Here are a number of reasons for starting with Flash:
Comparing ActionScript with Animation
Maybe you've used Flash to build Web animations without ever going into its programming features. Many books on Flash (as opposed to ActionScript) focus on the powerful animation features of Flash. These books often mention ActionScript but don't dwell on it heavily. Animation is primarily about creating moving images; user interaction in animations is minimal. When creating an animation, you generally create some sort of visual symbol onscreen and then use a tool called a motion tween to indicate where this object should be at a specified point in time. You can also use a tool called a shape tween to change the shape of an object over time. You can do this with many objects at the same time to make a complex animation. In order to track all these objects, Flash animators often arrange them into separate layers. Thus, a typical 30-second Flash animation might have hundreds of frames of animation in over a dozen layers.
Animation is cool because it allows you to build movies. However, to create games, you must discover how to program.
If you treat Flash as a programming environment (as I do in this book), you see things quite differently. You still use Flash to create objects, but instead of relying on the Flash environment to control what those objects do (via animation), you control the objects directly by writing programming code. The ActionScript programming language built into Flash lets you do anything that can be done with animation - and many things that cannot be done by using animation techniques alone.
In a nutshell, programming is what makes games interactive. You can
How You Make a Game
The goal of game development can be summarized in one sentence:
Games are stories that use the player as a primary character.
Like any interesting story, a game needs these plot elements:
Game play must be compelling, but game elements don't need to be complex. Simple games like Tetris and Pac-Man have had phenomenal success.
Making a playable game
A good game has a good story, and it also has some form of user interaction. In Flash, the player uses the mouse and keyboard as primary input devices. Although these devices might seem limiting (compared with a more sophisticated joystick or driving console), you can do many things with these basic forms of input.
Although Flash doesn't directly support joystick input, users can easily use modern joysticks with the games you can write in Flash. Most joysticks now come with programs that allow the user to map keystrokes to keyboard commands. In effect, by allowing keyboard input, you also allow rudimentary joystick input.
A game should also look good and sound good, but these things don't matter if the game isn't fun.
Some of the best games ever have incredibly limited graphics and sound. If you've never played NetHack (as shown in Figure 1-1), download a copy (free for just about any computer ever made) and play it. At first, you might be thrown by the complete lack of graphics and sounds. NetHack uses plain text without any graphics or sound effects, but the game is amazingly absorbing. I bet that you get caught up in the incredible game play and find yourself actually scared of the capital D coming at you.
Most of all, games should be fun. I can't really tell you how to make a game fun. You need to test a lot for a game that's fun to play.
Starting with a plan
Before you worry at all about the details of your game, come up with a theme.
Think about what you want your game to be about. Outline and define the following components:
A main play screen (or two)
An instruction screen
Some sort of introduction
A Game Over screen, or maybe two: one for when the player wins and one for when the player loses
Draw these visual elements on paper.
How the object moves
Whether it's controlled by the user or the computer
Whether it does something when it interacts with other objects
Whether it makes sounds
What happens when it leaves the screen
After you finish defining these objects, convert your sketches into reality. This sounds like a pretty easy step, but it's the one that might cause you a lot of grief. You probably know exactly what you want all the screen objects to do, but a computer is incredibly stupid.
You have to convert your clever ideas to statements so clear that even an idiot computer can understand them.
Learning to code
Mountain climbers train before they scale the big mountains:
A mountain climber concentrates on the next step.
The same advice is really good for all programmers, beginning or advanced:
You need to know both
The basic ideas of programming
The principles of game development
In this book, chapters show you specific skills and apply those skills in simple games, so you can
Learn the skills you need for complex games.
Practice these skills in isolated programs.
Celebrate your progress! When you succeed at a viable chunk of code, do a little Hampsterdance. (If you don't know what I'm talking about, visit hampsterdance.com.)
Game Programming 101
Game programming is a process. All the programs in this book use the Flash environment, but the details of Flash programming aren't the most important factor. When you want to make a game, you need to choose an environment that will work as well as decide a strategy for creating the game.
Selecting a language
If you're reading this book, you've chosen Flash as your environment. Excellent choice!
Flash makes a lot of the implementation easier, so you can concentrate on the content of your games instead of all the details of memory management, image drawing, and reading the input devices. (Fancier environments make you put a lot of work into such details instead of mastering the craft of game development.)
Those are really great environments, but they aren't necessarily what you need while you're learning the process of game development.
If you want to be a racing champion, you don't just show up in Indianapolis with a helmet. Starting your driving career in a high-performance machine is foolhardy and dangerous. You begin your career racing karts and then advance through more challenging vehicles. That's why you should start programming with Flash and ActionScript:
Excerpted from Beginning Flash Game Programming For Dummies by Andy Harris Excerpted by permission.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.
Part I: Basic Flash.
Chapter 1: Why You Want to Write Games in Flash.
Chapter 2: Cruising and Using the Flash Environment.
Part II: The Next Steps.
Chapter 3: Altered States.
Chapter 4: Getting with the Program.
Chapter 5: Making an Interactive Game.
Part III: Sprites, or Movie Clips.
Chapter 6: Introducing Sprites and Movie Clips.
Chapter 7: Won’t Be Long ’Til You Write Pong.
Part IV: Getting Control of the Situation.
Chapter 8: Keyboard Input and Audio Output.
Chapter 9: It’s Alive! Animating Your Sprites.
Chapter 10: Building the Monster Traffic Game.
Part V: Phun with Phuzzy Physics.
Chapter 11: Vectors and Gravity.
Chapter 12: Vehicle Motion.
Chapter 13: The Life and Death of Sprites.
Part VI: The Part of Tens.
Chapter 14: Ten Math Concepts for Game Programmers.
Chapter 15: Ten Game Starters.
Posted May 9, 2013
Posted April 22, 2013
Posted March 6, 2013
Posted September 27, 2012
No text was provided for this review.