Adventures in Flash Games

I’ve been learning how to create simple web games with HTML5 and JavaScript. I’ve also been refreshing my memory on how to use Adobe Flash to create games. I successfully programmed a simple Craps game with HTML5/JavaScript (Craps being the casino game where you roll two dice). I now want to see if I can recreate that game in Flash.

My first step is breaking down the game into pieces. I need to have pictures of each die face (I have actually already created this in Flash). I need to have a way to reference each die face separately. I need to have a way to generate a random number, and then assign that random number to its corresponding die face. Once the die face is chosen, I need to display it to the player. I need to create a button for the player to click in order to roll the die, and I need to program the button to connect it to the code generating the random number. I need to have two dice in order to create the final craps game, so whatever code I create to roll one die, I will just repeat. The button will have to somehow initiate the code for both die rolls.

So here are my first tasks:

  1. Create graphical elements (die faces, buttons).
  2. Assign variables for two random numbers.
  3. Create function to generate random numbers and assign to their respective die faces.
  4. Create an event listener for the button that rolls the dice.

The tasks above will set up the basic die-rolling part of the game. But I need to do a bit more to create the actual Craps game. I need to check if it’s the player’s first turn. I need to check whether the first number rolled equals 7 or 11, and if it does I need to let the player know they won. If the first number rolled is not 7 or 11, I need to check whether the first number rolled equals 2, 3, or 12, and if it equals any of those I need to let the player know they lost. If the first number rolled is not 2, 3, 7, 11, or 12, I need to store the first number in a variable. On each subsequent turn, I need to check the number rolled on that turn against 7 and 11 (lose) and against the first number rolled (win), and I need to let the player know the result of their roll.

So here are the additional tasks for the full Craps game:

  1. Create output fields to display messages to the player.
  2. Create a Boolean variable for First Turn.
  3. Create an if statement to check the first number; it should give the player either a win message, a lose message, or tell them their “point” (the first number they rolled). This should also set the First Turn variable to False.
  4. Create an if statement to check subsequent rolls against 7, 11, and their point, and give them a win message, a lose message, or keep rolling message.
  5. Create a function to end the game when a win or lose condition has been reached.
  6. Create a button to restart the game, along with event handler for the button.

Now, all I have to do is actually build the game in Flash! I’ll be building it in stages, and I’ll post each stage here as it is finished.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s