Switch to the store?

Adobe Flash 11 Stage3D (Molehill) Game Programming Beginners Guide

More Information
Learn
  • Animate complex 3d scenes in Flash.
  • Initialize the Molehill graphics engine enabling hardware 3d acceleration.
  • Overlay 2D Flash on top of your 3d scenes for beautiful user interfaces.
  • Render splendid textures for eye-catching visuals.
  • Upload 3D model geometry for in-game items, enemies, terrain and levels.
  • Program incredible looking shaders in AGAL that run incredibly fast.
  • Make your own special effects like explosions, sparks, and magic.
  • Write event handlers and timers that control the action.
  • Track player movements, health and the game state.
  • Trigger game events, detect collisions, and control the game.
  • Compile your project to a .SWF that you can put on a web page.
About

Adobe’s Stage3D (Molehill) is a set of 3D APIs that has brought 3D to the Flash platform. Being a completely new technology, there were almost no resources to get you acquainted with this revolutionary platform, until now.

This book will show you how to make your very own next-gen 3D games in Flash. If you have ever dreamed of writing your own console-style 3d game in Flash, get ready to be blown away by the hardware accelerated power of Stage3D. This book will lead you step-by-step through the process of programming a 3D game in Actionscript 3 using this exciting new technology. Filled with examples, pictures and source code, this is a practical and fun-to-read guide that will benefit both 3D programming beginners and expert game developers alike.

Starting with simple tasks like setting up Flash to render a simple 3d shape, each chapter presents a deeper and more complete videogame as an example project. Right from a simple tech demo, your game will grow to become a finished product - your very own playable 3d game filled with animation, special effects, sounds, and tons of action. The goal of this book is to teach you how to program a complete game in Molehill that has a beginning, middle, and game over.

As you progress further into your epic quest, you will learn all sorts of useful tricks such as ways to create eye-catching special effects using textures, special blend modes for transparent particle systems, fantastic vertex and fragment programs that are used to craft beautiful shaders and much more. You will learn how to upload the geometry of your 3D models to video RAM for ultra-fast rendering. You will dive into the magical art of AGAL shader programming. You will learn optimization tricks to achieve blazingly fast frame rate even at full screen resolutions. With each chapter, you will “level up” your game programming skills, earning the title of Molehill Master – you will be able to honestly call yourself a 3D game programmer.

This book is written for beginners by a veteran game developer. It will become your trusty companion filled with the knowledge you need to make your very own 3D games in Flash.

The sample chapter for this book (chapter 8; view the Table of Contents here) will be made available very soon. Thank you for your patience.

Features
  • The first book on Adobe's Flash 11 Stage3D, previously codenamed Molehill
  • Build hardware-accelerated 3D games with a blazingly fast frame rate.
  • Full of screenshots and ActionScript 3 source code, each chapter builds upon a real-world example game project step-by-step.
  • Light-hearted and informal, this book is your trusty sidekick on an epic quest to create your very own 3D Flash game.
  • This is the game you will create after you are done with the book: PLAY THE DEMO GAME
Page Count 412
Course Length 12 hours 21 minutes
ISBN9781849691680
Date Of Publication 25 Nov 2011
Step 1: Downloading Flash 11 (Molehill) from Adobe
Time for action – getting the plugin
Time for action - getting the Flash 11 profile for CS5
Time for action – upgrading Flex
Time for action – upgrading the Flex playerglobal.swc
Time for action – using SWF Version 13 when compiling in Flex
Time for action – updating your template HTML file
Step 2: Start coding
Time for action – creating an empty project
Time for action – importing Stage3D-specific classes
Time for action – initializing Molehill
Time for action – defining some variables
Time for action – embedding a texture
Time for action – defining the geometry of your 3D mesh
Time for action – starting your engines
Time for action – adding to the onContext3DCreate function
Time for action – uploading our data
Time for action – setting up the camera
Time for action – let's animate
Time for action – setting the render state and drawing the mesh
The entire source code
Summary
Level 3 achieved!
AGAL: Adobe Graphics Assembly Language
A basic AGAL shader example
Time for action – writing your first vertex program
Time for action – writing your first fragment program
Compiling the AGAL source code
Time for action – compiling AGAL
Time to Render!
Time for action – rendering
Creating a shader demo
Adding an FPS counter
Time for action – creating the FPS GUI
Time for action – adding the GUI to our inits
Time for action – adding multiple shaders to the demo
Time for action – initializing the shaders
Time for action – animating the shaders
Time for action – uploading data to Stage3D
Summary
Level 4 achieved!
Creating vertex buffers
Time for action – coding the Stage3dObjParser class
Time for action – creating the class constructor function
Time for action – coding the parsing functions
Time for action – processing the data
Time for action – coding some handy utility functions
The render loop
Time for action – starting the render loop
Time for action – adding the score to the GUI
Time for action – upgrading your init routines
Time for action – parsing our mesh data
Time for action – animating the scene
Folder structure
Summary
Level 5 achieved!
Time for a plan: creating a "real" game
Using textures in Stage3D
Time for action – updating UV coordinates each frame
Render states
Time for action – rendering a mesh's backfaces
Time for action – making a mesh not affect the zbuffer
Time for action – rendering an opaque mesh
Time for action – rendering a mesh with transparent regions
Time for action – rendering a mesh so it lightens the scene
Increasing your performance
Adding texture effects to our demo
Time for action – embedding the new art
Time for action – adding the variables we need
Time for action – upgrading the GUI
Time for action – listening for key presses
Time for action – upgrading our render loop
Time for action – upgrading the renderTerrain function
Time for action – upgrading our Stage3D inits
Time for action – simplifying the initShaders function
Time for action – parsing the new meshes
Time for action – rendering different meshes as appropriate
Time for action – switching textures
Time for action – switching blend modes
Your demo has been upgraded!
Summary
Level 6 achieved!
Our current quest
Making our game more interactive
Time for action – adding a GUI overlay
Time for action – creating the game timer class
Time for action – adding the GameTimer class constructor
Time for action – implementing the tick function
Time for action – creating the GameInput class
Time for action – coding the GameInput class constructor
Time for action – detecting mouse movement
Time for action – detecting the keyboard input
Time for action – detecting key release events
Time for action – detecting the input focus
Time for action – creating the Stage3dEntity class
Time for action – creating the Stage3dEntity class constructor
Hiding complex code by using get and set functions
Time for action – getting and setting the transform
Time for action – getting and setting the entity position
Time for action – getting and setting the entity rotation
Time for action – getting and setting the entity's scale
Time for action – updating the transform or values on demand
Time for action – creating the movement utility functions
Time for action – implementing vector utility functions
Time for action – adding some handy entity utility functions
Time for action – cloning an entity
Time for action – rendering an entity
Design art for our new improved game world
Upgrading our game
Time for action – importing our new classes
Time for action – adding new variables to our game
Time for action – embedding the new art
Time for action – upgrading the game inits
Time for action – upgrading the GUI
Time for action – simplifying the shaders
Time for action – using the new textures
Time for action – spawning some game entities
Time for action – upgrading the render function
Time for action – creating a simulation step function
Time for action – creating a heartbeat function
Time for action – upgrading the enterFrame function
Let's see all this in action!
Summary
Level 7 achieved!
Our current quest
A basic particle entity class
Time for action – extending the entity class for particles
Time for action – adding particle properties
Time for action – coding the particle class constructor
Time for action – cloning particles
Time for action – generating numbers used for animation
Time for action – simulating the particles
Time for action – respawning particles
Time for action – rendering particles
Keyframed vertex animation shader
Time for action – creating a keyframed particle vertex program
Time for action – creating a static particle vertex program
Time for action – creating a particle fragment program
Time for action – compiling the particle shader
A particle system manager class
Time for action – coding a particle system manager class
Time for action – defining a type of particle
Time for action – simulating all particles at once
Time for action – rendering all particles at once
Time for action – spawning particles on demand
Time for action – creating new particles if needed
Keyframed particle meshes
Time for action – sculpting a single particle
Time for action – sculpting a group of particles
Time for action – sculpting the second keyframe
Incorporating the particle system class in our game
Time for action – adding particles to your game
Time for action – preparing a type of particle for use
Time for action – upgrading the renderScene function
Time for action – adding particles to the gameStep function
Time for action – keeping track of particle statistics
Let's see the new particle system in action!
Summary
Level 8 achieved!
Extending the entity class for "actors"
Time for action – creating a game actor class
Time for action – extending the actor's properties
Time for action – coding the GameActor class constructor
Time for action – creating a step animation function
Time for action – animating actors
Time for action – using timers
Time for action – shooting at enemies
Time for action – cloning an actor
Time for action – handling an actor's death
Time for action – respawning an actor
Collision detection
Time for action – detecting collisions
Time for action – detecting sphere-to-sphere collisions
Time for action – detecting bounding-box collisions
An "actor reuse pool" system
Time for action – creating an actor pool
Time for action – defining a clone parent
Time for action – animating the entire actor pool
Time for action – rendering an actor pool
Time for action – spawning an actor
Time for action – checking for collisions between actors
Restricting display to nearby actors for better framerate
Time for action – hiding actors that are far away
Time for action – destroying every actor in the pool
Easy world creation using a map image
Time for action – implementing a level parser class
Time for action – spawning actors based on a map image
Time for action – parsing the map image pixels
Upgrading the input routines
Time for action – adding more properties to the input class
Time for action – handling click events
Time for action – upgrading the key events
Summary
Level 9 achieved!
Our final quest
Getting to the finish line
Time for action – drawing a title screen
Time for action – importing required classes
Adding new variables to our game
Time for action – tracking the game state
Time for action – adding variables for timer-based events
Time for action – adding movement related variables
Time for action – keeping track of all entities
Time for action – upgrading the HUD
Time for action – defining variables used by Stage3D
Adding art to our game
Time for action – embedding our new art assets (AS3 version)
Time for action – embedding our new art assets (CS5 version)
Time for action – embedding all the meshes
Time for action – keeping track of art assets
Upgrading the final game source code
Time for action – upgrading the inits
Time for action – initializing Stage3D
Time for action – upgrading the initGUI function
Time for action – upgrading the texture inits
Time for action – upgrading the shaders
Time for action – defining new actor types and behaviors
Time for action – initializing the terrain meshes
Time for action – initializing the enemies
Time for action – initializing the bullets
Time for action – initializing the asteroids
Time for action – initializing the space stations
Time for action – initializing the particle models
Time for action – creating the game level
Time for action – upgrading the render loop
Defining gameplay-specific events
Time for action – tracking game events
Time for action – handling game over
Time for action – updating the score display
Time for action – updating the FPS display
Time for action – handling collision events
Time for action – handling the player input
Time for action – upgrading the gameStep function
Time for action – upgrading the heartbeat function
Time for action – upgrading the enterFrame function
Publish... distribute... profit!
Summary
Level 10 achieved. Universe saved!
Where to go from here?
A note from the author

Authors

Christer Kaitila

The author of this book, Christer Kaitila, B.Sc. is a veteran video game developer with 17 years of professional experience. A hardcore gamer, dad, dungeon master, artist and musician, he never takes himself too seriously and loves what he does for a living: making games! A child of the arcade scene, he programmed his first videogame in the eighties, long before the internet or hard drives existed. The first programming language he ever learned was 6809 assembly language, followed by BASIC, Turbo Pascal, VB, C++, Lingo, PHP, Javascript, and finally ActionScript. He grew up as an elite BBS sysop in the MS-DOS era and was an active member of the demoscene in his teens. He put himself through university by providing freelance software programming services for clients. Since then, he has been an active member of the indie game development community and is known by his fellow indies as Breakdance McFunkypants.

Christer frequently joins game jams to keep his skills sharp. Over the years, he has programmed puzzle games, multiplayer RPGs, action titles, shooters, racing games, chat-rooms, persistent online worlds, browser games, and many business applications for clients ranging from 3D displays for industrial devices to simulations made for engineers.

He is the author of the book “Adobe Flash 11 Stage3D (Molehill) Game Programming Beginner's Guide” and is the curator of a popular news website called http://www.videogamecoder.com which boasts over 30,000 articles and zero ads. He is one of the administrators of Ludum Dare, and has hosted a mini weekend jam with the theme of “all talk: dialogue and conversation”. He also created the keynote lecture for Ludum Dare 21, an 8 minute video filled with words of encouragement and advice. His client work portfolio is available at http://www.orangeview.net and his personal game development blog is http://www.mcfunkypants.com where you can read more about the indie game community and his recent projects. He lives in Victoria, Canada with his beloved wife and the cutest baby son you've ever seen.