diff --git a/asset/sprites-src/martin.gif b/asset/sprites-src/martin.gif new file mode 100644 index 0000000..d60379b Binary files /dev/null and b/asset/sprites-src/martin.gif differ diff --git a/asset/sprites-src/martin.png b/asset/sprites-src/martin.png new file mode 100644 index 0000000..93763f7 Binary files /dev/null and b/asset/sprites-src/martin.png differ diff --git a/asset/sprites-src/martin01.xcf b/asset/sprites-src/martin01.xcf new file mode 100644 index 0000000..ec75deb Binary files /dev/null and b/asset/sprites-src/martin01.xcf differ diff --git a/asset/sprites/martin01.png b/asset/sprites/martin01.png new file mode 100644 index 0000000..fe368b5 Binary files /dev/null and b/asset/sprites/martin01.png differ diff --git a/data/sprites.json b/data/sprites.json index 8726fa6..a7562ee 100644 --- a/data/sprites.json +++ b/data/sprites.json @@ -1 +1 @@ -{"astronaut":{"sx":0,"sy":1,"cols":1,"tilew":24,"tileh":24,"frames":1},"neingeist":{"sx":0,"sy":26,"cols":1,"tilew":24,"tileh":24,"frames":1},"rocket":{"sx":0,"sy":51,"cols":1,"tilew":26,"tileh":52,"frames":1},"starbug":{"sx":0,"sy":104,"cols":1,"tilew":24,"tileh":24,"frames":1}} \ No newline at end of file +{"astronaut":{"sx":0,"sy":1,"cols":1,"tilew":24,"tileh":24,"frames":1},"martin":{"sx":0,"sy":26,"cols":1,"tilew":24,"tileh":24,"frames":1},"neingeist":{"sx":0,"sy":51,"cols":1,"tilew":24,"tileh":24,"frames":1},"rocket":{"sx":0,"sy":76,"cols":1,"tilew":26,"tileh":52,"frames":1},"starbug":{"sx":0,"sy":129,"cols":1,"tilew":24,"tileh":24,"frames":1}} \ No newline at end of file diff --git a/images/sprites.png b/images/sprites.png index 3262409..624a0a1 100644 Binary files a/images/sprites.png and b/images/sprites.png differ diff --git a/platformer.js b/platformer.js index b157e91..971fc5b 100644 --- a/platformer.js +++ b/platformer.js @@ -94,7 +94,6 @@ Q.Sprite.extend("Neingeist",{ } }); - // FIXME do not copy // ## Enemy Sprite // Create the Enemy class to add in some baddies @@ -126,6 +125,37 @@ Q.Sprite.extend("Starbug",{ } }); +// FIXME do not copy +// ## Enemy Sprite +// Create the Enemy class to add in some baddies +Q.Sprite.extend("Martin",{ + init: function(p) { + this._super(p, { sheet: 'martin', 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: "DU BIST TOT" }); + 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; + } + }); + } +}); + // ## Level1 scene // Create a new scene called level 1 Q.scene("level1",function(stage) { @@ -152,6 +182,7 @@ Q.scene("level1",function(stage) { // Add in a couple of enemies stage.insert(new Q.Starbug({ x: 600, y: 0 })); stage.insert(new Q.Neingeist({ x: 650, y: 0 })); + stage.insert(new Q.Martin({ x: 550, y: 0 })); stage.insert(new Q.Rocket({ x: 146, y: 32 })); });