From cd11a8485e32b2d3ff4e63e57826b23ba238f1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20M=C3=BCller?= Date: Thu, 25 Apr 2013 22:18:37 +0200 Subject: [PATCH] Score stuff and more polish awesomeness --- dev/lib/game/entities/ball.js | 2 +- dev/lib/game/entities/goal.js | 2 +- dev/lib/game/entities/paddle-player.js | 27 ++++++++++++++++++++++---- dev/lib/game/main.js | 3 +-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/dev/lib/game/entities/ball.js b/dev/lib/game/entities/ball.js index 60d2c76..f25878f 100644 --- a/dev/lib/game/entities/ball.js +++ b/dev/lib/game/entities/ball.js @@ -45,7 +45,7 @@ ig.module( // TODO: Moooar points on speed balls // TODO: Moar points on edge hits - if (other.name == 'paddle-player') ig.global.score += 20; + if (other.name == 'paddle-player') ig.global.score += 50; this.hitSounds[Math.floor(Math.random()*4)].play(); } }, diff --git a/dev/lib/game/entities/goal.js b/dev/lib/game/entities/goal.js index 1335c5c..9aec194 100644 --- a/dev/lib/game/entities/goal.js +++ b/dev/lib/game/entities/goal.js @@ -19,7 +19,7 @@ ig.module( if (other.name == 'ball') { console.log(this.owner); if (this.owner == 'player') ig.global.lifes -= 1; - if (this.owner == 'ai') ig.global.score += 2000; + if (this.owner == 'enemy') ig.global.score += 2000; other.reset(); this.looseSound.play(); } diff --git a/dev/lib/game/entities/paddle-player.js b/dev/lib/game/entities/paddle-player.js index d834546..50de03b 100644 --- a/dev/lib/game/entities/paddle-player.js +++ b/dev/lib/game/entities/paddle-player.js @@ -2,14 +2,34 @@ ig.module( 'game.entities.paddle-player' ) .requires( - 'game.entities.paddle' + 'impact.entity' ) .defines(function(){ - EntityPaddlePlayer = EntityPaddle.extend({ + EntityPaddlePlayer = ig.Entity.extend({ + size: {x: 30, y: 120}, + collides: ig.Entity.COLLIDES.FIXED, + type: ig.Entity.TYPE.A, + name: 'paddle-player', - animSheet: new ig.AnimationSheet('media/paddle-player.png', 30, 120), + animSheet: new ig.AnimationSheet('media/paddle-player_sheet.png', 30, 120), + + maxVel: {x: 0, y: 400}, + + init: function(x, y, settings) { + this.parent(x, y, settings); + + this.addAnim('idle', 1, [0]); + this.addAnim('lives4', 1, [0]); + this.addAnim('lives3', 1, [1]); + this.addAnim('lives2', 1, [2]); + this.addAnim('lives1', 1, [3]); + this.addAnim('lives0', 1, [4]); + }, update: function(){ + this.currentAnim = + this.anims['lives'+ig.global.lifes]; + if (ig.input.state('up')) { this.vel.y = -400; } else if (ig.input.state('down')) { @@ -26,4 +46,3 @@ ig.module( } }); }); - diff --git a/dev/lib/game/main.js b/dev/lib/game/main.js index dd9cf55..2c20425 100755 --- a/dev/lib/game/main.js +++ b/dev/lib/game/main.js @@ -83,8 +83,7 @@ draw: function() { ig.system.context.clearRect( 0 ,0, ig.system.realWidth, ig.system.realHeight ); this.parent(); // Draw entries and background - this.font.draw(ig.global.score, 237, 8, ig.Font.ALIGN.LEFT); - this.font.draw(ig.global.lifes, 550, 0, ig.Font.ALIGN.RIGHT); + this.font.draw(ig.global.score, 390, 8, ig.Font.ALIGN.RIGHT); if (this.showPause) { if(this.pauseDialogAlpha < 1) {