This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var propertyValue = function(obj, key, separator = '.') { | |
var keyArray = key.split(separator); | |
var result = obj; | |
for (var i = 0, j = keyArray.length; i < j; i++) { | |
(function(name) { | |
result = result[name]; | |
})(keyArray[i]); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var modules = {}; | |
var require = function(name) { | |
var globals = Object.keys(window); | |
if (Object.keys(modules).length !== globals.length) { | |
globals.forEach(function(item) { | |
if (!Object.hasOwnProperty.call(modules, item)) { | |
modules[item] = window[item]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var normalize = function(path, delimiter) { | |
if (delimiter == null) { | |
delimiter = '/'; | |
} | |
var pathArr = path.split(delimiter); | |
var newPath = []; | |
for (var i = 0, j = pathArr.length; i < j; i++) { | |
(function(item) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GameObject | |
constructor: -> | |
@x = 0 | |
@y = 0 | |
@behaviors = {} | |
andObject = @ | |
@move = (x, y) => | |
@x += x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Behavior | |
constructor: (descriptor) -> | |
mixedice [@, @::], new EventMap() | |
@type = 'Behavior' | |
@name = "#{@type}-#{Date.now()}" | |
@children = {} | |
@parent = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Observable | |
constructor: (data) -> | |
@changes = [] | |
Object.defineProperty @, 'data', | |
get: -> data | |
set: (value) -> | |
data = value | |
i() for i in @changes | |
value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('tilemap', function() { | |
var TileMap = (function() { | |
var TileMap = function(width, height) { | |
if (width == null) { | |
width = { | |
min: 0, | |
max: 4 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require = (name) -> | |
if Object.hasOwnProperty.call require.cache, name | |
moduleExp = require.cache[name].module.exports | |
exportObj = require.cache[name].exports | |
else | |
moduleObj = {} | |
exportObj = {} | |
require.modules[name].apply(this, [require, moduleObj, exportObj]); | |
require.cache[name] or= {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EventMap | |
{ | |
public delegate void SenderEvent(object sender); | |
public delegate void Event(); | |
protected Dictionary<String, ArrayList> events; | |
public object Sender { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TextureManager | |
constructor: -> | |
@textures = {} | |
load: (texture, callback) -> | |
texture = [texture] unless Array.isArray texture | |
textures = @textures | |
promises = for t in texture | |
(cb) -> |