1 decade ago by Warspawn
Here is a star field background class I made. It uses the context to draw the stars dynamically. gist
This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact
// main.js
ig.module('game.main')
.requires(
'impact.debug.debug',
'impact.game',
'game.starfield'
)
.defines(function() {
SpaceBlasterGame = ig.Game.extend({
version: '1.0',
font: new ig.Font( 'media/04b03.font.png' ),
init: function() {
this.backgroundMaps.push(
new Starfield(250, {vel: {x: 0, y: 100}}),
new Starfield(150, {vel: {x: 0, y: 200}}),
new Starfield(550, {vel: {x: 0, y: 20}})
);
},
update: function() {
this.parent();
for(var i=0;i<this.backgroundMaps.length;i++) {
if(this.backgroundMaps[i].update) {
this.backgroundMaps[i].update();
}
}
},
draw: function() {
this.parent();
this.font.draw( 'Version: ' + this.version, 8, ig.system.height - 8, ig.Font.ALIGN.LEFT );
}
});
ig.main('#canvas', SpaceBlasterGame, 60, 600, 800, 1);
});
Quote from Warspawn
is the Entity prefix some sort of required naming convention that WM looks for or something? I'm new to ImpactJS and don't know.
EntityStarfield. But since it&039;s not an entity, but rather a #backgroundMap, don't worry about it.