View ImpactJS.JSON-tmLanguage
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" | |
}, |
View followCamera.js
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; | |
} | |
}, |
View enableBehaviors.js
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({ |
View baseBehavior.js
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, |
View player.js
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); | |
}, |
View eventChain.js
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. |
View eventChain.js
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. |
View eventChain.js
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; | |
} |
View eventChain.js
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(); |
View eventChain.js
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