The Final Stretch…

For my final project, I am designing an Air raid style game that is re-skinned as a football game for an iPad. I plan to call this Red Zone Offense. The game will have three pages– a start page, instructions page, and a game page– and when the game ends the items in the game page will disappear and the player will prompted to play again or return to the start page. The goal of this game is to score as many touchdowns as you can within the time limit. You are allowed four incomplete passes, but if the pass is intercepted (the ball touches the red defender) the game is over. The score and “down” will be displayed on screen, as well as a timer so that the player can keep track as he goes. The player will use the left and right arrow keys to move the quarterback and spacebar to pass the ball. The player will be limited to one to two minutes–haven’t decided yet– for each round so the game does not go on forever, and when the timer runs out, the end screen will pop up and give the player his/her stats. If you lose, you will see a similar screen with slightly different text, and both will give the player the option to play again or return to the start page. Here are some ideas I had for the layout, and I would love some feedback on it. I am not too crazy about the position of the game page stats, but do not know where they would look good on this layout:

Basic Layout for "Red Zone Offense"

Basic Layout for “Red Zone Offense”

Drowned in the River…

This is the code for my snake. It works about half the time.

Every one of these Flash assignments has come with a couple setbacks, but this is the first time I have had to just call it quits on a project. I was reluctant to give up and spent well over the requested five hours of time outside of class. If you try the game out once, you may get lucky and not find the glitches, but more than likely the snake will get stuck on the edge of the screen, the game will randomly change the true/false conditions to end the game, and the goose will disappear if you win the game and hit the reset button. The game was working smoothly up until I tried to add the river creature element, but everything seemed to go downhill from there. It looks like my code should work, and Mr. Gleason could not find anything wrong either. I’m so lost now though that I think I would have to just restart the whole project, but I’ve already spent so much time on it I think I’ll just eat away my sorrows with some Thanksgiving turkey instead. Happy Thanksgiving everybody!

I meant to make the win/lose functions more elaborate, but even this code did not work 100% of the time.

Let the Raid Begin!

Click on the in-text link to shoot down the enemy planes!

There is finally a fully functioning game of Air Raid! I followed from the book, and voila, there was a game. While I was very excited when the final project came together, this assignment really stressed me out since I was unable to test the game at all before the final product was complete. This is a big drawback to Rosenzweig’s chapter, because while we are shown how to make the game, it is very hard to internalize all the information without seeing what each chunk of code is actually controlling. By tweaking a few of the parameters afterward, such as the altitude of the planes, the range of heights, and speed of the bullet and AA-Gun, I felt better about most of the concepts. Even the timer I was able to understand better after taking another look at the code. The one part that I was still a little confused about is the chunk of code below. The author really just seemed to cruise over this part, and I don’t have much of a clue as to how the whole arrays are being controlled.

This code works. How it works, I have no idea.

The Worst Game of Air Raid You’ve Ever Played

This is my functionality tweak to the practice file. 50 balls disperse at random speeds from the center.

This isn’t actually a game quite yet. All you do is control the movements of an AAGun as you watch one plane go across the screen– see for yourself. To get a little practice with basic functionality, we started with a modification of a practice file, shown here. The code listed to the right demonstrates that the the balls start at the center of the stage and disperse in random directions at random speeds. This was a simple task, and using a basic shape like a circle on a blank stage really helped to explain what the functions in the Air Raid file were doing.

The Air Raid file was a little trickier since we were dealing with two different objects. This part of the assignment really took a lot of time because it was easy to get lost when Rosenzweig jumps back and forth between the object class and main class throughout his explanations. It is pretty easy to put the code in the right place after rereading the passage, but there were some variables (such as the Boolean) that you had to add on your own if you did not skip ahead to the final main class code. Another issue that I ran into, although very minor, was that I realized the author was using a different screen size for his game. The gun started in an odd place and the plane was disappearing in the middle. I simply changed the “x” parameters on the Airplane class to fit the 1280×720 screen that we had to work with.

By the time I got to step 3 of the homework– adding up and down arrow functionality– I was comfortable with adding new keyboard events. Rosenzweig’s notes are usually very helpful, as he explained what the keyCode references identified. 38 and 40 corresponded to the up and down arrows, so I was able to add those functions next to the left and right arrow functions. As seen in the code below, each arrow key has a function. In the Airplane class, this triggers the code [this.height ++;] and [this.width ++;] for the up arrow, and  [this.height –;] and [this.width –;] for down.

Each arrow key has a function. The up and down arrows increase and decrease the size of the gun.

Election Day Stars

This is an insane amount of stars.

In this election themed Flash project you can start and stop the frame count, add random sized stars in random places, and make the stars go insane. And, for my sanity, I also made this function stoppable. This assignment was pretty straightforward since the “frame event” listener was a similar concept to other event listeners, and the only place I got hung up on was getting all the variables right for adding stars. I was unsure about what needed to be connected between the main ActionScript file and the one for the Movie Clip. Once I heard how to do it, however, it all made a lot of sense. I could probably just use a little more practice with giving Movie Clips their own page in order to really make the concepts clear. I think I might get lost if I tried to do this again on my own for something other than random stars.

Letter Scramble

This program generates a random passage and will tell you the number of times the letter you pressed appears in that passage.

I was able to finish the Letter Scramble assignment– my final work shown here— using the full class time, and did not have a whole lot of trouble with it. The concepts are starting to make a lot more sense to me after the Concept Chunks assignment. Generating passages and adding functions to the buttons is starting to feel pretty natural since we have done it for many of the assignment we have done so far. I also thought it was awesome that we could make one function that worked for ever button. The part where I was hung up the most, however, was making the program count the number of times a letter appeared in a passage. I was able to look up code from Chapter 9 of GPU that showed how to use a loop and “if” statement to search through the passage, but could not figure out how to bring it all together for the actual program. I was probably stuck at this part for half the time I spent on the assignment. I finally consulted Mr. Gleason and figured out that I was very close to solving it, but needed one or two tweaks and a counter variable to complete the loop function. I am feeling much more comfortable with these types of functions now but would definitely benefit from one more practice exercise in class.

This code includes a loop with an “if” statement to locate the letters.

Concept Chunks

These appear to be pretty simple functions, but it is not always easy to translate the functions from the textbook to your own project.

I think I thought too much. This assignment took me a good 3 hours to fully complete and I had to break it up into two parts, but by the time I finished I was thinking how simple it really was. My final project can be viewed here, and it should satisfy all your interests– if your interests include capitalizing letters and using a ton of commas. The reason why this took me so long was just that I was struggling to properly reference the Strings in the correct way to make a working function. Once I figured out the first button, the next two came easy because they were basically repeating the same format. With the “cat friendly” button and “find the letter” buttons, the Game Programming University (GPU) book also provided the appropriate format. The array button was a little more complex because it involved creating a new variable and converting between Strings and Arrays. since I had trouble keeping Strings in order, you can imagine that converting between the two took me a little while to grasp. As I noted before I over-thought this assignment quite a bit. Even though the GPU textbook has all the code, I am still struggling to figure out what to do on my own. I usually get really frustrated trying to figure these issues out on my own, and only understand what I am doing after someone tells me what to do.

This isn’t even the real Hangman…

My work space- the “meat” of the code and the water themed word generator.

If this is only the “Pre-” Hangman assignment, I don’t want to know what the real one will be like. I was just starting to get the hang of arrays, and now these loops are a curveball that’s a little tough to handle. With the guidance of others I am able to understand what is happening pretty well, but on my own I still struggle to get all the pieces together for the program to work.  I also struggled just getting the counter to work properly. I tried looking up scorekeeping in ActionScript 3.0 Game Programming University: Second Edition, but the same mechanics didn’t seem to apply. No matter what I did I kept getting the error message shown below, and it was not until I was told to add the .toString to my counting variable that it worked. Other than make my program function, I have no idea what this does. I was still proud that the finished project works and am sure I just need a little more practice to drive home some of these concepts. This assignment took me about 3 hours to complete.

I received this error message, and slight variations, A LOT when trying to figure out the click counter.

A (insert:adjective) Flash Mad Lib Generator

If you don’t like these tips, just hit the reset button for some new ones.

While it took me about 2.5 hours to complete, this assignment was pretty straightforward with the techniques we have worked on during class periods. To first see what I’m talking about in this post, you may want to try out this Mad Lib Generator for yourself. Creating a Mad Lib generator from scratch elaborated on the Random Prose assignment and used the Magic 8 Ball type interactive format, with input text boxes and a button to reset the game. What worked great for me in this assignment is checking that the code works after each added segment. This goes against my natural instincts in wanting to get the assignment over with and trying to keep track of multiple parts at once, but almost all of my troubles have come from trying to do too more than one thing at a time. Doing it this way allowed me to fix problems as they came up and I could easily locate the problems. The only thing I was still wondering at the end of this assignment was if there was an quicker way to reset the text boxes when the reset button is pressed. As you can see in the screenshot below, the last few lines are resetting each text box individually (e.g. adj1 = “”;).

This is the last few segments of code to reset the game.

I did also take some design into consideration on this assignment. I found a very simple Mad Lib story to borrow from on this WordLibs.com page. It gives tips for a job interview, so I kept the structure and font pretty professional looking. I had too break away from the child-like animation style of the Rex tutorials and keep everything neat and square.

Flash Fever: Magic 8 Ball Assignment

This may be more impressive without the distorted text.

This title is not meant to imply my excitement towards Flash and programming the Magic 8 Ball. Writing ActionScript for Flash is actually one of the worst things to try to do when you are suffering from a fever. Nonetheless, my fear of falling behind in understanding these assignments has overruled my better judgement to stay in bed. I managed to get very little done in the two hours I spent working on this assignment, mainly because I tried to do the whole thing at once instead of the piece by piece processes of Rex in Chapter 5. I tried to translate a lot of the script from the number guessing game to the eight ball, but I quickly got very confused when it came to the if/else statements and some of the “String” statements. Thankfully, I heard the suggestion to incorporate arrays and did that to save a ton of hassle. I could not explain them very well myself right now, but looking at the code for the arrays, I could recognize what each individual part meant. Since I wasn’t so concerned with that aspect, I was also able to grasp the concept of strings and how they store text.

Not the most original array of answers, but it does what is promised.

One issue that I ran into which took the most time was a pretty basic (and blatant) error that I could not figure out for the longest time. I had forgotten to put (event:MouseEvent) in the onButtonAskClick function. My output text was not showing up, and my error messages were not showing that this was the issue. I also had the issue of distorted text as you can see with the screenshot, but I am in no condition to solve it. I’m looking forward to someone responding to the email string!