From c2c0e2a8598217fd5ff004a4c29f5fabbc05840d Mon Sep 17 00:00:00 2001 From: logsol Date: Sun, 12 Jan 2014 06:31:44 +0100 Subject: [PATCH] added football --- app/Game/Config/Settings.js | 2 +- app/Game/Core/GameObjects/Item.js | 20 +++++++++++++++++--- app/Game/Core/Loader/Level.js | 14 ++++++++++++++ static/img/Items/outdoor/football.gif | Bin 0 -> 302 bytes 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 static/img/Items/outdoor/football.gif diff --git a/app/Game/Config/Settings.js b/app/Game/Config/Settings.js index 41d571f..889edb3 100755 --- a/app/Game/Config/Settings.js +++ b/app/Game/Config/Settings.js @@ -47,7 +47,7 @@ define({ IS_BROWSER_ENVIRONMENT: typeof window !== 'undefined', USE_WEGBL: true, - DEBUG_MODE: 0, + DEBUG_MODE: 1, // NETWORKING WORLD_UPDATE_BROADCAST_INTERVAL: 70, diff --git a/app/Game/Core/GameObjects/Item.js b/app/Game/Core/GameObjects/Item.js index baaa77d..ef9eddb 100644 --- a/app/Game/Core/GameObjects/Item.js +++ b/app/Game/Core/GameObjects/Item.js @@ -29,10 +29,20 @@ function (Parent, Box2D, Settings) { Item.prototype.createFixture = function () { - var itemShape = new Box2D.Collision.Shapes.b2PolygonShape(); + var itemShape; var w = this.options.width / Settings.RATIO; var h = this.options.height / Settings.RATIO; - itemShape.SetAsOrientedBox(w / 2, h / 2, new Box2D.Common.Math.b2Vec2(0, -(h/2))); + + if(this.options.type == 'circle'){ + var r = (w + h) / 4 ; + itemShape = new Box2D.Collision.Shapes.b2CircleShape(); + itemShape.SetRadius(r); + itemShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, -r)); + } else { + itemShape = new Box2D.Collision.Shapes.b2PolygonShape(); + itemShape.SetAsOrientedBox(w / 2, h / 2, new Box2D.Common.Math.b2Vec2(0, -(h/2))); + } + var fixtureDef = new Box2D.Dynamics.b2FixtureDef(); fixtureDef.shape = itemShape; @@ -42,7 +52,11 @@ function (Parent, Box2D, Settings) { var density = ((this.options.weight + offset) / this.options.width / this.options.height) * factor; fixtureDef.density = density; fixtureDef.friction = Settings.ITEM_FRICTION; - fixtureDef.restitution = Settings.ITEM_RESTITUTION; + + fixtureDef.restitution = this.options.bounce + ? this.options.bounce / 10 + : Settings.ITEM_RESTITUTION; + fixtureDef.isSensor = false; this.body.CreateFixture(fixtureDef); diff --git a/app/Game/Core/Loader/Level.js b/app/Game/Core/Loader/Level.js index 671ead3..4701ea1 100755 --- a/app/Game/Core/Loader/Level.js +++ b/app/Game/Core/Loader/Level.js @@ -246,6 +246,20 @@ microwave: 3.744 y:0, rotation: 0, grabAngle: -1.5 + }, + { + name:'Football', + image:'football.gif', + type:'circle', + category:'outdoor', + weight: 2, + width:10, + height:10, + x:350, + y:0, + rotation: 0, + grabAngle: -1.5, + bounce: 6 } ], tiles: /* diff --git a/static/img/Items/outdoor/football.gif b/static/img/Items/outdoor/football.gif new file mode 100644 index 0000000000000000000000000000000000000000..a12530e9a32c0b9b7fb0bebb02a69d490ad5bf8a GIT binary patch literal 302 zcmZ?wbhEHb$IoWxq&z_w!eMWs_^T|`E zwr$(~@83TLM)r`1=;WkScQ3zh-@e|ybLZoS4>#}Lad-EQ2#;uO>s+*GNm6nO0|P^F zXvBpJ7uIgr@a4;wva*Vpn0S6cF?M#|vuDqJ{`~2{frB4Ee*6yxK*g9q@h1x-1A_&F z4oC{*Ck8fehdBc24m|BT(b^BWc+8o6dV)09w8$Sy37B+8%;L&pwi!1W%%fH;+bNr8 o?s`h)z(k`Bg6bD0a=P+qi3y0y={xf%s27;II|=f-J2F@U0G0}kAOHXW literal 0 HcmV?d00001