|
|
|
@ -29,7 +29,7 @@ Q.Sprite.extend("Player",{
|
|
|
|
|
|
|
|
|
|
// You can call the parent's constructor with this._super(..)
|
|
|
|
|
this._super(p, {
|
|
|
|
|
sheet: "player", // Setting a sprite sheet sets sprite width and height
|
|
|
|
|
sheet: "astronaut", // Setting a sprite sheet sets sprite width and height
|
|
|
|
|
x: 410, // You can also set additional properties that can
|
|
|
|
|
y: 90 // be overridden on object creation
|
|
|
|
|
});
|
|
|
|
@ -69,9 +69,41 @@ Q.Sprite.extend("Tower", {
|
|
|
|
|
|
|
|
|
|
// ## Enemy Sprite
|
|
|
|
|
// Create the Enemy class to add in some baddies
|
|
|
|
|
Q.Sprite.extend("Enemy",{
|
|
|
|
|
Q.Sprite.extend("Neingeist",{
|
|
|
|
|
init: function(p) {
|
|
|
|
|
this._super(p, { sheet: 'enemy', vx: 100 });
|
|
|
|
|
this._super(p, { sheet: 'neingeist', vx: 100 });
|
|
|
|
|
|
|
|
|
|
// Enemies use the Bounce AI to change direction
|
|
|
|
|
// whenver they run into something.
|
|
|
|
|
this.add('2d, aiBounce');
|
|
|
|
|
|
|
|
|
|
// Listen for a sprite collision, if it's the player,
|
|
|
|
|
// end the game unless the enemy is hit on top
|
|
|
|
|
this.on("bump.left,bump.right,bump.bottom",function(collision) {
|
|
|
|
|
if(collision.obj.isA("Player")) {
|
|
|
|
|
Q.stageScene("endGame",1, { label: "You Died" });
|
|
|
|
|
collision.obj.destroy();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// If the enemy gets hit on the top, destroy it
|
|
|
|
|
// and give the user a "hop"
|
|
|
|
|
this.on("bump.top",function(collision) {
|
|
|
|
|
if(collision.obj.isA("Player")) {
|
|
|
|
|
this.destroy();
|
|
|
|
|
collision.obj.p.vy = -300;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME do not copy
|
|
|
|
|
// ## Enemy Sprite
|
|
|
|
|
// Create the Enemy class to add in some baddies
|
|
|
|
|
Q.Sprite.extend("Starbug",{
|
|
|
|
|
init: function(p) {
|
|
|
|
|
this._super(p, { sheet: 'starbug', vx: 100 });
|
|
|
|
|
|
|
|
|
|
// Enemies use the Bounce AI to change direction
|
|
|
|
|
// whenver they run into something.
|
|
|
|
@ -118,8 +150,8 @@ Q.scene("level1",function(stage) {
|
|
|
|
|
stage.add("viewport").follow(player);
|
|
|
|
|
|
|
|
|
|
// Add in a couple of enemies
|
|
|
|
|
stage.insert(new Q.Enemy({ x: 700, y: 0 }));
|
|
|
|
|
stage.insert(new Q.Enemy({ x: 800, y: 0 }));
|
|
|
|
|
stage.insert(new Q.Neingeist({ x: 700, y: 0 }));
|
|
|
|
|
stage.insert(new Q.Starbug({ x: 800, y: 0 }));
|
|
|
|
|
|
|
|
|
|
// Finally add in the tower goal
|
|
|
|
|
stage.insert(new Q.Tower({ x: 180, y: 50 }));
|
|
|
|
|