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
{ "name": "ImpactJS", "scopeName": "source.js.impact", | |
"fileTypes": ["js"], | |
"patterns": [ | |
{ | |
"name": "meta.module.impact", | |
"begin": "\\b(ig)\\.(module)\\(", | |
"beginCaptures": { | |
"1": { | |
"name": "support.variable.impact.namespace" | |
}, |
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
calculatePlayerStats: function() { | |
this.player = ig.game.getEntityByName('player'); | |
// Did we actually get a player? | |
if (this.player) { | |
// Cache some stats. | |
this.halfPlayerWidth = this.player.size.x / 2; | |
this.halfPlayerHeight = this.player.size.y / 2; | |
this.maxVel = this.player.maxVel; | |
} | |
}, |
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
ig.module( | |
'game.behaviors.enableBehaviors' | |
) | |
.requires( | |
'impact.impact' | |
) | |
.defines(function() { | |
enableBehaviors = function(entityClass) { | |
entityClass.inject({ |
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
ig.module( | |
'game.behaviors.baseBehavior' | |
) | |
.requires( | |
'impact.impact' | |
) | |
.defines(function() { | |
BaseBehavior = ig.Class.extend({ | |
enabled: true, |
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
update: function() { | |
this.behave('update'); | |
this.handleAnimation(); | |
this.parent(); | |
}, | |
handleMovementTrace: function(res) { | |
this.behave('handleMovementTrace', res); | |
this.parent(res); | |
}, |
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
/*global ig: true */ | |
ig.module( | |
'game.system.eventChain' | |
) | |
.requires( | |
'impact.impact' | |
) | |
.defines(function() { | |
// Defines a function that can fire sequential events. |
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
// Defines a function that can fire sequential events. | |
EventChain = function() { | |
// Make sure we get called with new. | |
if (this === window) { | |
return new EventChain(); | |
} | |
var steps = []; | |
// Called every frame. |
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
update.then = function(doThis) { | |
steps.push(function() { | |
// Update. | |
doThis(); | |
// End. | |
steps.shift(); | |
}); | |
return this; | |
} |
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
update.wait = function(secs) { | |
var decrement = secs; | |
steps.push(function() { | |
// Update. | |
if (decrement) { | |
decrement -= ig.system.tick; | |
} | |
// End. | |
if (decrement <= 0) { | |
steps.shift(); |
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
update.during = function(doThis) { | |
if (!steps) { | |
throw new Error('during only works with previous step!'); | |
} | |
var func = steps[steps.length - 1]; | |
steps[steps.length - 1] = function() { | |
doThis(); | |
func(); | |
}; | |
return this; |
OlderNewer