HTML5
banner
navBar resume programming
scriptingBar
Game/Program:
Tilt-A-World

A gravity-based maze game that started off as just a small exercise I came up with in which I could put some of the work I did in Unity3D tutorials into practice.

I then re-skinned it and recorded game play for an AMD video contest and I won.

I then showed it to Gene Fowler (my boss during my practicum at Loogaroo) and he said "...lets do it for iPhone/iPad/iPod!..." .

So now I'm in the process of refining the code and adding new functionalities. I also have a proper artist, William Halbersma, working on proper assets for me.

The game is simple. Rotate the maze so that gravity will take the ball to the end of the maze. The user only needs to physically rotate their phone/device to rotate the maze.

 
gravControl.js
var backGround:GameObject; //handle to back ground
var theBall:GameObject; //handle to the ball

function Start()
{
    backGround=gameObject.Find("background"); //set handle to background
    theBall=gameObject.Find("Ball"); //set handle to ball
}

function Update()
{
    gameObject.transform.rotation=backGround.gameObject.transform.rotation; //copy background rotation
    
    //apply gravity to the ball in the direction the background has rotated such that the player percieves gravity is pulling them down no matter
    //how much the maze has rotated
    theBall.gameObject.rigidbody.AddForce(gameObject.transform.up*(-Physics.gravity.y*40.0*Time.deltaTime));
}
 

Although this script is very short. It took me a bit of thinking to figure it out.

Originally I was just rotating the whole maze and letting gravity do it's thing. However, between update loops it was sometimes possible for the ball to end up inside a block before physics was able to register the collision. This caused a few obvious glitches. So, I decided to manually apply gravity to the ball.

I accomplished this by first creating an empty GameObject and orienting it such that it's up vector points towards actual up.
Then by multiplying it's up vector by gravity's y element by an arbitrary number by delta time by negative 1. The resulting vector is always pointing towards what the user perceives as down in the real world. That resulting vector is applied as force to the ball each update loop. Delta time is part of that multiplication to keep the ball moving the same amount on any hardware. The arbitrary number is used so the ball doesn't move incredibly slow. The negative one is used so we're not being pulled upwards.

The camera and background are the only things actually rotating. However, to the end user, it appears they are simply rotating the maze. The same math is applied to the bubble particles in the water level except without multiplying by negative 1.

 
^RETURN TO TOP^