Skip to content

Instantly share code, notes, and snippets.

@ekelokorpi
Created December 6, 2017 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekelokorpi/de8413dd1d499644af0774314adabbe6 to your computer and use it in GitHub Desktop.
Save ekelokorpi/de8413dd1d499644af0774314adabbe6 to your computer and use it in GitHub Desktop.
game.module(
'game.main'
)
.body(function() {
game.createScene('Main', {
init: function() {
this.mob = new game.Mob();
this.mob.gfx.addTo(this.stage);
},
keydown: function(key, shift, ctrl, alt) {
if (key === 'DOWN') {
this.mob.move();
}
if (key === 'UP') {
}
if (key === 'RIGHT') {
}
if (key === 'LEFT') {
}
}
});
game.createClass('Mob', {
init: function() {
this.gfx = new game.Graphics();
this.gfx.fillColor = '#ff0000';
this.gfx.x = 20;
this.gfx.y = 20;
this.gfx.drawRect(0, 0, 25, 25);
},
move: function() {
this.gfx.y += 20;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment