• Stars
    star
    1,033
  • Rank 43,504 (Top 0.9 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

How to build an outrun-style racing game in javascript

Javascript Pseudo 3D Racer

An Outrun-style pseudo-3d racing game in HTML5 and Javascript

Incrementally built up in 4 parts:

With detailed descriptions of how each part works:

A note on performance

The performance of this game is very machine/browser dependent. It works quite well in modern browsers, especially those with GPU canvas acceleration, but a bad graphics driver can kill it stone dead. So your mileage may vary. There are controls provided to change the rendering resolution and the draw distance to scale to fit your machine.

Currently supported browsers include:

  • Firefox (v12+) works great, 60fps at high res - Nice!
  • Chrome (v19+) works great, 60fps at high res... provided you dont have a bad GPU driver
  • IE9 - ok, 30fps at medium res... not great, but at least it works

The current state of mobile browser performance is pretty dismal. Dont expect this to be playable on any mobile device.

NOTE: I havent actually spent anytime optimizing for performance yet. So it might be possible to make it play well on older browsers, but that's not really what this project is about.

A note on code structure

This project happens to be implemented in javascript (because its easy for prototyping) but is not intended to demonstrate javascript techniques or best practices. In fact, in order to keep it simple to understand it embeds the javascript for each example directly in the HTML page (horror!) and, even worse, uses global variables and functions (OMG!).

If I was building a real game I would have much more structure and organization to the code, but since its just a racing game tech demo, I have elected to KISS.

FUTURE

It's quite astounding what it takes to actually finish a game, even a simple one. And this is not a project that I plan on polishing into a finished state. It should really be considered just how to get started with a pseudo-3d racing game.

If we were to try to turn it into a real game we would have to consider:

  • car sound fx
  • better synchronized music
  • full screen mode
  • HUD fx (flash on fastest lap, confetti, color coded speedometer, etc)
  • more accurate sprite collision
  • better car AI (steering, braking etc)
  • an actual crash when colliding at high speed
  • more bounce when car is off road
  • screen shake when off-road or collision
  • throw up dirt particles when off road
  • more dynamic camera (lower at faster speed, swoop over hills etc)
  • automatic resolution & drawDistance detection
  • projection based curves ? x,y rotation
  • sub-pixel aliasing artifacts on curves
  • smarter fog to cover sprites (blue against sky, cover sprites)
  • multiple stages, different maps
  • a lap map, with current position indicator
  • road splits and joins
  • day/night cycle
  • weather effects
  • tunnels, bridges, clouds, walls, buildings
  • city, desert, ocean
  • add city of seattle and space needle to background
  • 'bad guys' - add some competetor drivers to race against as well as the 'traffic'
  • different game modes - fastest lap, 1-on-1 racing, collect coins ? shoot bad guys ?
  • a whole lot of gameplay tuning
  • ...
  • ...

Related Links

License

MIT license.

NOTE: the music tracks included in this project are royalty free resources paid for and licensed from Lucky Lion Studios. They are licensed ONLY for use in this project and should not be reproduced.

NOTE: the sprite graphics are placeholder graphics borrowed from the old genesis version of outrun and used here as teaching examples. If there are any pixel artists out there who want to provide original art to turn this into a real game please get in touch!

More Repositories

1

javascript-state-machine

A javascript finite state machine library
JavaScript
8,661
star
2

bin-packing

A javascript binary tree based algorithm for 2d bin-packing suitable for generating CSS sprites
JavaScript
628
star
3

sprite-factory

Automatic CSS Sprite Generator
Ruby
620
star
4

javascript-tetris

A simple javascript tetris game
HTML
586
star
5

javascript-pong

A javascript version of the classic 1972 arcade game Pong!
JavaScript
202
star
6

javascript-tiny-platformer

A very minimal javascript platform game
JavaScript
172
star
7

javascript-gauntlet

An HTML5 Gauntlet-style game
JavaScript
155
star
8

javascript-audio-fx

A Simple HTML5 Audio Helper Library
JavaScript
111
star
9

javascript-boulderdash

An HTML5 implementation of the c64 classic Boulderdash game
JavaScript
103
star
10

javascript-snakes

An HTML5 Snakes Game
HTML
95
star
11

javascript-tower-platformer

A prototype for an html5 rotating tower platformer game
JavaScript
86
star
12

javascript-breakout

An HTML5 canvas implementation of breakout
JavaScript
72
star
13

rack-rabbit

A Unicorn-style forking server for hosting rabbitMQ consumers as load balanced Rack apps
Ruby
62
star
14

javascript-starfield

An old school 2d starfield using HTML5 <canvas>
JavaScript
46
star
15

javascript-delta

An HTML5 javascript shoot em up in the style of the old c64 classic game "Delta"
JavaScript
43
star
16

ruby-sample-daemon

A simple example of daemonizing a long running Ruby process
Ruby
13
star
17

tetris-shoes

A Tetris game in Ruby Shoes
Ruby
5
star
18

javascript-stutter

Can anyone make this minimalist canvas animation smooth ?
JavaScript
3
star
19

dotfiles

Personal dotfiles
Vim Script
2
star
20

sprite-factory-and-rails31

Experimenting with sprite-factory and the rails 3.1 asset pipeline
Ruby
2
star
21

snowpack-coverage-bug

Reproducing a snowpack/web-test-runner coverage issue
JavaScript
1
star
22

unified-assets

Easily unify and minify static javascript and css assets
Ruby
1
star
23

ruby-serializer

Declarative serialization of PORO's to JSON
Ruby
1
star
24

vue-template-brunch

Adds support to Brunch for pre-compiling standalone (NOT single-file) vue templates.
JavaScript
1
star