Tuesday, November 24, 2009

Case 08 - Timer and arrays

So, in this case we got the task to make a timer and use arrays for something. The time could either count down or just count how long time you use to complete the game. So far I have chosen a timer that start on 0 and count upwards. I might change it to a countdown, so that you have complete the game within a certain timelimit.
I started out from the example from the labclass, and made it so that it starts counting when starting the game. I didn't make it a new class in its own .as-file because I honestly haven't grasped the class system yet and find it a little confusing. I did the same for the arrays, which I use to insert some bottles of rum, which collect points when picked up. Like I did with the timer, I took the lab example tried to understand how it works. I managed to add the bottles with array, then adding a hitTestObject with the pirate so they can be picked up and add points to the total score. I planed to add gravity to the arrays/bottles so that they would just fall to the ground and stay there. But when I tried that it just messed up the pirates physics aswell. So I ended up by just placing the bottles by inserting fitting x and y coordinates. To display the collected points/score I did the same as in the timer. Made a new dynamic text field, made a new :int variable which increases by 50 when picking up a bottle. A function that make that :int variable into a string, and then inserting that string function into the dynamic textfield.

No comments: