torsdag 26. november 2009

Case 10 - Victory or defeat


Nortrom MacFree - Beta version by ~SveinE89 on deviantART

In this week’s case our objective was to create some kind of way to show the player that you’ve either won or lost. In addition we also were supposed to create a starting menu with instructions and a button to start the game. In the win/loose screens we should make it possible to restart the game.

In this case I first had to reorganize my script-file. I learned what I needed to do in our group meeting on Monday, where we were introduced to the concept. The first function I called in was the constructor, where all the main objects of the game are added. But now that I needed a start screen, I had to move this constructor further down in the script. I added two new functions over it; the intro and menu function (in addition to the functions for the buttons).

I spent a lot of time this week on designing the different screens, since the programming went pretty smoothly. I decided to make the loosing screen a so called “blue screen of death”, which is a familiar term in the computer world. I created a replica of the well known blue screen that appears in the earlier versions of the Windows operation system when you crash your computer. I also decided that instead of creating a button to click with on with your mouse to restart, I just bound a key to restart the game. This suited the blue screen more, since you often got the message “Press any key to attempt to continue”. For the intro and win screen, I decided to create a small movie sequence to create a sort of background story.

After letting people see my game and give me feedback, I also spent a lot of time revamping the game. I made it a bit harder by adding more enemies, and increasing their speed. I’ve also added a timer that makes you lose if the time runs out. I also worked on the design and placing of the different objects.

søndag 15. november 2009

Case 9 - Behold: Sound.

In this week we got to make sounds and music for our game. All the sound have to be triggered by AS3. It also has to be license-free, meaning that I can’t use for instance Britney Spears – Oop I did it Again in my game.

I wanted to have one special theme that was going to loop in the background, a sound when the hero picked up orbs, a sound for when the he hit enemies, some catch-phrases my hero would shout out every once and a while, and some other music bits I could use in my intro/outro. I tried looking on the internet on several free-sound web-pages, but I wasn’t completely happy with the material I found. Therefore I contacted a friend of mine, who makes digital music and sounds. I explained how my game worked and described what kind of sounds I wanted. And after a while I got some material that I’m very happy with.

The way of adding music was quite simple. On our group meeting on Monday I learned all I needed to know. This time Ole Andreas created a chat-like thing in our Fronter-room that he used to show us what code we needed to use sound in AS3. I think that method worked out really good, because we could all talk, read/write the code, and use the code by typing it in our own scripts at the same time.

The way I added sound to my game was quite easy. First I imported the necessary properties, made variables for the sound I would use from my library, and then I made variables for 3 different sound channels. By creating sound channels you can play several sounds “on top of each other”. For instance background music and a sound when you pick up orbs. I created one channel for background sound/music, one for sound-effects, and one for vocals.

I managed to add a background music easily and a sound when you pick up an orb. One problem I’ve encountered here is that I chosen to just scale the orbs down to 0 when they’re picked up, instead of removing them, and that leads to that every time I walk over the place where an orb used to be, the sound is also played. I’m currently working on this at the moment and I won’t publish a new version of the game before I feel comfortable with it.

Case 8 - Picking It Up

The task in this case was to create something for the hero to pick up and gather. In some games a timer is also implemented, so if you wanted the game to be timed, this was the case to solve it.

I decided to create my energy orbs in an array. An array is a kind of container in AS3 which contains several instances of an object. When I had placed to orbs in this array, I used the code and placed them individually around my level. In this week I also placed out the platforms, creating a first draft of my world. I also tried spreading the orbs around randomly using a math code, but I wanted to have full control over them. I also decided to only have 4 orbs around the map. And story vice these were the energy orbs to charge our hero’s gun so that he could defeat the Mother-Virus.

In the lab on Thursday, they showed a really good and simple example of how to create and use an array. They created 10 balls, and first placed them orderly around the screen, then randomly using the math code I mentioned earlier. This really helped me a lot, and made me understand the usage of arrays.

I decided not to use a timer in my game, because I wanted it to be simple. I may later add a timer if I see that the game needs more challenges. But I tried to make a “test-timer” just for the learning experience, and it worked well. The examples shown in the lab were also very useful here.

One way I think I’m going to implement the timer later, is when I’m going to move my enemy back and forth. Since I move all my backgrounds, platforms and objects, instead of my character, I have to find a way to make my enemy move along the x-axis, without using a code similar to the ones we created in case 3.

Case 7 - Bad Guys

In this case we were supposed to design enemies for our heroes. Like I’ve mentioned earlier I was going with viruses and Trojan horses as the bad guys. These bad guys should have some kind of AI, they can follow the character, patrol a certain path or whatever. In this case we also were supposed to learn about using more than one class/.as-file. This can make your code easier to control and is a must if you’re creating bigger applications.



That is one of the bad guys; The Virus.

After discussing in the group meeting on Monday, I thought this would be an easy case. But as I got working on the code, I realized that I was wrong. It took a long time before I really understood the point of doing it this way, and I’m not sure I’ve done it now either. I can see the usage of more classes is valuable in bigger projects, but with a small flash game like this I’m not quite sure.




Here is the second bad guy in the game: The Trojan Horse.

After a while I managed to create the 2 classes; one main-class and one enemy-class. In the enemy-class I set the positions etc, and gave my enemy a very simple AI, that just makes him patrol back and forth. I have not created a function that says what is going to happen if our hero hits him, but I am working on it.