Wednesday, 9 April 2014

Working Processes: Creating the Game - Implementing the Inventory (coding)

I took the inventory system which I created on this blog post and adjusted it so that it would not need to be so repetitive dependent upon which item was picked up. Originally the code look like this:

function ifFullPassSquare():void {
    if(!inv1Full){
        inv1.gotoAndStop(2);
        inv1Full = true;
    } else if (inv1Full){
        inv2.gotoAndStop(2);
        inv2Full = true;
    }
}
function ifFullPassCircle():void {
    if(!inv1Full){
        inv1.gotoAndStop(3);
        inv1Full = true;
    } else if (inv1Full){
        inv2.gotoAndStop(3);
        inv2Full = true;
    }
}


This code works, but it is very repetitive and will become more repetitive the more items you have to add to the inventory.

Since the two functions are very similar, I have created a code which will include all items. This would be done through a variable.

Here is the code:

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

itemInQuestion is the variable. When picking up an item, itemInQuestion will be set to the name of what label that item has in the inventory. This function would then be inserted and apply that code.

The lable, as seen in the previous blog post would look like this, itemLightbulb
When the item is found, the script itemInQuestion=itemLightbulb; would be implemented.

As more item boxes are added, the code will increase in size.

Working Processes: Creating the Game - Implementing the Inventory (visual)

For my inventory, I have created a single movieclip. I have pasted it 6 times so there are now 7 of them.

With the 7 movieclips, I have given them each a different instance name to establish the difference between them.

barItemBox1
barItemBox2
etc

Inside the movieclip, I have so far created 5 frames. Each frame containing a new item. The first frame of which containing no item.

As I add more items in, I'll have more frames.

Each frame has its own label such as itemLightbulb.


[UNFINISHED] Planning: Inventory System

Inventory will have items overlapping the square

Tuesday, 8 April 2014

Working Processes: Creating the Game - Adding menu and back buttons & two room views

I have now added two new room views.

These are of the desk (referred to as table), so you'll be able to see the other side of it, closer up.
And also of the computer screen, once the screen has been clicked on.

These camera angles are important as you'll not only see the contents of the desk better, but also now have access to the drawers and most importantly, see parts of the room and items you had not seen before.


When on this side of the desk, an item you wouldn't have seen in the previous camera angle appears. A lightbulb is now visible for the user to collect into their inventory and insert into the lamp.
The computer screen is an important camera angle as it allows the user to log into the receptionists account.

The user and password will need to be found with items around the room.
Once logged in the user will be able to see what the receptionists last activity was which will help give clues on further tasks.

It will display the users name and it will confirm that this transaction was with the user.

I have also now integrated a back and menu button.
The back button would go to the previous camera angle
Whilst
The menu button would go back to the enter your user name section.

The menu goes there for now, but this may change dependent upon how I adjust the menu later on. (There might be a section before the user enters their name).

In the case of the user accidentally clicking the menu button, I have created an are you sure box which will pop up and confirm whether the user wants to go through with this.

This message pops up as a movieclip and doesn't direct the user to another frame.

If the user presses no, then they will continue on their game as though they had never pressed the menu button.

Monday, 7 April 2014

Working Processes: Creating the Game - Adding a username feature

Without giving too much of the storyline away, I'm going to tell you why I believe a username feature will be so important for my artifact.

When the users enter their name, their name will be stored in the Flash as a string.

By doing so, I will be able to later refer back to their name on the computer and possibly other items too. This will therefore make the game more interactive as though it is them who is trapped in the room.

I created the following code to ask for the username:

var usersName:String;
stage.addEventListener(KeyboardEvent.KEY_DOWN,usersNameListener);
function usersNameListener(event:KeyboardEvent) {

    // if the key is ENTER
    if (event.charCode==13) {
        usersName=usersNameTxt.text;
        trace("You entered a name with " + usersName.length + " characters");
        if (usersName.length>=3) {
            stage.removeEventListener(KeyboardEvent.KEY_DOWN,usersNameListener);
            trace("Hello " + usersName + ", thank you for playing my game");
            gotoAndStop("viewMain");
        } else if (usersName.length<3){
            trace("Name needs more characters");
            nameCharacters_MC.play();
        }
    }
}

Since I wanted to be sure that the user actually enters a name rather than just skipping ahead, I added a character count by using an AS3 script. I also added a character limit, which didn't need to be scripted but merely changed in the settings of the input text field.

The character count was not something I had done before, I tried several methods including:
maxchars<=3
but in the end, I managed to find a forum post which touched upon this subject.

The code I had in fact been looking for was length

So I applied it accordingly, as seen above.

I used this Adobe page on Textfields to familiarise myself with them:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html
and then for character count, this was something I hadn't done before
http://www.kirupa.com/forum/showthread.php?179466-is-it-possible-to-do-a-character-count-in-flash

Sunday, 6 April 2014

Working Processes: Creating the Game - Pictures for Frames

Since I had picture frames in the background, which were suppose to be of the people who worked at the place. I wanted to make it so that these pictures were not cartoons but at the same time not photos of people.

If they were cartoons, the user would lose the feeling that they are trapped in the room.
If they were photos, it would not work since the art style would be completely different to the game.

I decided to use a feature of Flash known as trace bitmap. When tracing the bitmap, each picture needed different settings due to their size, colour and detail.

The settings averaged around the following

Colour threshold: 20
Minimum area: 50
Corner threshold: normal
Curve fit: normal

From this I was left with the following results:


They now look like paintings, which I believe looks better than if they were just photos.

Underneath each picture, I gave them a description of what role they had in the company and also what their name was. These pictures will play a key role in how the users will escape from the room.

Original pictures can be found in the bibliography.

Saturday, 5 April 2014

Working Processes: Creating the Game - Colouring in and adding tint

I went through the different alternatives I could use in order to colour in my piece.

I've decided to not go with any of those options but instead have taken a different route which I believe works best. This technique may be a technique I will proceed to use later in life too.

Instead of putting alpha on the colour of the items, or removing the lines, I've decided to instead colour the items in with a solid colour and give the lines an alpha. The alpha percentage I have chosen to apply to the whole room is 25%.

By having lines with 25% alpha, meaning that they are only 25% visible. Since the lines are also a black apha it means that the lines will be the same colour as the object but slightly darker. This would be perfect!


As for the colours itself, I have chosen to go for pastel colours. These colours aren't too strong and therefore will not look as though the game is made for infants (which would be the case if I went with primary colours only).

Since my game is also set at night, very little light will be in the room. In order to achieve a night effect, I have also added a tint to go above the Flash file.

To do this tint, I did not use the tint feature but instead used the advanced featured and played around with the settings. I was most satisfied with the following.
  • 47% alpha
  • 0% red
  • 0% green
  • 13% blue x B + 22
I believe this created a very good effect which left the piece looking as though it was at night. Here is the final result: