Vector Racer 0.2

Vector Racer 0.2 – #winning

Vector Racer 0.2 is out! And I’m glad to say that I’ve solved the two primary issues in version 0.1:

  • Detecting collisions if the player path crosses an obstacle
  • Determining when a player does a lap

So now, you are actually able to win the game! And you are able to determine if you’re better than your buddy since the number of steps are declared upon crossing the finish line.

My record is 42(!). What’s yours?


Better collision-detection

Second issue was that collision was only detected where the player ‘landed’ at each step. Given enough speed, it was easy to drive right through obstacles.

I’ve added collision details to three extra points between two positions, making it hard to drive through obstacles but still allowing for cutting a few corners.

Here’s the concept. Finding the mid-point between the old and new position:

Vector split
Finding the mid-point between two points is an easy way to increase resolution.

And how the code looks. Not very generalized.

var vectorSplit = function(start, end) {
  var splits = [];
  var mid = { x:((end.x - start.x) / 2) + start.x, y:((end.y - start.y) / 2) + start.y };
  var start_mid = { x:((mid.x - start.x) / 2) + start.x, y:((mid.y - start.y) / 2) + start.y };
  var mid_end = { x:((end.x - mid.x) / 2) + mid.x, y:((end.y - mid.y) / 2) + mid.y };

I guess the right way to do it would be something along the line of Bresenham’s line algorithm but that’s not going to happen anytime soon.

To Do

The most pressing issues going forward is:

  • Implement UI for mobile(who uses laptops for casual gaming anymore?)
  • Add UI response during the selection process.
  • Add information area for things like laps, steps etc.