Skip to content

Instantly share code, notes, and snippets.

@cykod
Created January 30, 2013 13:05
Show Gist options
  • Save cykod/4673169 to your computer and use it in GitHub Desktop.
Save cykod/4673169 to your computer and use it in GitHub Desktop.
Quintus: Change homepage demo to top-down - replace Player sprite with:
Q.gravityY = 0;
Q.Sprite.extend("Player",{
init: function(p) {
this._super(p, { sheet: "player", x: 410, y: 90 });
this.add('2d');
this.on("hit.sprite",function(collision) {
if(collision.obj.isA("Tower")) {
Q.stageScene("endGame",1, { label: "You Won!" });
this.destroy();
}
});
},
step: function(dt) {
if(Q.inputs['up']) { this.p.vy = -200; }
else if(Q.inputs['down']) { this.p.vy = 200; }
if(Q.inputs['left']) { this.p.vx = -200; }
else if(Q.inputs['right']) { this.p.vx = 200; }
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment