Wednesday 11 March 2009

Flash game update - 'Amazing Memory?'

Since my last post, I've made and implemented quite a few new features. I have found that development is manageable by doing it in reasonable stages: level designs, alpha transformation to 0, countdown clock, reveal option. 

Firstly, one of the key objectives I set out beforehand was to have levels that increased in difficulty. Henceforth, I have created 7 designs which I think will cater for a decent amount of gameplay. I did discard some other designs as I felt them a little too repetitive. However, luckily I noticed that by altering the start and end positions will make for variety within the game, sometimes you'll be heading clockwise, sometimes anti-clockwise, sometimes north and so on.

I was cautious of making the first level in the least simple, so to ease the player in and encourage them to enjoy the game.



From then on, the gameplay becomes more difficult by adding in more complex routes, or little walls that will get in the way if not remember and eat up some time as the user tries to get around the obstacle.

 
  

Importantly, these are not how the designs will stay, visually. At the moment they provide a function. On completing all the additional code based tasks, I will return to the designs and update them. I am considering themes, such as an Aztec look, or Roman, along with Egyptian or Japanese. 

The unique selling point of the game relies upon the fact that the user must remember the route/maze as it disappears within a set period of time. I moved onto installing this event.

After having researched online, I learnt that it was possible to create fading tweens within the action script. However, it appeared long and quite laborious, so I decided to opt for a straight reduction in the alpha state - from 1, to 0. 


This is achieved only after a 'remember time' clock counts down. So I had to install this too.
Courtesy of David Downes' Flash examples, I was able to look up the code required for a countdown clock. 

I decided a suitable amount of time was 8 seconds, and so set the remembertimer variable to 8. However, I soon found on testing the movie that whilst the 'remember clock' counts down, the user is able to begin their route through the map. Hence, I had to remove the stage event that listens for key events whilst the remembertimer is active.

Here is the code that now is required to suitably allow the user to remember the maze, not play, but then be allowed to play when remembering is over: 

 
maze.alpha=1;

var remembertime=8;
// total time to countdown

var remembertimer:Timer = new Timer(1000, 0);
//(delay in milliseconds, number of repeats)

function remembertimerStart() {
   // start timer and starts timerHandler function when the act is completed
        remembertimer.addEventListener("timer", remembertimerHandler);
        remembertimer.start();
rememberclock.text=remembertime;
}

function remembertimerHandler(event:TimerEvent):void{
      remembertime=remembertime-1; // remove 1 second every 1000 milliseconds
      rememberclock.text=remembertime; 
 // when clock reaches 0 then it will stop the timer and the walls will become transparent
 // the keys will become usable
 // the clock will be reset ready for the next level
      if (remembertime==0) {  
 remembertimer.stop();
  rememberclock.text="";
 maze.alpha=0;
 stage.addEventListener(KeyboardEvent.KEY_DOWN,detecthit1);
 leveltimerStart();
 }
}

As can be seen, this activates the next timer, the leveltimer, which is the total time allowed to hunt round the maze. It was necessary to use rememberclock.text="" when it completes as I decided from a design point of view to have the clocks in the same position. Otherwise, I encountered the problem that the rememberclock read 0 and overlapped the levelclock which counts down.



Lastly, through playing the test versions myself, I became aware of how difficult the game can be when not paying full attention. This resulted in me allowing more generous time allowances per maze, upping it from 30, to 40, yet still this could prove difficult in the latter stages. I am wary of extreme difficulty, as it was sometime I found I disliked through my Flash game analysis.

To combat this, from an early stage I realised the option for a 'reveal' button would be helpful. I found the implementing of code easy enough... or so I thought. Harking back to my very first days using Flash, it was a case of setting up an event listener for when the reveal button is pushed:

revealBtn.addEventListener(MouseEvent.CLICK,revealtimerStart);
 

However, I received an error concerning the third countdown clock I have working in this game. It repeatedly sought a type of event. Having always been a little unclear on the purpose of myEventObject, or e:event, or event:MouseEvent  it was courtesy of a surgery session that allowed me to get it cleared up.

Now, the 'remember clock' counts down, the 'level clock' then is cued, and should the user need it, they can push reveal and the 'reveal clock' will be activated, which pauses the 'level clock' but then makes it continue after the alotted time. 



I am pleased so far with my progress. I have tried to steer away from quick fixes, and unlike my previous history with Flash, my coding is not too superfluous. The functions that set up and make the game run are all on the first frame. Thereafter, the following slides just require calling the rememberTimerStart () function, which begins the processes.



So far I have been fortunate in encountering little trouble in the development of my game. Nonetheless, advances can still be made. As I mentioned beforehand, the design needs enhancing, but then also, I would like to add in bonus points, which that in itself requires sorting out a points score system. I have tried a little but failed in my efforts. Lastly, if time feasible, I want to limit the amount of times reveal can be used. This will no doubt concern using a variable options setting up the amount. 

@



No comments: