From 9f314ec95c69ab20d558741044c87d3cc3dca2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20M=C3=BCller?= Date: Sun, 24 Jun 2012 10:50:26 +0200 Subject: [PATCH] file cleanup --- dev/lib/game/entities/ball.js | 82 +++++++++++++------------- dev/lib/game/entities/goal.js | 26 ++++---- dev/lib/game/entities/paddle-enemy.js | 24 ++++---- dev/lib/game/entities/paddle-player.js | 32 +++++----- dev/lib/game/entities/paddle.js | 28 ++++----- dev/lib/game/main.js | 1 - 6 files changed, 96 insertions(+), 97 deletions(-) diff --git a/dev/lib/game/entities/ball.js b/dev/lib/game/entities/ball.js index 4a7d55c..3e743f8 100644 --- a/dev/lib/game/entities/ball.js +++ b/dev/lib/game/entities/ball.js @@ -6,56 +6,56 @@ ig.module( ) .defines(function(){ - EntityBall = ig.Entity.extend({ +EntityBall = ig.Entity.extend({ - name: 'ball', + name: 'ball', - size: {x:48, y:48}, - collides: ig.Entity.COLLIDES.ACTIVE, - type: ig.Entity.TYPE.B, + size: {x:48, y:48}, + collides: ig.Entity.COLLIDES.ACTIVE, + type: ig.Entity.TYPE.B, - animSheet: new ig.AnimationSheet( 'media/ball.png', 48, 48 ), + animSheet: new ig.AnimationSheet( 'media/ball.png', 48, 48 ), - bounciness: 1, - maxVel: {x: 1000, y: 1000}, + bounciness: 1, + maxVel: {x: 1000, y: 1000}, - init: function( x, y, settings ) { - this.parent( x, y, settings ); - - this.addAnim( 'idle', 1, [0] ); + init: function( x, y, settings ) { + this.parent( x, y, settings ); + + this.addAnim( 'idle', 1, [0] ); - this.randomVel(); - }, + this.randomVel(); + }, - ready: function() { - this.startPos = {x: this.pos.x, y: this.pos.y}; - }, + ready: function() { + this.startPos = {x: this.pos.x, y: this.pos.y}; + }, - collideWith: function( other, axis ) { - if(other.name == 'paddle') { - // the horizontal speed of the ball multiplied - // every time it hits a paddle - this.vel.x *= 1.15; + collideWith: function( other, axis ) { + if(other.name == 'paddle') { + // the horizontal speed of the ball multiplied + // every time it hits a paddle + this.vel.x *= 1.15; - // the paddles y movement is added to the ball, - // so that players can give the ball a spin - this.vel.y += other.vel.y/2; - } - }, - - reset: function() { - this.randomVel(); - - this.pos.x = this.startPos.x; - this.pos.y = this.startPos.y; - }, - - randomVel: function() { - this.vel.x = (Math.random()*(100)) + 100; - if(Math.random() > .5) this.vel.x *= -1; - this.vel.y = (Math.random()*20) + 50; + // the paddles y movement is added to the ball, + // so that players can give the ball a spin + this.vel.y += other.vel.y/2; } + }, - }); + reset: function() { + this.randomVel(); -}); \ No newline at end of file + this.pos.x = this.startPos.x; + this.pos.y = this.startPos.y; + }, + + randomVel: function() { + this.vel.x = (Math.random()*(100)) + 100; + if(Math.random() > .5) this.vel.x *= -1; + this.vel.y = (Math.random()*20) + 50; + } + +}); + +}); diff --git a/dev/lib/game/entities/goal.js b/dev/lib/game/entities/goal.js index 5cd714e..d2e6b3e 100644 --- a/dev/lib/game/entities/goal.js +++ b/dev/lib/game/entities/goal.js @@ -6,23 +6,23 @@ ig.module( ) .defines(function(){ - EntityGoal = ig.Entity.extend({ +EntityGoal = ig.Entity.extend({ - height: 90, + height: 90, - size: {x:48, y:48}, - checkAgainst: ig.Entity.TYPE.B, + size: {x:48, y:48}, + checkAgainst: ig.Entity.TYPE.B, - _wmScalable: true, - _wmDrawBox: true, - _wmBoxColor: '#00ff00', + _wmScalable: true, + _wmDrawBox: true, + _wmBoxColor: '#00ff00', - check: function( other ) { - if(other.name == 'ball') { - other.reset(); - } + check: function( other ) { + if(other.name == 'ball') { + other.reset(); } + } - }); +}); -}); \ No newline at end of file +}); diff --git a/dev/lib/game/entities/paddle-enemy.js b/dev/lib/game/entities/paddle-enemy.js index 4364018..c0b3efe 100644 --- a/dev/lib/game/entities/paddle-enemy.js +++ b/dev/lib/game/entities/paddle-enemy.js @@ -7,20 +7,20 @@ ig.module( ) .defines(function(){ - EntityPaddleEnemy = EntityPaddle.extend({ +EntityPaddleEnemy = EntityPaddle.extend({ - update: function(){ - var ball = ig.game.getEntitiesByType( EntityBall )[0]; + update: function(){ + var ball = ig.game.getEntitiesByType( EntityBall )[0]; - if( ball.pos.y + ball.size.y / 2 > this.pos.y + this.size.y / 2 ) { - this.vel.y = 100; - } else { - this.vel.y = -100; - } - - this.parent(); + if( ball.pos.y + ball.size.y / 2 > this.pos.y + this.size.y / 2 ) { + this.vel.y = 100; + } else { + this.vel.y = -100; } - }); + this.parent(); + } -}); \ No newline at end of file +}); + +}); diff --git a/dev/lib/game/entities/paddle-player.js b/dev/lib/game/entities/paddle-player.js index 032e318..993247b 100644 --- a/dev/lib/game/entities/paddle-player.js +++ b/dev/lib/game/entities/paddle-player.js @@ -6,24 +6,24 @@ ig.module( ) .defines(function(){ - EntityPaddlePlayer = EntityPaddle.extend({ +EntityPaddlePlayer = EntityPaddle.extend({ - animSheet: new ig.AnimationSheet( 'media/paddle-player.png', 64, 128 ), + animSheet: new ig.AnimationSheet( 'media/paddle-player.png', 64, 128 ), - update: function(){ - if( ig.input.state('up') ) { - this.vel.y = -400; - } - else if( ig.input.state('down') ) { - this.vel.y = 400; - } - else { - this.vel.y = 0; - } - - this.parent(); + update: function(){ + if( ig.input.state('up') ) { + this.vel.y = -400; + } + else if( ig.input.state('down') ) { + this.vel.y = 400; + } + else { + this.vel.y = 0; } - }); + this.parent(); + } -}); \ No newline at end of file +}); + +}); diff --git a/dev/lib/game/entities/paddle.js b/dev/lib/game/entities/paddle.js index 4d3936a..3630c74 100644 --- a/dev/lib/game/entities/paddle.js +++ b/dev/lib/game/entities/paddle.js @@ -6,24 +6,24 @@ ig.module( ) .defines(function(){ - EntityPaddle = ig.Entity.extend({ +EntityPaddle = ig.Entity.extend({ - name: 'paddle', + name: 'paddle', - size: {x:64, y:128}, - collides: ig.Entity.COLLIDES.FIXED, - type: ig.Entity.TYPE.A, + size: {x:64, y:128}, + collides: ig.Entity.COLLIDES.FIXED, + type: ig.Entity.TYPE.A, - animSheet: new ig.AnimationSheet( 'media/paddle.png', 64, 128 ), + animSheet: new ig.AnimationSheet( 'media/paddle.png', 64, 128 ), - maxVel: {x: 0, y: 400}, + maxVel: {x: 0, y: 400}, - init: function( x, y, settings ) { - this.parent( x, y, settings ); - - this.addAnim( 'idle', 1, [0] ); - } + init: function( x, y, settings ) { + this.parent( x, y, settings ); + + this.addAnim( 'idle', 1, [0] ); + } - }); +}); -}); \ No newline at end of file +}); diff --git a/dev/lib/game/main.js b/dev/lib/game/main.js index aa100fa..9c6fbd6 100755 --- a/dev/lib/game/main.js +++ b/dev/lib/game/main.js @@ -39,7 +39,6 @@ MyGame = ig.Game.extend({ } }); - // Start the Game with 60fps, a resolution of 640x400 (16:10), scaled // up by a factor of 2 ig.main( '#canvas', MyGame, 60, 640, 400, 1 );