Daily Reaction Game Dev: We Made a Box Move

{

/*Welcome to the first DR Game Dev post, the ongoing story of Seb and Dan’s attempts to make a game that should hopefully give us a better understanding of the games industry, as well as allowing us to make a friggen game. With each update, we hope to clue you in on our progress, give you a glimpse at game creation and insult each other mercilessly.

Seb: So my knowledge on the whole game creation thing was absolutely zero going into this, while Dan has a few months of knowledge… but from years ago. Honestly, we didn’t even know where to start.

Dan: Yeah, having had some lead time on Seb, I thought I could at least have a few days of going over the things I had learned way back, sadly, that only took up about 10 mins before I caught him up to my level.

Seb: The first thing I learned was that Java isn’t only a type of tasty coffee bean, but also a programming language that will be fundamental in the creation of our game. So we set ourselves a challenge in Unity3D, a popular (free) game engine – make a ‘game’ where you could move a box left, right, up and down using the directional keys.

Dan: While not exactly the most complicated of concepts, the idea was to get a fundamental understanding of how JavaScript actually works, and to know if we can follow its rules of logic. We looked up the code for making a box move left and right, but had to re-write it to go up and down.

Seb: Yup, and that code is:

#pragma strict

function Start () {

}

function Update () {

var moveHoriz : float = Input.GetAxis( “Horizontal” );

var moveVert : float = Input.GetAxis( “Vertical” );

if( Mathf.Abs( moveHoriz ) > 0.0 )

{

    transform.position += Vector3.right * moveHoriz * Time.deltaTime;

}

   if( Mathf.Abs ( moveVert ) > 0.0 )

   {

      transform.position += Vector3.up * moveVert * Time.deltaTime;

   }

}

What we then did was to reverse engineer it to ensure what all these weird words and squiggles actually mean. At the end of each DR Game Dev, we’ll post our continually updating self-made dictionary.

Dan: Simply by messing around with the code we were able to understand how certain segments or Classes were called, and what they would be expecting as a return value. Yet, even though there are resources online, most expect a great deal of knowledge before you could comprehend what they were talking about.

Seb: Oh god, it’s crazy. They start with “Oh so you’ve never done any coding before? That’s ok, simply start by flanging the x-node with the ol’ truvian method of distillation.” It’s stupid. But we persevered, and ended up with this code:

#pragma strict

function Start () {

}

function Update () {

var moveHoriz : float = Input.GetAxis( “Horizontal” );

var moveVert : float = Input.GetAxis( “Vertical” );

if( Mathf.Abs( moveHoriz ) > 0.0 )

{

     transform.position += Vector3.right * moveVert * Time.deltaTime;

}

    if( Mathf.Abs ( moveVert ) > 0.0 )

    {

       transform.position += Vector3.up * moveVert * Time.deltaTime;

    }

}

And the box moved. IT MOVED.

game5

Dan: Luckily for Seb, I already flanged my x-node before we started, so that was out of the way. But, as we finally got things to move, as well as understand the method programmers use to determine time and speed, we were able to adjust movement to a usable pace. In the end the tangible product we were left with was only a simple program that moved a box in almost any direction, but the effect it had on our confidence and comprehension of JavaScript was immeasurable.

What do you think of the DR GameDev? Are you trying to make your own game? Do you want to know our game idea yet? Are you excited to see Dan’s upcoming concept art? Share your nerd speak in the comments below, or hack our Twitters to crash the stock market at Seb and Dan. As always, feel free to email us at DailyReaction@PlayStationLifeStyle.net for game tips, random jokes and sex robot stories.

Turn to page 2 for our terribly inaccurate dictionary…

*/

}

TRENDING