Talking about 2 Cars game, 3D, Game development and Javascript.
Do you remember “2 Cars” tutorial series? It’s a series published about 4 years ago, based on an old Ketchapp game which is no longer available, as far as I can see.
Never mind, we are going to rebuild it using Buildbox and (almost) no code.
In the original game you control two cars at the same time: one at the left of the stage, and one on the right. You can make cars change lane by tapping the screen: a tap on the left half of the screen will make the left car change lane, and a tap on the right half of the screen will make the right car change lane.
Play this prototype I built with Phaser to see how the game works.
And look at this video below to see what I was able to create with Buildbox and just a few lines of code:
How was I able to do this with Buildbox?
First, there’s a fake player running below the ground which is followed by the camera:
The fake player – which actually is the real player, but not playing as part of the game – is the ball running below the floor, with the camera following it.
Blue and red spaceships are just two objects. There is also a UI Screen with two big control buttons covering the left and right half of the screen:
Then each spaceship has its own control button listener in the Node map, with a little script to decide whether to move left or right, then another script to round the final position:
This is the script for input management of the right spaceship:
function signal(name, value){
if(value){
let position = this.entity().position();
if(position.x == -6){
this.emitSignal("Move Left", true)
}
if(position.x == -2){
this.emitSignal("Move Right", true)
}
}
}
And this is the script to round the final position:
function signal(name, value){
if(value){
let entity = this.entity();
let position = entity.position();
entity.setPosition(Math.round(position.x), position.y, position.z);
}
}
The same concept applies to left spaceship. During next step we’ll dive more in detail and add some obstacles to avoid and coins to pick up, meanwhile download the full project and have fun with almost no code.
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.