diff --git a/dev/lib/game/entities/goal.js b/dev/lib/game/entities/goal.js index f80a89b..855371c 100644 --- a/dev/lib/game/entities/goal.js +++ b/dev/lib/game/entities/goal.js @@ -5,23 +5,21 @@ ig.module( 'impact.entity' ) .defines(function(){ + EntityGoal = ig.Entity.extend({ + height: 90, + size: {x:48, y:48}, + checkAgainst: ig.Entity.TYPE.B, -EntityGoal = ig.Entity.extend({ + _wmScalable: true, + _wmDrawBox: true, + _wmBoxColor: '#00ff00', - height: 90, - - size: {x:48, y:48}, - checkAgainst: ig.Entity.TYPE.B, - - _wmScalable: true, - _wmDrawBox: true, - _wmBoxColor: '#00ff00', - - check: function( other ) { - if(other.name == 'ball') { - other.reset(); - } - } + check: function(other) { + if (other.name == 'ball') { + ig.game.score[this.owner] -= 1; + other.reset(); + } + } + }); }); -}); diff --git a/dev/lib/game/entities/paddle.js b/dev/lib/game/entities/paddle.js index 240f955..b8717f0 100644 --- a/dev/lib/game/entities/paddle.js +++ b/dev/lib/game/entities/paddle.js @@ -9,6 +9,7 @@ ig.module( EntityPaddle = ig.Entity.extend({ name: 'paddle', + scores: 0, size: {x: 30, y: 96}, collides: ig.Entity.COLLIDES.FIXED, diff --git a/dev/lib/game/levels/level1.js b/dev/lib/game/levels/level1.js old mode 100644 new mode 100755 index 0e3402f..abee595 --- a/dev/lib/game/levels/level1.js +++ b/dev/lib/game/levels/level1.js @@ -1,6 +1,6 @@ ig.module( 'game.levels.level1' ) .requires( 'impact.image','game.entities.paddle-enemy','game.entities.paddle-player','game.entities.ball','game.entities.goal' ) .defines(function(){ -LevelLevel1=/*JSON[*/{"entities":[{"type":"EntityPaddleEnemy","x":56,"y":148},{"type":"EntityPaddlePlayer","x":536,"y":148},{"type":"EntityBall","x":300,"y":184},{"type":"EntityGoal","x":600,"y":48,"settings":{"size":{"x":24,"y":288}}},{"type":"EntityGoal","x":0,"y":48,"settings":{"size":{"x":24,"y":288}}}],"layer":[{"name":"bg","width":3,"height":2,"linkWithCollision":false,"visible":1,"tilesetName":"media/bg.png","repeat":false,"preRender":false,"distance":"1","tilesize":250,"foreground":false,"data":[[1,1,1],[1,1,1]]},{"name":"board","width":13,"height":8,"linkWithCollision":false,"visible":1,"tilesetName":"media/tileset.png","repeat":false,"preRender":false,"distance":"1","tilesize":48,"foreground":false,"data":[[1,2,1,1,1,2,1,1,1,2,2,1,1],[7,4,0,0,0,0,0,0,0,0,0,4,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,3,0,0,0,0,0,0,0,0,0,3,6],[2,1,1,2,1,1,1,1,2,2,2,2,1]]},{"name":"collision","width":13,"height":8,"linkWithCollision":false,"visible":0,"tilesetName":"","repeat":false,"preRender":false,"distance":1,"tilesize":48,"foreground":false,"data":[[1,1,1,1,1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,1,1,1,1]]}]}/*]JSON*/; +LevelLevel1=/*JSON[*/{"entities":[{"type":"EntityPaddleEnemy","x":56,"y":148},{"type":"EntityPaddlePlayer","x":536,"y":148},{"type":"EntityBall","x":300,"y":184},{"type":"EntityGoal","x":600,"y":48,"settings":{"size":{"x":24,"y":288},"owner":"human"}},{"type":"EntityGoal","x":0,"y":48,"settings":{"size":{"x":24,"y":288},"owner":"ai"}}],"layer":[{"name":"bg","width":3,"height":2,"linkWithCollision":false,"visible":1,"tilesetName":"media/bg.png","repeat":false,"preRender":false,"distance":"1","tilesize":250,"foreground":false,"data":[[1,1,1],[1,1,1]]},{"name":"board","width":13,"height":8,"linkWithCollision":false,"visible":1,"tilesetName":"media/tileset.png","repeat":false,"preRender":false,"distance":"1","tilesize":48,"foreground":false,"data":[[1,2,1,1,1,8,9,10,1,2,2,1,1],[7,4,0,0,0,0,0,0,0,0,0,4,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,5,0,0,0,0,0,0,0,0,0,5,6],[7,3,0,0,0,0,0,0,0,0,0,3,6],[2,1,1,2,1,1,1,1,2,2,2,2,1]]},{"name":"collision","width":13,"height":8,"linkWithCollision":false,"visible":0,"tilesetName":"","repeat":false,"preRender":false,"distance":1,"tilesize":48,"foreground":false,"data":[[1,1,1,1,1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,1,1,1,1]]}]}/*]JSON*/; LevelLevel1Resources=[new ig.Image('media/bg.png'), new ig.Image('media/tileset.png')]; }); \ No newline at end of file diff --git a/dev/lib/game/main.js b/dev/lib/game/main.js index 4bdf146..a627109 100755 --- a/dev/lib/game/main.js +++ b/dev/lib/game/main.js @@ -2,6 +2,7 @@ ig.module( 'game.main' ) .requires( + 'impact.debug.menu', 'impact.game', 'impact.font', @@ -14,6 +15,7 @@ ig.module( .defines(function(){ RunningGame = ig.Game.extend({ font: new ig.Font( 'media/04b03.font.png' ), + score: {'ai': 10, 'human': 10}, init: function() { ig.input.bind(ig.KEY.ESC, 'mainmenu'); @@ -28,12 +30,15 @@ ig.module( }, update: function() { - if (ig.input.pressed('mainmenu')) ig.system.setGame(StartScreen); + if (this.score.ai == 0 || this.score.human == 0 || ig.input.pressed('mainmenu')) + ig.system.setGame(StartScreen); this.parent(); // Update entries and background }, draw: function() { this.parent(); // Draw entries and background + this.font.draw(this.score.ai, 270, 25, ig.Font.ALIGN.CENTER); + this.font.draw(this.score.human, 350, 25, ig.Font.ALIGN.CENTER); } }); diff --git a/dev/media/tileset.png b/dev/media/tileset.png index 315c699..a4135e9 100644 Binary files a/dev/media/tileset.png and b/dev/media/tileset.png differ