Sunday, 13 April 2014

Research - Finding a song

I would like a song to play when the user plays this game.

The song can't be something which distracts the user, but instead creates an atmosphere for the game.

I've searched around and there's two songs which stand out to me.

Song Name Description Link
Fall Of The Awakened This song creates a very good atmosphere and sounds like a song which would be used for problem solving in games with puzzles. This will work very well with my game. However the song changes at 1:20 and becomes much more upbeat - which will not work with the game I am creating. Since, if used, the duration would just be 1:20 this is too short for a game like mine. If set on a loop in Flash, it wouldn't work well as there would be a clear indication where it begins and ends. /audio/listen/573019
Let It Go (Short) This song has an entirely different atmosphere. It does not so much represent a problem solving puzzle vibe but more so gives an impression that all is not right. Which would work well with my game as there is a character to is lost and has trouble finding out where he is and who he is. /audio/listen/566042

Out of the two, I believe Let It Go would be best suited  for this. Mainly because it's good throughout and the loop works perfectly. Loops are particularly important with games.


Saturday, 12 April 2014

Working Processes: Creating the Game - Fixing the inventory issue

To fix my inventory issue, I changed my code from this (with booleans):

function ifFullPassItem():void {
    if(!itemBox1Full){
        bottomBar.barItemBox1.gotoAndStop(itemInQuestion);
        trace(itemBox1Full);
        itemBox1Full = true;
    } else if (itemBox1Full){
        bottomBar.barItemBox2.gotoAndStop(itemInQuestion);
        trace(itemBox1Full);
        itemBox2Full = true;
    }
}


To this (with vectors):

function ifFullPassItem():void {
    for (var i:uint = 0; i < 7; i++) {
        if(i<inventorySystem.length){
            bottomBar["barItemBox"+(i+1)].gotoAndStop(inventorySystem[i]);
        } else{
            bottomBar["barItemBox"+(i+1)].gotoAndStop("itemNothing");
        }
    }   
}


I have uploaded both versions of the game in order to show what has changed.

The Waiting Room [V1]
The Waiting Room [V2]

You will notice that there are overlays as buttons, instead of buttons on the actual items. I done this so that I would only need one symbol for the buttons. When publishing the final version, these buttons shall be made transparent, not in the alpha filter, but inside the symbol with the fill colour set to 0% alpha.

In order to see the difference between the files, please do these steps.

Enter your name
Click on the Computer
Click on  the lightbulb on the chair
Drag the lightbulb, from the inventory, onto the lamp
Press back
Click on the coat to retrieve the glasses
Notice that...
In the old version the glasses get entered into the 2nd inventory slot instead of the 1st, even though the 1st is free.
In the new version the glasses transfer into the first slot







Also by redoing this script with a more complex formula, if both items were in the inventory (glasses in the 2nd slot) and then the lightbulb is removed, the glasses will move into the 1st slot. This is something which I had spoken to my supervisor Dan about, where I stated it may not be something I will be able to accomplish due to it's complexity.

I used this Adobe page on Vectors to learn how to use them and created the code myself
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html

Friday, 11 April 2014

Planning: The Inventory so far and the concerns

With the inventory I have created, some problems have arisen which I did not think would happen.

For my inventory I have the same movieclips, repeated 7 times, with different instance names.
I have the following code for it:

function ifFullPassItem():void {
    if(!itemBox1Full){
        bottomBar.barItemBox1.gotoAndStop(itemInQuestion);
        trace(itemBox1Full);
        itemBox1Full = true;
    } else if (itemBox1Full){
        bottomBar.barItemBox2.gotoAndStop(itemInQuestion);
        trace(itemBox1Full);
        itemBox2Full = true;
    }
}

This code is not complete, and would carry on till itembox7.

This code helps the items know which movieclip the item would be placed it, but it doesn't acknowledge which of those movieclip instances the item is in.

This means that I will not be able to take out items once they are used and this will create unnecessary item space.

I did consider adding a if barItemBox1=itemLightbulb gotoAndStop("itemNone") else if barItemBox2=itemLightbulb gotoAndStop ("itemNone") to the item. However this would make the code very long, especially as it would be repeated for each item.

I will need to change the code accordingly so that it will work well with removing items.

Working Processes: Creating the Game - Using items from the inventory

In my game, there comes a point that you will use the lightbulb, from the inventory and drag it to connect to the lamp.

It sounds like a reasonable straightforward code of startDrag and stopDrag with a hitTest, however this is not the case.

Since my inventory items are inside movieclips, this has made the process a lot harder.

Here is the code I have created:

//moveLightbulb
var lightbulbMove:lightbulbClass = new lightbulbClass();

stage.addEventListener(Event.ENTER_FRAME, lightbulbMoveListener);
function lightbulbMoveListener(event:Event):void {
    if(lightbulbGrab==1){
    trace("Lightbulb grab is grabbed (stage check) | " +lightbulbGrab);
    addChild(lightbulbMove);
    lightbulbMove.startDrag();
    lightbulbMove.y=mouseY;
    lightbulbMove.x=mouseX;
    lightbulbMove.z=1;
    lightbulbMove.visible=true;
    cursor_mc.visible=false;
    stage.removeEventListener(Event.ENTER_FRAME, lightbulbMoveListener);
    stage.addEventListener(Event.ENTER_FRAME, lightbulbReleasedListener);
    lightbulbGrab=2;
    }
}

function lightbulbReleasedListener(event:Event):void {
    if(lightbulbGrab==3){
    releaseLightbulb();
    }
}

function releaseLightbulb() {
    lightbulbMove.stopDrag();
    lightbulbMove.visible=false;
    cursor_mc.visible=true;
    cursor_mc.startDrag(true);
    lightbulbGrab=0;
    trace("Lightbulb grab is reset (stage check) | "+lightbulbGrab);
    stage.removeEventListener(Event.ENTER_FRAME, lightbulbReleasedListener);
    stage.addEventListener(Event.ENTER_FRAME, lightbulbMoveListener);
}
// hittest lightbulb and light;
stage.addEventListener(Event.ENTER_FRAME, lightbulbHitLampListener);
function lightbulbHitLampListener(event:Event):void {
    if (lightbulbMove.hitTestObject(tableView.tableViewLamp)) {
        lightbulbInserted=true;
        if (lightbulbInserted) {
            tableView.tableViewLamp.gotoAndStop(2);
            trace("Lightbulb grab is released and inserted (stage check) | "+lightbulbGrab);
            lightbulbGrab=3;
            stage.removeEventListener(Event.ENTER_FRAME, lightbulbHitLampListener);
        }
    }
}

The code above would use the EventListeners to look out for when specific user tasks have been completed. To do this I used if statements on integers

The integers numbers represented the following:

0 - default
1 - grabbed
2 - released
3 - dropped

The reason why default is so important is because it has not yet been grabbed, and it means that if the lightbulb was released onto the stage but not directly on the lamp, it would appear back in the default position - in the inventory.

The user event tasks were scripted in the inventory.

The reason for doing this is because I would not know which of the inventory slots the lightbulb was in. So I would therefore do it on the frame of the inventory movieclip that the item is in.

I used the following code inside in the inventory:

lightbulbInv.addEventListener(MouseEvent.MOUSE_DOWN, grabbedLightbulbListener);
function grabbedLightbulbListener(evt:MouseEvent):void {
    if (MovieClip(root).lightbulbGrab==0) {
        trace("this should work at 0 only");
        MovieClip(root).lightbulbGrab=1;
        trace("lightbulb grab is grabbed (inventory check) | "+MovieClip(root).lightbulbGrab);
        lightbulbInv.visible=false;
    }
}
stage.addEventListener(MouseEvent.MOUSE_UP, notgrabbedLightbulbListener);
function notgrabbedLightbulbListener(evt:MouseEvent):void {
    lightbulbInv.visible=true;
    if(MovieClip(root).lightbulbGrab==2){
        trace("Lightbulb grab is released (inventory check) | "+MovieClip(root).lightbulbGrab);
        MovieClip(root).lightbulbGrab=3;
        trace("Lightbulb grab is dropped (inventory check) | "+MovieClip(root).lightbulbGrab);
        //lightbulbInv.visible=false;
        lightbulbInv.addEventListener(MouseEvent.MOUSE_DOWN, grabbedLightbulbListener);
    }
}

stage.addEventListener(Event.ENTER_FRAME, lightbulbUsedListener);
function lightbulbUsedListener (event:Event):void{
    if(MovieClip(root).lightbulbInserted){
        stage.removeEventListener(MouseEvent.MOUSE_UP, notgrabbedLightbulbListener);
        gotoAndStop("itemNothing");
    }
}


Both of these codes have so far been the hardest to write in this project.

I found this on  drag and drop of items
http://www.actionscript.org/forums/showthread.php3?t=151862

Planning: Ethics Form Update

Today I got an email regarding ethics approval.

Fortunately it stated that I now have ethical clearance for my work so that I can show people my game and ask them about it.

This will help me find glitches and look at the way people play my game.
If I notice that they can't find an item or don't know how to do something, I can make it more clear.
If they spot bugs, I'll be able to take note and fix them.

Upon receiving the ethics approval I also have to attach this Approval Notification document with my work submission.

I plan to get feedback on my game after I have done more to it.

Thursday, 10 April 2014

Working Processes: Creating the Game - Problems with scripting the drawers

When working on the drawers section, I made 4 versions of the drawers. They were as follows:

All closed
1st one open
2nd one open
3rd one open

I created the script:

drawerView.drawer1.addEventListener(MouseEvent.CLICK,drawer1Listener);
function drawer1Listener(ev:MouseEvent):void{
    drawerView.gotoAndStop("opened1");
}
drawerView.drawer2.addEventListener(MouseEvent.CLICK,drawer2Listener);
function drawer2Listener(ev:MouseEvent):void{
    drawerView.gotoAndStop("opened2");
}
drawerView.drawer3.addEventListener(MouseEvent.CLICK,drawer3Listener);
function drawer3Listener(ev:MouseEvent):void{
    drawerView.gotoAndStop("opened3");
}



and put it outside of the movieclips.

When testing the the Flash SWF, I noticed that the drawers were only able to be opened once.



I decided to add traces in for each time a drawer was opened to see if this could help me solve the problem.

In the end, I decided it was best to firstly, make sure that the buttons for all the drawers were available on all frames of the movieclip, whether they were accessible or not, so that they can still be read by Flash. Secondly, I modified the code to recall the listeners for the other drawers after one had been opened. This fixed the problem. My new code looked like this:

drawerView.drawer1.addEventListener(MouseEvent.CLICK,drawer1Listener);
function drawer1Listener(ev:MouseEvent):void{
    drawerView.gotoAndStop("opened1");
    drawerView.drawer2.addEventListener(MouseEvent.CLICK,drawer2Listener);
    drawerView.drawer3.addEventListener(MouseEvent.CLICK,drawer3Listener);
}
drawerView.drawer2.addEventListener(MouseEvent.CLICK,drawer2Listener);
function drawer2Listener(ev:MouseEvent):void{
    drawerView.gotoAndStop("opened2");
    drawerView.drawer1.addEventListener(MouseEvent.CLICK,drawer1Listener);
    drawerView.drawer3.addEventListener(MouseEvent.CLICK,drawer3Listener);
}
drawerView.drawer3.addEventListener(MouseEvent.CLICK,drawer3Listener);
function drawer3Listener(ev:MouseEvent):void{
    drawerView.gotoAndStop("opened3");
    drawerView.drawer2.addEventListener(MouseEvent.CLICK,drawer2Listener);
    drawerView.drawer1.addEventListener(MouseEvent.CLICK,drawer1Listener);
}


.

Wednesday, 9 April 2014

Working Processes: Creating the Game - Small errors EventListeners

Strangely, even though I had used the code:

roomView.mainTable.addEventListener(MouseEvent.CLICK,mainTableListener);
function mainTableListener(ev:MouseEvent):void{
    gotoAndStop("viewTable");
    stage.removeEventListener(Event.ENTER_FRAME, mousePlacementX);
}

to remove the event listener of mousePlacementX (used for changing frames to another camera angle). I still received errors complaining that mousePlacementX movieclip was not accessible (meaning that the movieclip has not been removed).

To sort out this problem and perhaps glitch, I added:

stage.removeEventListener(Event.ENTER_FRAME, mousePlacementX);

to the frame label of viewTable and received no more errors.