Advertisement
Games

Create a Microphone-Controlled Flash Game: Code

by

In this mini-series, we're creating a spaceship game where the main control is via the microphone: shout louder to make the ship fly higher. So far, we've created all the required graphical elements for the game. Now, it's time to work on our code. We've got a lot to do, so let's get started!


Final Result Preview

For the purposes of keeping the tutorial simple, we have done no error checking for the existence of a microphone. This means that, if you do not have a microphone plugged in, turned on, and set up for use with Flash, the game won't work: you'll get an Error #1009. Check the comments in Player.as in the source files for information on how to deal with this.


A Small Note:

For some reason Flash Builder isn't working perfectly. In particular, it's ignoring code hinting - but, nevertheless, one should be able to follow the tutorial.


Project Setup

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Creating the Player

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Creating Space Objects

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Player Animation and Collision Response

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Setting Up Scores and Lives

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Creating Our Background

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Cleaning Up Our Game

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Creating the Game Over Screen

Don't like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!


Conclusion

Thank you for watching. It's been a huge tutorial, and afterwards I would have liked to do some things differently:

  • First off the classes have just been added one by one, but it would have made more sense for the classes to be organised in packages.
  • Even though our project works fine, we do get some run time errors, which isn't very neat.
  • Also, it's pretty easy to get very far by saying nothing, and just sticking to the bottom of the screen.

Nevertheless, I hope you enjoyed this tutorial, and most importantly learned something from it.

Related Posts
  • Code
    iOS SDK
    Exploring the Multipeer Connectivity framework: Game Logic78mpi preview image
    In this tutorial, I will show you how to create a simple, multi-player game using the Multipeer Connectivity framework that was introduced in iOS 7. In the first installment of this series, we laid the foundation of the game. In this article, we'll implement the game logic.Read More…
  • Game Development
    Art
    Designing 3D Environments: Lights, Camera, Polygons? Action!Environment 3d 400
    The jump from 2D to 3D isn't just big—it's trans-dimensional! 3D can be daunting, but let's try to ease the painful transition with a solid game plan for getting your game ideas into a 3D space. We're not covering the specifics of creating 3D objects here, but we will be discussing tips for putting these into a game scene and getting the most out of them visually and in play.Read More…
  • Game Development
    Implementation
    Write Once, Publish Everywhere With HaxePunk: Making a GamePreviewretinaimage
    You've probably had this experience before: you hear about an awesome game, but then you find out that it's only coming out on the one platform that you don't own. It doesn't have to be this way. In this tutorial, you will learn how to use Haxe to make a game in one development platform that can target multiple gaming platforms, including Linux, Mac, Windows, iOS, Android, and Flash.Read More…
  • Game Development
    From Scratch
    Buzzy Bee: Create a Flappy Bird-Style Game in GameSalad, Step by StepBuzzy bee flappy bird game tutorial gamesalad 400px
    In this 45-minute screencast tutorial, I'll show you how to make an avoider game like Flappy Bird, step by step, using the free GameSalad Creator tool. You don't need to have any previous programming experience or game development knowledge, I'll provide all the artwork, and you can follow along whether you're on Windows or OS X.Read More…
  • Game Development
    Game Design
    Designing RPG Mini-Games (and Getting Them Right)Designing rpg mini games hires
    The world is on the brink of being uprooted by a megalomaniac hell-bent on destruction. You and your band of merry followers are the only group able to stop him. What better time to head on down to the stables and breed exotic birds? Or not...Read More…
  • Code
    Ruby
    Writing Robust Web Applications - The Lost Art of Exception HandlingRails education retina preview2
    As developers, we want the applications we build to be resilient when it comes to failure, but how do you achieve this goal? If you believe the hype, micro-services and a clever communication protocol are the answer to all your problems, or maybe automatic DNS failover. While that kind of stuff has its place and makes for an interesting conference presentation, the somewhat less glamorous truth is that making a robust application begins with your code. But, even well designed and well tested applications are often lacking a vital component of resilient code - exception handling.Read More…