Saturday, 19 April 2014

Working Processes / Planning: Finalising the Game - Cutting can, Scripting fuse box, door animation, timer, updating the graphics of viewTable

Today, I finished creating the game. All the main scripting has been complete and is fully functional in regards to completing the game. As far as I'm aware, there are also no more glitches or errors within the code.

As for adding narration to the piece, I am unsure as to whether this would go well with the artefact or whether it will take it away from the user experiecing how to Escape the Room themselves.

Perhaps, the narration would be just used in the cutscene instead and not throughout the game.

I will find out the best route to take with this from my tutorial with Daniel, coming up on the 3rd of April.

 To getting to this stage of the production processes I had to complete the following things.

I had to script it so that the user was able to cut the cut into half


I made it so that when you click on the can, it pops like, like the notebook or desk note would have. This way, the user can read the contents of the can. I then added a button for the user to click to cut the can. Upon clicking the button, the can would be removed from the inventory and the cut can would be added.

If the user is not wearing their glasses, the ability to cut the can will not be accessible and therefore have a 50% with the event listener removed. Once the user wears their glasses, the contents of the can will be unblurred allowing the user to not only read the can but now cut it too.

I feel that this is important so that the user is aware of the content on the can.

Since the user must wear the glasses to read the notebook or note, it is unlikely the user will be able to get this far in the game without wearing the glasses in the first place. This script was added more so for users who are coming back to beat their score.

I then had to create the script for the fuse box. This was a simple hit test for the cut can and the fuse box. When adding this script, I had to make sure that the script would not work if the fuse box doors were close. In order to do this, I made sure that the script didn't work on frame 1 of the fuse box MC.

My script was the following:

// ---------Hit test item---------
// hittest cut can and fusebox;
stage.addEventListener(Event.ENTER_FRAME, canCutHitFuseBoxListener);
function canCutHitFuseBoxListener(event:Event):void {
    if (drugCanFound) {
        if (canCutMove.hitTestObject(shelfBoxView.insertCanHittest)) {
            if (stage.contains(canCutMove)&&shelfBoxView.currentFrame==1) {
                trace("yes, child (canCutMove) is there and going to be removed");
                removeChild(canCutMove);
                canCutGrab=3;
            } else {
                //lightbulbInserted=true;
                inventorySystem.splice(inventorySystem.indexOf("itemCanCut"),1);
                ifFullPassItem();
                //if (lightbulbInserted) {
                trace("Cut Can grab is released and inserted (stage check) | "+canCutGrab);
                canCutGrab=3;
                doorUnlocked=true;
                trace("Door Unlocked = "+doorUnlocked);
                overlayTint.visible=false;
                shelfBoxView.gotoAndStop(3);
                stage.removeEventListener(Event.ENTER_FRAME, canCutHitFuseBoxListener);
            }
        }
    }
}


This script also made it so that if the cut can was to be dragged whilst the fuse box doors were close (on frame 1 of the MC), that the child would be removed before opening the doors. This way, the hittests of the cut can dragged onto the stage (before the door was opened), would not interfere with the acitivated hittest when the doors were opened.

Afterwards, I created the boolean doorUnlocked.

This way I could make it so that the door will unlock as soon as the cut can has been dragged onto the fuse box.
The lights will also turn on when this happens, to do this, the movieclip overTint has been set to false.

I then went to the door camera angle and animated is so that when the doorUnlocked boolean is set to true, the screen turns black and takes you to the completed game label.

Once here, I added a timer.

In a tutorial with Dan, we discussed it would be a bad idea to add a timer which would be visible throughout playing the game as it would make the user play the game differently. By having it so that the time is displayed at the end of the game, it makes the users more relaxed on their first play through as they don't realise it is there and are able to play the game properly.

To create this timer, I used the timer from the "Code Snippits" from the windows toolbar. Here various codes were accessible including a timer. This timer however only worked in seconds.

The code was the following:

/* Simple Timer
Displays a countdown timer in the Output panel until 30 seconds elapse.
This code is a good place to start for creating timers for your own purposes.

Instructions:
1. To change the number of seconds in the timer, change the value 30 in the first line below to the number of seconds you want.
*/

var fl_TimerInstance_2:Timer = new Timer(1000, 30);
fl_TimerInstance_2.addEventListener(TimerEvent.TIMER, fl_TimerHandler_2);
fl_TimerInstance_2.start();

var fl_SecondsElapsed_2:Number = 1;

function fl_TimerHandler_2(event:TimerEvent):void
{
    trace("Seconds elapsed: " + fl_SecondsElapsed_2);
    fl_SecondsElapsed_2++;
}


I read the code and figured out how it worked, I then managed to come up with an idea on how I could involve minutes too. The code changed to the following:

var fl_TimerInstance:Timer = new Timer(1000, 3000);
fl_TimerInstance.addEventListener(TimerEvent.TIMER, fl_TimerHandler);

var fl_SecondsElapsed:Number = 1;
var fl_MinutesElapsed:Number = 0;

function fl_TimerHandler(event:TimerEvent):void
{
    if(fl_SecondsElapsed == 60){
        fl_SecondsElapsed = 0;
        fl_MinutesElapsed++;
    }
    trace(+fl_MinutesElapsed + " Minutes and " + fl_SecondsElapsed +" Seconds");
    fl_SecondsElapsed++;
}


So when fl_SecondsElapsed == 60, I would reset it to 0 and add 1 to the minutes.

This worked very well and was ideal.

Finally, I then went back to the viewTable and completed the art for that camera angle. Originally I had not done this as I felt that the scripting of the game was more important than the appearance.

Before


After


Once complete, I was very happy with the results.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.