Sunday, 29 May 2011
Finished game
Thought I'd post a link to the finished game that I posted on my DeviantArt page, I'm really happy with how well received it's been: http://steffne.deviantart.com/gallery/#/d3hdv85
Friday, 27 May 2011
Conclusion
I've had a lot of fun making this game, it's extremely near completion so I'm definitely going to keep going with it. Hopefully I can have it up and fully running by later tonight/tomorrow. This is the most challenging thing that I've created in AS3, I'm surprised that I managed to achieve what I did! It's been very fiddly at times, I'm very grateful that I created a flowchart as it really helped me get my head around what I exactly needed to be doing at times. I think if I were to redo this again I'd have liked to have gave myself some more time for research and preproduction. However I have been working on it non-stop since receiving the assignment, so I'm not too sure how I'd have managed to squeeze anything else in! Overall very pleased with myself and hope to keep furthering my knowledge in AS3.
Variables
Here is a list of the variables I've used in the game:
//booleans
var herbhaircollect:Boolean=false;
var herbfridgecollect:Boolean=false;
var herbcircuscollect:Boolean=false;
var bookherbcollect:Boolean=false;
var strawberrydrawercollect:Boolean=false;
var henhousestrawberrycollect:Boolean=false;
var barnstrawberrycollect:Boolean=false;
var medicinestrawberrycollect:Boolean=false;
var bookstrawberrycollect:Boolean=false;
var treestrawberrycollect:Boolean=false;
var mudstrawberrycollect:Boolean=false;
var plantpotstrawberrycollect:Boolean=false;
var haystrawberrycollect:Boolean=false;
var strawberrymirrorcollect:Boolean=false;
var henclick:Boolean=false;
var geteggs:Boolean=false;
var cakecolour:int = 0;
As I mentioned before, the majority of these were used to stop items from reappearing and being recollected.
The henclick is so that when the hen has jumped out the tree, it stays vanished from the main environment.
The geteggs is for when you close down the farmers speech, he sends the eggs to the bakery for you.
The cakecolour stores a number which is used to help determine which frame of the birthday cake to go to (directs you to the right colour.)
//booleans
var herbhaircollect:Boolean=false;
var herbfridgecollect:Boolean=false;
var herbcircuscollect:Boolean=false;
var bookherbcollect:Boolean=false;
var strawberrydrawercollect:Boolean=false;
var henhousestrawberrycollect:Boolean=false;
var barnstrawberrycollect:Boolean=false;
var medicinestrawberrycollect:Boolean=false;
var bookstrawberrycollect:Boolean=false;
var treestrawberrycollect:Boolean=false;
var mudstrawberrycollect:Boolean=false;
var plantpotstrawberrycollect:Boolean=false;
var haystrawberrycollect:Boolean=false;
var strawberrymirrorcollect:Boolean=false;
var henclick:Boolean=false;
var geteggs:Boolean=false;
var cakecolour:int = 0;
As I mentioned before, the majority of these were used to stop items from reappearing and being recollected.
The henclick is so that when the hen has jumped out the tree, it stays vanished from the main environment.
The geteggs is for when you close down the farmers speech, he sends the eggs to the bakery for you.
The cakecolour stores a number which is used to help determine which frame of the birthday cake to go to (directs you to the right colour.)
Character movement
I'll stick to explaining the key points here or else it'll get confusing.
On the down button press, Calvin switches to facing forwards.
On the up button press, Calvin switches to facing backwards.
On the left button press, Calvin switches to facing left.
On the right button press, Calvin switches to facing right.
This is done through gotoAndStop codes.
When Calvin gets 200 pxls to the left/right of the screen,
the background starts scrolling with the movement of Calvin.
In this chunk of code there's parts that mention wellies which might look confusing to someone else looking at this.
This is here because in the barn you can click on the wellies and Calvin will wear them,
you can't walk through the mud until you wear these.
The wellies are always on Calvins feet, but on alpha=0
Calvin wears the wellies when the alpha = 1 and he is then able to pass the coordinate cut off point where the mud is.
There's also a part about ladders,
when ladders2 alpha =0 , on the up key press Calvin can go up the ladders.
The left and right keys are disabled when Calvin goes up the ladders as Calvin just goes invisible when the ladder animation occurs.
(It'd look pretty strange if Calvin stayed at the bottom of the ladders,
while a seperate animation of him was climbing up the ladders at the same time!)When Calvin gets to the bottom of the ladders (animation over) Calvin reappears on the main stage
and his left and right movement is free to move again.
Password boxes
Razzles password
For Razzle's password, you find a note in his toolbox with a picture of snakes. As this doesn't say a specific word, I didn't want to be too strict on the password. So this is why I have more than one password that works on this box, I've also added the password in a mixture of lower and uppercases. When you press the guess button, it closes down the menu (hides with alpha:0 and moves coordinates) if you have the correct password he will say so- then give you his ladders as a reward. The ladders reward pops up when you close his dialogue box (the actionscript is hiding in the speech dialogue movieclip.) If you guess wrong then he'll say it isn't right. You can then close down his speech box, click on him again and the password menu will pop up. This menu will keep doing this until you guess the password correctly. Once you've obtained the ladders from Razzle his speech bubbles alpha will go to 0 so that you can't talk to him anymore.
Pincode
Code explanation
I thought I'd firstly explain the basic structure of my code. There's quite a lot of it now and printscreening it all and putting it into this blog might be a bit of a challenge! I'll try my best though.
Collecting items -
When you click on an item, the alpha is lowered and it's coodinates are moved. (this applies to closing down menus too)
If the item is collectable then it goes into the pocket inventory, into it's corresponding box.
The first frames of these boxes are blank, the second show the item that has been collected.
Two of my items (strawberries and herbs) have counters on them,
so when you collect an item it adds one to the correspondong number. (herbbox + berrybox)
I also have an award menu that pops up as an extra bit of feedback so that you know when you've collected an item.
I had an issue with collectable items reappearing once you leave the room and come back.
To fix this issue I added in variables for each item, so when the variable is true the item stays off stage and alpha: 0
Here is an example of how the award menu and collecting a herb works:
function fridgeherb3(evt:MouseEvent):void {
herbhave++; // plus 1 to herb counter
herbfridgecollect=true; // refers to variable, this stops the herb from being recollected and reappearing
environment.fridge.fridgeherb.x+=1000;
environment.fridge.fridgeherb.y+=1000; //moves herbs coordinates
award.gotoAndStop("herb");//moves to herb award popup
award.alpha=1;//makes awards visible
award.x=stage.stageWidth/2;//moves award to halfway point on stage
award.y=164; //moves awards to this y coordinate point
if (pocketinventory.box6.currentFrame==1) { // if you haven't collected a herb yet then
pocketinventory.box6.gotoAndStop(2);//switch to second frame so that herb appears in inventory
}
}
Talking to characters -
This was by far one of the most confusing parts. I have just one movieclip with all character dialogue listed- and an animation previous to show the speech bubble pop up. I didn't originally have this animation pasted in at the front of every piece of speech, but I ended up getting a bug where it struggled to find the spoken text after playing the animation. To fix the problem I added the animation at the beginning so that it wouldn't have to fuss around looking for 2 separate things.
I also have all the close speech code inside this movieclip, which ended up causing a few extra issues since the rest of my code was on the main timeline. If I ever made another game on this scale I'd definitely stick to keeping all the code on the main timeline. When looking for a null object error, I found it a nightmare looking around so many pieces of code dotted around all over the place.
This is an example of how the character dialogue code works:
function pom1(evt:MouseEvent):void {
if (strawberryhave >=10 && henclick == true) { //if you have 10 strawberries and eggs
environment.speech8.gotoAndPlay(302); //talk to pom- she'll ask what colour cake you'd like
} else {
environment.speech8.gotoAndPlay(130);//talk to pom - she asks for 10 strawberries and eggs
}
}
Wednesday, 18 May 2011
Custom Cursor
Tutorial used: http://danielmclaren.com/node/96
You can see it hovering over the hospital doors.
I'm very pleased with the outcome of this cursor, when you hover away from the flash file the cursor disappears.
Then reappears when you move back onto the game.
I've had issues with this in AS2 where even when you hovered off the flash file- the cursor image would still stay on-screen.
Subscribe to:
Posts (Atom)