Week 2

Developing 15 capstone ideas proved to be very challenging for me this past week. I spent way too long thinking about each proposal and was never fully satisfied with any of them. I know the area in…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Javascript and Games

As we have just started to jump into the world of making are webpages come alive with Javascript, I want to learn and look into more detail about how Javascript can be used with one of my big passions, and that being video games. Javascript an incredible versatile and powerful language, it is now used in almost every application of web-development, from making a static page interact with the user on the front end to being able to code all the back end with NodeJs.

The main reason any of us would want to learn Javascript is for the ability to make our websites react the user, if the user presses a like button they expect that button to change colour or show that they have interacted with the button in some way. This interaction between software and the user got me thinking about video games and how as a child I used to play a lot of games online with websites, I know a lot of them where flash games, but I wanted to see examples of whats out there for Javascript oriented games and what tools are available.

Free Rider

When I Googled Javascript games I found something that bought back so many memories of school and of cause not playing the game at all in lesson. Free Rider is a great example of what is possible with Javascript and turning a HTML page into hours of enjoyment.

HexGL

Then moving onto something that shows the full extent of what is possible with pushing the possibility of HTML and javascript to the limit with HexGL. In the creators own words, HexGL is a futuristic, fast-paced racing game built by Thibaut Despoulain using HTML5, Javascript and WebGL and a tribute to the original Wipeout and F-Zero series.” (WebGL is a Javascript API that renders 2D and 3D graphics). When I found this game I was blown away by what could be achieved and I was not expecting something like this, when I think web based games my mind is drawn to Freed Rider and that basic style but HexGL could be put onto a console and wouldn’t look to far out of place.

I had another reason for wanting to talk about this subject and that is that I used to use the game engine Unity 3D and remembered that it allowed users to create using Javascript and I wanted to have a go and see what I could make. Once I had downloaded Unity to begin, I quickly found out that the option to write any script in Javascript had been taken away and C# was the only language that could be selected. I did some digging to see if they had hidden the setting or I need to download a different version but it turns out that using Javascript had been scrapped completely.

Unity for anyone that doesn’t know is a game engine that is used for a host of different styles of games, from 2D and 3D to virtual reality and augmented reality. Unity was released in 2005 and has a host of popular games that have been created using the platform, including: Cuphead, Heartstone and the VR Rick and Morty games as well as hundreds of mobile games.

The goal was to make something simple a character would walk into a trigger box and a partical effect would happen. I started off by creating a plane to act as the ground for the character.

creating the plane
Oops

When running to see if what I had created worked I had forgotten to make the plane a solid object so the character would just fall through the ground. Then I applied the first person camera onto the capsule to allow it the controls to run as a first person character, this prefab is the handy in the same way rails is when creating websites. It automatically has all the basic code done for allowing camera movement with the mouse as well as keyboard controls for moving the character, in the same way rails creates most of the basic HTML so we don’t have to write it out over and over.

First person camera working

With the first person controller working this is the point for creating the trigger to set the particle system going. This is where I ran into the problem of Unity stopping the support for Javascript. I search seeing why and if there was reason for it, like a Javascript as powerful as C#. But nope. The answer was not as interesting as I had hoped it was just to cut back on optimising every version of Unity to run both C# and Javascript.

I decided to push on and just finish what I started. Once the trigger was created I started the script which was easy to do, after some googling to try and remember what I was doing wrong (I forgot to declare the particle system). And the finished project.

Finished

Add a comment

Related posts:

Yesterdays and tomorrows

Some of us are not explicitly sad. We just look like this. Happiness is as bored of us as we are of it. So much so we’ve forsworn the art of bargaining with life because we’ve finally made our peace…

Dangerous Liaisons Doctors Edition

I started working as an Attending Physician in 2008. I was young, 34 years old and new to my role of teaching Palliative Care Fellows who were just a few years younger than me. The Chairman of the…

How Do We Assign Meaning to an Icon?

To assign meaning to anything it must be a culturally agreed-upon definition that parlays into symbolic representation. To assign meaning to an icon means that we can all agree on a singular image to…