Skip to content

Instantly share code, notes, and snippets.

# Load managers required by chronicle
managers = require "#{paths.shared}/managers"
{ playerManager,
spriteManager,
tileManager,
mapManager } = managers
# managers.coffee
managers =
playerManager : require 'player_manager',
spriteManager : require 'sprite_manager',
tileManager : require 'tile_manager',
mapManager : require 'map_manager'
module.exports = managers
# player_manager.coffee
module.exports = new PlayerManager()
# server.coffee
playerManager = require 'player_manager'
# map_manager.coffee
playerManager = require 'player_manager'
#world
position relative
canvas
position absolute
top 0
left 0
width 800px
height 600px
outline "1px #f00 solid"
// Generated by CoffeeScript 1.3.3
(function() {
var app, fs, handler, io;
app = require('http').createServer(handler);
io = require('socket.io').listen(app);
fs = require('fs');
app.listen(8100);
handler = function(request, response) {
return fs.readFile(__dirname + '/index.html', function(error, data) {
@clooth
clooth / marker_manager.coffee
Created August 23, 2012 20:15
Google maps utility library - MarkerManager
# This function was modeled on jQuery’s $.type
# function. (http://api.jquery.com/jQuery.type/)
# Note that, as an alternative to type checking,
# you can often use duck typing and the existential
# operator together to eliminating the need to examine
# an object’s type, in certain cases.
type = (obj) ->
if obj == undefined or obj == null
return String obj
classToType = new Object
# Process all markers in the bounds provided, using a callback
processAll: (bounds, callback) ->
for x in [bounds.minX..bounds.maxX]
for y in [bounds.minY..bounds.minX]
"foo"
@
processAll = function(bounds, callback) {
var x, y, _i, _j, _ref, _ref1, _ref2, _ref3;
# Process all markers in the bounds provided, using a callback
processAll: (bounds, callback) ->
for x in [bounds.minX..bounds.maxX]
for y in [bounds.minY..bounds.minX]
"foo"
processAll = function(bounds, callback) {
var x, y, _i, _j, _ref, _ref1, _ref2, _ref3;
for (x = _i = _ref = bounds.minX, _ref1 = bounds.maxX; _ref <= _ref1 ? _i <= _ref1 : _i >= _ref1; x = _ref <= _ref1 ? ++_i : --_i) {
# Process all markers in the bounds provided, using a callback
processAll: (bounds, callback) ->
for x in [bounds.minX..bounds.maxX]
for y in [bounds.minY..bounds.minX]
"foo"
processAll = function(bounds, callback) {
var x, y, _i, _ref, _ref1, _results;
_results = [];
class GridBounds
constructor: (bounds) ->
this.minX = Math.min(bounds[0].x, bounds[1].x)
this.maxX = Math.max(bounds[0].x, bounds[1].x)
this.minY = Math.min(bounds[0].y, bounds[1].y)
this.maxY = Math.min(bounds[0].y, bounds[1].y)