2018-03-05 15:02:13 +01:00
|
|
|
if (this.parentEntity === data.entity) {
|
|
|
|
console.log('Entity Impact Snake');
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.initialized) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do some init stuff here
|
|
|
|
*/
|
|
|
|
|
|
|
|
this.initialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We override the system init so we get a handle on our canvas instance (instead of looking it up)
|
|
|
|
*/
|
|
|
|
ig.System.inject({
|
|
|
|
init : function(canvasId, fps, width, height, scale ) {
|
|
|
|
this.fps = fps;
|
|
|
|
|
|
|
|
this.clock = new ig.Timer();
|
2018-04-10 15:48:32 +02:00
|
|
|
this.canvas = R3.EntityManager.Instance.findComponentById('2km5mzakar').instance;
|
2018-03-05 15:02:13 +01:00
|
|
|
this.resize( width, height, scale );
|
|
|
|
this.context = this.canvas.getContext('2d');
|
|
|
|
|
|
|
|
this.getDrawPos = ig.System.drawMode;
|
|
|
|
|
|
|
|
// Automatically switch to crisp scaling when using a scale
|
|
|
|
// other than 1
|
|
|
|
if( this.scale != 1 ) {
|
|
|
|
ig.System.scaleMode = ig.System.SCALE.CRISP;
|
|
|
|
}
|
|
|
|
ig.System.scaleMode( this.canvas, this.context);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
ig.module(
|
|
|
|
'game.impact-test'
|
|
|
|
)
|
|
|
|
.requires(
|
|
|
|
'impact.font',
|
|
|
|
'impact.game',
|
|
|
|
'impact.image',
|
|
|
|
'game.levels.snake'
|
|
|
|
)
|
|
|
|
.defines(function(){
|
|
|
|
|
|
|
|
// code for this module
|
|
|
|
|
|
|
|
// Create your own game class
|
|
|
|
ig.global.Snake = ig.Game.extend(
|
|
|
|
|
|
|
|
{
|
|
|
|
font: new ig.Font( 'media/04b03.font.png' ),
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
// initialize your game world, bind some
|
|
|
|
// keys, etc.
|
|
|
|
ig.input.bind( ig.KEY.SPACE, 'jump' );
|
|
|
|
|
|
|
|
console.log('init called');
|
|
|
|
this.loadLevel( LevelSnake );
|
|
|
|
},
|
|
|
|
|
|
|
|
draw : function() {
|
|
|
|
texture.instance.needsUpdate = true;
|
|
|
|
this.parent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-04-10 15:48:32 +02:00
|
|
|
var size = R3.Utils.GetWindowSize();
|
2018-03-05 15:02:13 +01:00
|
|
|
|
|
|
|
// Start your game
|
|
|
|
// 60fps, 320x240 pixels, scaled up by a factor of 2
|
|
|
|
ig.main('#noid', Snake, 60, 64 * 16, 64*16, 1 );
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
//@ sourceURL=entityLoaded.js
|