Beginning Flash Game Programming For Dummies [NOOK Book]

Overview

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 ...
See more details below
Beginning Flash Game Programming For Dummies

Available on NOOK devices and apps  
  • NOOK Devices
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK Study
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
$13.99
BN.com price
(Save 44%)$24.99 List Price
Note: This NOOK Book can be purchased in bulk. Please email us for more information.

Overview

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
Read More Show Less

Product Details

  • ISBN-13: 9781118085455
  • Publisher: Wiley
  • Publication date: 5/9/2011
  • Series: For Dummies Series
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 408
  • Sales rank: 620,110
  • File size: 11 MB
  • Note: This product may take a few minutes to download.

Meet 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 has written several books on various computing topics and languages including Java, C#, mobile computing, JavaScript, and PHP/MySQL.
Andy welcomes comments and suggestions about his books. He can be reached at aharris@cs.iupui.edu.
Read More Show Less

Read an Excerpt

Beginning Flash Game Programming For Dummies


By Andy Harris

John Wiley & Sons

ISBN: 0-7645-8962-8


Chapter One

Why 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.

TIP

Here are some very good reasons to write games:

  •   Computer games made more income in 2003 than the movie industry.
  •   Game programming is technically challenging.
  •   Making a game is fun!

TECHNICAL STUFF

Most other game development books can be divided into two camps:

  •   Some talk about the game design process, storyboarding, coming up with game ideas, and the visual side of gaming. That's pretty good stuff to know, but it doesn't help you actually make a game.
  •   Other books assume that you're already good at C++ and advanced math. That's pretty good stuff, too, but you don't need to start there.

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:

  •   Flash offers robust multimedia support. Flash, which was designed to support animation on the Web, supports various kinds of images easily. (Think JPEG images and custom drawings.) See how to use the drawing features of Flash in Chapter 9. Flash also has great support for various kinds of audio files, such as MP3 and WAV formats. You incorporate audio into your games in Chapter 8.
  •   ActionScript is related to the influential C language. The ActionScript programming language built into Flash is closely related to JavaScript and ECMAScript, which are two extremely common programming languages. All these languages are based on the C programming language, so the coding conventions you'll master are much like those in other languages.
  •   Flash is designed for the Web. By working in Flash, you have a ready distribution network. Because Flash was designed for the Web, all your games can be easily published on the Web, and anybody with a Web browser and a Flash plug-in can enjoy your games. And you won't have to worry about what operating system your users use. (All the programs in this book have been tested in Windows XP and Fedora Core Linux, but they should work in any OS with a Flash plug-in.)

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

  •   Control what's onscreen, what size it is, where it is, and how it's rotated
  •   Detect whether two things touch each other
  •   Accept input from the user

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:

  •   A character (at least one)
  •   A conflict
  •   A goal

TIP

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.

TECHNICAL STUFF

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.

TIP

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:

  •   The main character: Don't forget the kinds of obstacles this character will encounter. You can read how to build a main character throughout the book, but the topic is covered most deeply in Chapter 9.
  •   The overall look of the game: Consider the setting. What colors will you use? What overall look and feel are you looking for? (Retro? Cartoon? Gothic? Maybe a Gothic retro cartoon?) Chapter 7 describes how to set up the visual feel of a game.
  •   The main screens: Most games have

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.

  •   The objects on each screen: You have to build everything in your game. The visual design part is important but relatively easy.
  •   The role/behavior of each object: Decide these details upfront for each object:

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:

  •   Learn: They learn the tools of the trade, practicing on small hills and isolated, safe areas before testing their skills on actual mountains.
  •   Pace: When they're ready to climb Mt. Everest, climbers don't go for the top in one day. They build a solid base camp at the foot of the mountain. Then they create another camp higher up, and another even higher.
  •   Progress: At each camp, the ultimate goal is still the summit, but the intermediate goal of the next camp is the task at hand.

A mountain climber concentrates on the next step.

REMEMBER

The same advice is really good for all programmers, beginning or advanced:

  •   Master the tools of the trade. There's no getting past the fundamentals (which this book shows).

You need to know both

The basic ideas of programming

The principles of game development

  •   Know the goal. That's why you start with a written description of your program.

TIP

  •   Use small steps. Concentrate on mastering one task at a time.

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.

  •   Enjoy the view. Game programming is supposed to be fun.

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.)

  •   Pace yourself. Your first program won't be the next version of Quake, but there's plenty of fun in writing games that are a little less ambitious. Eventually, you'll build your skills so you can write something way better than Quake.

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 is an ideal environment for beginning game creation.

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.)

  •   Most commercial games are written in 2-D, using C++ and graphics engines like DirectX or OpenGL.

Those are really great environments, but they aren't necessarily what you need while you're learning the process of game development.

WARNING!

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:

  •   C++ is like a Formula 1 car - fast and difficult to handle.
  •   Flash and ActionScript are like a go-kart (albeit a souped-up, Internet-enabled go-kart that outperforms any computing environment NASA had during the moon program).

(Continues...)



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.

Read More Show Less

Table of Contents

Introduction.

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.

Index.

Read More Show Less

Customer Reviews

Average Rating 4
( 5 )
Rating Distribution

5 Star

(3)

4 Star

(0)

3 Star

(0)

2 Star

(2)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 5 Customer Reviews
  • Anonymous

    Posted June 2, 2014

    To below

    The book is written in/for "Flash". A great read for an aspiring game designer!

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted May 9, 2013

    ???

    What language does it tell you about

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted April 22, 2013

    To Review

    The sample blocks out pics. Buy the book, and the pics will show up. This book is AWESOME!!!!!!!!

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted March 6, 2013

    Review

    I hav the sample but i cant see the pics! SOMEON HELP ME!!!

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted September 27, 2012

    No text was provided for this review.

Sort by: Showing all of 5 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)