Friday 30 January 2015

Every game needs a timer and moving platforms Right?

Obviously the answer is no, but it seems like the best mind set to have when creating the mechanics for your game. No one wants to spend hours re-writing the same scripts over and over again and I found myself doing this whenever starting a new project. I have promised myself to try and make my life easier from now on by trying my best to make the code as re-usable as possible and have them stored for a rainy day. I thought I would share a couple scripts (JavaScript) that others might find useful and that follow my new train of thought.

Timer:

#pragma strict

public var scaleOfBar :float;
private var total :float;
private var percent :float;
public var duration :float;
public var horizontal :boolean = false;
public var vertical :boolean = false;
public var minus :boolean = false;
public var adding :boolean = false;


function Start () {

if (minus) // If ticked in unity the bar will decrease in scale.
total = scaleOfBar;
else if (adding) // This will increase.
total = 0;
}

function Update ()
{
percent = scaleOfBar / duration; // How much to Increase/Decrease the bar every second

if (total > 0 && minus)
total -= Time.deltaTime * percent; //Decrease until bar is empty
if (total < scaleOfBar && adding)
total += Time.deltaTime * percent; //Increases bar until it's full

// Statements below check what axis to effect
if (horizontal)
transform.localScale.x = total;
if (vertical)
transform.localScale.y = total;
}

Once attached to your object you just need to change the pivot point so the bar does what you want.
Fill in all the information in the Unity editor (duration is in seconds) by ticking the boxes that you want. Note: If you have a horizontal bar copy and paste the x Scale of the bar into scaleOfBar or the y Scale for vertical.


Moving Platforms:

#pragma strict

public var heightLimit :float;
public var lowLimit :float;
public var leftLimit :float;
public var rightLimit :float;
public var moveUpAndDown :boolean;
public var moveLeftAndRight :boolean;
public var moveUp :boolean = false;
public var moveDown :boolean = false;
public var moveLeft :boolean = false;
public var moveRight :boolean = false;
public var speed :float;

function Update ()
{
if (moveLeftAndRight) // Horizontal movement
{
if (transform.localPosition.x <= leftLimit)
{
moveLeft = false;
moveRight = true;
}
else if (transform.localPosition.x >= rightLimit)
{
moveLeft = true;
moveRight = false;
}
//Move platform back and forth
if (moveRight)
transform.localPosition.x += speed * Time.deltaTime;
else if (moveLeft)
transform.localPosition.x -= speed * Time.deltaTime;


}
if (moveUpAndDown) // Vertical movement
{
if (transform.localPosition.y <= lowLimit)
{
moveUp = true;
moveDown = false;
}
else if (transform.localPosition.y >= heightLimit)
{
moveDown = true;
moveUp = false;
}
// Move platform Up and Down
if (moveUp)
transform.localPosition.y += speed * Time.deltaTime;
if (moveDown)
transform.localPosition.y -= speed * Time.deltaTime;
}
}

Similar to the timer you just need to edit in the Unity Editor once you have attached it to the object.
Tick the movement method you want and put the axis where you want the platform to change direction in the correct limit. Note; You must tell it what direction to start moving on one of the bottom four tick boxes.


Hope this stuff helps and feel free to use them.

Thursday 29 January 2015

Treasure Hunt

Teams went out on an adventure today to find QR codes scattered around the University Campus. Once found we were given directions or clues to where the next code could be found. This is a popular ARG (Alternate reality game) that is played on small or large scales. 
     Unfortunately my team had hit a dead end and misheard the clue. As it was a cold day and the lecture room was only down stairs, I opted for the comfort of warmth.

There are many resources online where you can set up your own QR codes that can be used for many different reasons. They can be used to set up things like treasure hunts, Sending sms messages to your phone if someone finds your keys and scans the code on them, advertising and many more.

On http://www.qrstuff.com/ you are able to make your own Codes and attach files such as:
  • Simple text.
  • Image files such as jpeg
  • Audio Files
  • Video Files
  • Url Links

You have probably seen Images like the one below to promote things within businesses to take them to their websites.


Wednesday 28 January 2015

Game Jam 2015

Nothing sounds more thrilling than a weekend of sleep deprivation, sugary drinks and savory snacks. The week leading up to the jam I was still in xmas mode, I felt extremely lazy and hardly motivated to do anything. To be honest there was a part of me that wanted to miss this one, I think it was the idea of letting the team down that led me to doing it.

Now looking back on that I don't know what the hell I was thinking, the experience of starting with a blank piece of paper and an empty Unity Scene with a 48 hr timer was amazing. My team consisted of first year students, like myself, and a friend of mine who owns his own animation business. We had to use anything and everything we had learned since September to try and make a game worth playing and I think/hope we succeeded.

On the same day the jam started we had Diego ,(Think that's how his name is spelt) a Post-Graduate from UCS who now works for Ubisoft Milan give a talk about the differences of AAA companies and Indie. He also gave us an insight on the kind of attributes and expectations companies like Ubisoft have. A few things I took away from this talk was:
  • Game Design (AAA or Indie) can be stressful.
  • You must be decisive but also be logical with your decisions.
  • Must have impeccable communication skills.
  • Have to learn from your mistakes quickly.
  • You must be able to take responsibility.
I don't think Diego could have come at a better time, a few hours later we were sitting down trying to think of ideas for our game. The next 48 hours seemed like a crash course for all the points above, except on a much smaller scale. Although these points can look very negative and not very appealing, the pros far out weigh the cons. Watching people play something you have had a part in creating is just awesome.



http://globalgamejam.org/2015/games/unlucky-chucky

Thursday 22 January 2015

Pervasive games


Today we talked about 'Killer' which is a pervasive game that was inspired from a film named 'La Decima Vittima'. The games objective is to assassinate your target using toy weapons as well as avoid the people that are targeting you.

The story to La Decima Vittima involves two main characters that are in a game called The Big Hunt. This involves real assassinations that has been legalised as long as the person is your victim or hunter. When you are a hunter and you kill your target your role is reversed to the victim. If you are able to kill 10 people you are rewarded with 1 million dollars and retire with a title of prestige and honored with many luxuries.

This film was adapted into a short story by Robert Sheckley named 'Seventh Victim' and then adapted into a game by Steve Jackson. This game is often played in college and universities and have set rules of where they can play (be assassinated) to avoid undesired consequences.
     Talking of undesired consequences, there have been many occasions where pervasive games have caused legal issues and fear in the community as people are not aware with what is going on. A good example of this is when a 3 week long game called Street Wars was held in London (rules were based on killer). further details can be found on this story here: http://news.bbc.co.uk/1/hi/england/london/5211998.stm

In America there was an event held called 'Cruel 2 B Kind'. This resembles the rules of Killer but to avoid the public outrage that London showed, instead of using water pistols, they hurled compliments or nice sentiments at one another.

Pervasive games are enjoyable as there is an overlap between the real world and the game being played. There is a sense, similar to an inside joke where the people that are involved know what is going on but everyone else just remain blissfully unaware or preferably hugely confused.