You can start game programming in a flash
Here's how to create five different cool games - no experience necessary!
Ever think you could come up with a better computer game? Then this book is for you! No boring programming theory here, just the stuff you need to know to actually make something happen, and all in plain English. Build a brain-teasing math game, go classic with Pong, create monsters and mayhem, and much more.
Discover how to
• Build and control basic movie clips
• Make text appear and change
• Generate random numbers
• Add sound effects
• Create cars and space vehicles that move realistically
• Blow up stuff onscreen
About the Author
Andy Harris earned a degree in Special Education from Indiana University/Purdue University–Indianapolis (IUPUI). He taught young adults with severe disabilities for several years. He also taught himself enough computer programming to support his teaching habit with freelance programming.
Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun.
Eventually, Andy decided to teach computer science full time, and he still teaches at IUPUI. He lectures in the applied computing program and runs the streaming media lab. He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.
Andy welcomes comments and suggestions about his books. He can be reached at email@example.com.
Read an Excerpt
Beginning Flash Game Programming For Dummies
By Andy Harris
John Wiley & SonsISBN: 0-7645-8962-8
Chapter OneWhy You Want to Write Games in Flash
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.
Table of Contents
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.
Most Helpful Customer Reviews
The book is written in/for "Flash". A great read for an aspiring game designer!
The sample blocks out pics. Buy the book, and the pics will show up. This book is AWESOME!!!!!!!!
What language does it tell you about
I hav the sample but i cant see the pics! SOMEON HELP ME!!!