Example #1
0
                        _.each(players, function (player) {
                            var trail = player.getTrail(),

                                // The number of trail points to look at when collision detecting before stopping. For
                                // any other player this i trail.length, but for the current player we skip the most
                                // newly created trail points to avoid crashing into ourselves right at the start. See
                                // the docstring for _trail_touch_distance
                                stop_at = player !== that ? trail.length : Math.max(-1, trail.length - _trail_touch_distance);

                            // Loop over the trail points checking the distance between our head and the points,
                            // pushing any found collisions to the list collisions
                            _.some(trail, function (point, index) {
                                if (index >= stop_at) {
                                    return true; // Simulate a "break;"
                                }

                                // Only consider points that are not holes. Since the most forward point could be a hole
                                // this can lead to "jumping" over other players if one is really lucky and starts a hole
                                // just before a collision. This is not a bug - it's a feature!
                                if (!point.h) {
                                    var distance = Math.sqrt(Math.pow(_x - point.x,2) + Math.pow(_y - point.y,2));

                                    if (distance <= settings.LINE_SIZE) {
                                        collisions.push(distance);
                                    }
                                }
                            });
                        });
Example #2
0
domjs.parse(loadConfig, function(err, dom) {

    var i;

    for(i in dom.children) {
        if(dom.children[i].name == configs.childName) {
            if(typeof dom.children[i].attributes[configs.platformAttribute] !== 'undefined') {

                var iconName 	= path.basename(dom.children[i].attributes['src']);
                var pl 			= dom.children[i].attributes[configs.platformAttribute];

                var configData = _.findWhere(configs.data,{'filename':iconName})
                if(typeof configData !== 'undefined') {
                    var platfromExists = _.some(configs.data, function (item) {
                        if(item.plattform == pl) return item;

                        return false;
                    });

                    if(!platfromExists)
                        continue;

                    try {
                        var pathx 		= typeof configData.folder == "undefined"  ? path.resolve(dPath,configs.directory,pl) : path.resolve(dPath,configs.directory,configData.folder);
                        var destPath 	= path.resolve(pathx,iconName);
                        var dirStat = fs.lstatSync(pathx);
                    } catch (e) {
                        if(e.code == 'ENOENT') {
                            mkdirp.sync(pathx);
                        }
                    }

                    sizes = configData.size.split('x');
                    try {
                        ig.resize({
                            srcPath: icon,
                            dstPath: destPath,
                            quality: 1,
                            format: 'png',
                            width: sizes[0],
                            height: sizes[1],
                        },function(err, stdout, stderr){
                            if (err) throw err;
                        });
                        console.log(destPath+' created');
                    }catch (e) {
                        console.error(e.code);
                    }


                }
            }
        }
    }
});
Example #3
0
 isAdminOfSomeEvent: function() {
     return _.some(this.adminCache, function(v) { return v; });
 },
Example #4
0
 userIsAdmin: function(user) {
     return _.some(this.models, function(event) {
         return event.userIsAdmin(user);
     });
 }
Example #5
0
 userIsAdmin: function(user) {
     var admins = this.get("admins");
     return _.some(admins, _.bind(function(admin) {
         return this.adminMatchesUser(admin, user);
     }, this));
 },