This is a remake of Pong for an exhibition the company I work for, Luxus, organized.
The reason for the project was to teach me about node, canvas and websockets. And it was really fun!
The game itself runs server side, two handsets function as controllers and a browser (or several) as the projection. The state of the game is pushed to the projection(s) on every tick. The controllers notify the server whenever speed changes. Messaging is done over a WebSocket connection.
The code isn't very beautiful, lacks comments, and supporting several versions of the WebSocket required adding a hackish tier to the connection handling. But it worked well enough and got the job done. Bugs will be present.
There is no running instance of this game, and likely never will be. This was a one-off concept demo which was tons of fun, but will not be maintained or further developed/cleaned up. (Unless you fork it ;-)
git clone git@github.com:nikcorg/Pong.git pong
cd pong
npm install
node miksago-ws-server.js
will run the server- open
http://your.box.com/public/client.html
in a browser - open
http://your.box.com/public/controller.html
in a mobile phone browser- NB! By default you need two players, to play alone in
miksago-ws-server.js:131
setplayAlone = true
.
- NB! By default you need two players, to play alone in
How I created a Pong-clone using Node.js, Canvas, WebSocket and DeviceOrientation.