Skip to content

Instantly share code, notes, and snippets.

@ruby0x1
ruby0x1 / ServerSession.js
Created March 27, 2012 14:55
Multi-player games in HTML5 : Server Side Session Class
var Session = Class.extend({
init : function( socket ) {
this.socket = socket;
this.serverid = UUID();
this.initListeners();
},
@ruby0x1
ruby0x1 / Ball.js
Created March 27, 2012 14:57
Multi-player games in HTML5 : Client Side Ball Class
var Ball = Class.extend({
init : function( attachTo ) {
//Create meshes
this.setupBall();
//Store the speed value
this.speed = 100;
@ruby0x1
ruby0x1 / ServerClass.js
Created March 27, 2012 14:54
Multi-player games in HTML5 : Server Side Server Class
var Server = Class.extend({
init : function( ) {
this.connections = [];
this.games = [];
},
addConnection : function( connection ) {
@ruby0x1
ruby0x1 / Server.js
Created March 27, 2012 14:55
Multi-player games in HTML5 : Socket.io on the server side with session
io.sockets.on('connection', function (socket) {
//create a new player, which registers its events
var connection = new Session( socket );
//add to the list of connections (for finding a game)
server.addConnection( connection );
//This will send a message to all clients saying that they connected,
//And hand them their serverid for future interactions.
socket.emit('onConnect', { serverid : connection.serverid });
@ruby0x1
ruby0x1 / Ball.js
Created March 27, 2012 14:56
Multi-player games in HTML5 : Server Side Ball Class
var Ball = Class.extend({
init : function( attachTo, isServer ) {
//Only create meshes on the client side
if( !isServer ) {
//Create meshes
this.setupBall( );
@ruby0x1
ruby0x1 / Player.js
Created March 27, 2012 14:57
Multi-player games in HTML5 : Client Side Player Class
var Player = Class.extend({
init : function( remoteConnection ) {
//The opponent we are storing is actually the socket for the player connection to socket.io
this.connection = remoteConnection || false;
//Create the mesh and set the positions for the player on screen
this.setupPaddle();
@ruby0x1
ruby0x1 / scriptCore.h
Created March 30, 2012 15:52
An example of the new script binding in Laboratory2D (header)
/*
Copyright (C) 2011 by Underscore Discovery, Sven "FuzzYspo0N" Bergstrom ( http://underscorediscovery.com )
For more license information, please read the following
http://laboratory2D.com/#/license
The license is MIT based, the MIT license is appended to the file.
*/
@ruby0x1
ruby0x1 / scriptCore.cpp
Created March 30, 2012 15:52
An example of the new script binding in Laboratory2D (source)
/*
Copyright (C) 2011 by Underscore Discovery, Sven "FuzzYspo0N" Bergstrom ( http://underscorediscovery.com )
For more license information, please read the following
http://laboratory2D.com/#/license
The license is MIT based, the MIT license is appended to the file.
*/
@ruby0x1
ruby0x1 / TexturePackerJSON.hx
Created November 19, 2012 18:31
JSON TexturePacker importer for Haxenme haxelib SpriteSheet, with behavior and examples
package com.underscorediscovery;
import com.eclecticdesignstudio.spritesheet.data.SpriteSheetFrame;
import com.eclecticdesignstudio.spritesheet.SpriteSheet;
import com.eclecticdesignstudio.spritesheet.data.BehaviorData;
import hxjson2.JSON;
class TexturePackerJSON {
@ruby0x1
ruby0x1 / gist:dae2c19b4244ea9c4549
Created November 11, 2015 23:53
WebGL drawArrays 64k limit
Chrome Version 46.0.2490.80 (64-bit)
Frame 965 errors:
VM143:9918 ----------------------
VM143:9924 INVALID_OPERATION <= drawArrays(TRIANGLES, 0, 65760)
[GroupMarkerNotSet(crbug.com/242999)!:D0EE0516CE7F0000]GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 1