{"action":"created","comment":{"url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/comments/51936334","id":51936334,"diff_hunk":"@@ -0,0 +1,102 @@\n+var Game = function( game )\n+{\n+};\n+\n+Game.prototype =\n+{\n+    __assets :\n+    {\n+        ship : {\n+            name : \"ship\",\n+            url : \"../../assets/ship.png\"\n+        },\n+        blackHole : {\n+            name : \"black_hole\",\n+            url : \"../../assets/black_hole.png\"\n+        }\n+    },\n+\n+    __sprites : {},\n+\n+    __non_player_objects : [],\n+    \n+    __parameters :\n+    {\n+        ship_mass: 1,\n+        blackHole_mass: 500000,\n+        camera_cutoff_x: 500\n+    },\n+\n+    onload : function()\n+    {\n+        preloadState = Core.getState( STATE_NAME.PRELOAD );\n+\n+        Object.keys( this.__assets ).forEach( function( assetKey )\n+        {\n+                var asset = this.__assets[ assetKey ]\n+                preloadState.addImage( asset.name, asset.url );\n+        }.bind( this ));\n+    },\n+\n+    create : function()\n+    {\n+        this.__sprites.ship = this.game.add.sprite(\n+                100, 200, this.__assets.ship.name );\n+        this.__sprites.ship.anchor.set( 0.5, 0.5 );\n+\n+        this.__sprites.blackHole = this.game.add.sprite(\n+                200, 300, this.__assets.blackHole.name );\n+        this.__sprites.blackHole.anchor.set( 0.5, 0.5 );\n+\n+        this.game.physics.startSystem(Phaser.Physics.ARCADE);\n+        this.game.physics.enable(this.__sprites.ship, Phaser.Physics.ARCADE);\n+        this.game.physics.enable(this.__sprites.blackHole,\n+                                 Phaser.Physics.ARCADE);\n+\n+        this.__sprites.ship.body.velocity.setTo(60, 0);\n+        \n+        this.__sprites.ship.body.mass = this.__parameters.ship_mass;\n+        this.__sprites.blackHole.body.mass = this.__parameters.blackHole_mass;\n+        \n+        this.__non_player_objects.push(this.__sprites.blackHole);\n+    },\n+\n+    update : function()\n+    {\n+        var ship = this.__sprites.ship;\n+        var blackHole = this.__sprites.blackHole;\n+        \n+        var totalGravity = (ship.body.mass * blackHole.body.mass) /\n+            Phaser.Math.distanceSq(ship.x, ship.y, blackHole.x, blackHole.y);\n+        \n+        var angleBetweenShipBH = Phaser.Math.angleBetweenPoints(ship.position,\n+            blackHole.position)\n+        \n+        ship.body.gravity = new Phaser.Point(totalGravity *\n+            Math.cos(angleBetweenShipBH), totalGravity *\n+            Math.sin(angleBetweenShipBH));\n+\n+        ship.body.rotation = 270 + Phaser.Math.radToDeg(\n+            Phaser.Math.angleBetweenPoints(ship.body.velocity,\n+                                           new Phaser.Point(0, 0)));","path":"src/states/game.js","position":81,"original_position":81,"commit_id":"f35d9b4bed014eef007297fffd3b352b5ed1630c","original_commit_id":"f35d9b4bed014eef007297fffd3b352b5ed1630c","user":{"login":"tomcraven","id":5236109,"avatar_url":"https://avatars.githubusercontent.com/u/5236109?v=3","gravatar_id":"","url":"https://api.github.com/users/tomcraven","html_url":"https://github.com/tomcraven","followers_url":"https://api.github.com/users/tomcraven/followers","following_url":"https://api.github.com/users/tomcraven/following{/other_user}","gists_url":"https://api.github.com/users/tomcraven/gists{/gist_id}","starred_url":"https://api.github.com/users/tomcraven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomcraven/subscriptions","organizations_url":"https://api.github.com/users/tomcraven/orgs","repos_url":"https://api.github.com/users/tomcraven/repos","events_url":"https://api.github.com/users/tomcraven/events{/privacy}","received_events_url":"https://api.github.com/users/tomcraven/received_events","type":"User","site_admin":false},"body":"Instead of new-ing this one each update call we should create a constant in 'create' and use it here.\r\n\r\nthis.__origin, or this.__zeroPoint (or whatever) = new Phaser.Point(0,0);\r\n\r\nI had a google and i'm surprised there's not a Phaser.Point.ZERO or something similar","created_at":"2016-02-04T20:59:30Z","updated_at":"2016-02-04T20:59:30Z","html_url":"https://github.com/marc-hugh-tom/ship/pull/5#discussion_r51936334","pull_request_url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/comments/51936334"},"html":{"href":"https://github.com/marc-hugh-tom/ship/pull/5#discussion_r51936334"},"pull_request":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5","id":58276456,"html_url":"https://github.com/marc-hugh-tom/ship/pull/5","diff_url":"https://github.com/marc-hugh-tom/ship/pull/5.diff","patch_url":"https://github.com/marc-hugh-tom/ship/pull/5.patch","issue_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues/5","number":5,"state":"open","locked":false,"title":"Basic idea prototype","user":{"login":"marc-jones","id":6664299,"avatar_url":"https://avatars.githubusercontent.com/u/6664299?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-jones","html_url":"https://github.com/marc-jones","followers_url":"https://api.github.com/users/marc-jones/followers","following_url":"https://api.github.com/users/marc-jones/following{/other_user}","gists_url":"https://api.github.com/users/marc-jones/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-jones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-jones/subscriptions","organizations_url":"https://api.github.com/users/marc-jones/orgs","repos_url":"https://api.github.com/users/marc-jones/repos","events_url":"https://api.github.com/users/marc-jones/events{/privacy}","received_events_url":"https://api.github.com/users/marc-jones/received_events","type":"User","site_admin":false},"body":"The black hole exerts a force on the ship proportional to their masses and the inverse square distance between them.\r\n\r\nThe black hole can be moved by clicking on the play area.\r\n\r\nThe ship can move infinitely to the right of the screen, but is limited vertically and cannot backtrack.","created_at":"2016-02-04T11:56:16Z","updated_at":"2016-02-04T20:59:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"937ef081ce980189d2fc7969c7d756572bcbd26b","assignee":null,"milestone":{"url":"https://api.github.com/repos/marc-hugh-tom/ship/milestones/1","html_url":"https://github.com/marc-hugh-tom/ship/milestones/prototype","labels_url":"https://api.github.com/repos/marc-hugh-tom/ship/milestones/1/labels","id":1560974,"number":1,"title":"prototype","description":"Bare bones prototype","creator":{"login":"tomcraven","id":5236109,"avatar_url":"https://avatars.githubusercontent.com/u/5236109?v=3","gravatar_id":"","url":"https://api.github.com/users/tomcraven","html_url":"https://github.com/tomcraven","followers_url":"https://api.github.com/users/tomcraven/followers","following_url":"https://api.github.com/users/tomcraven/following{/other_user}","gists_url":"https://api.github.com/users/tomcraven/gists{/gist_id}","starred_url":"https://api.github.com/users/tomcraven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomcraven/subscriptions","organizations_url":"https://api.github.com/users/tomcraven/orgs","repos_url":"https://api.github.com/users/tomcraven/repos","events_url":"https://api.github.com/users/tomcraven/events{/privacy}","received_events_url":"https://api.github.com/users/tomcraven/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":1,"state":"open","created_at":"2016-02-03T13:08:45Z","updated_at":"2016-02-04T11:56:16Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5/commits","review_comments_url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5/comments","review_comment_url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/comments{/number}","comments_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues/5/comments","statuses_url":"https://api.github.com/repos/marc-hugh-tom/ship/statuses/f35d9b4bed014eef007297fffd3b352b5ed1630c","head":{"label":"marc-hugh-tom:marc-prototype","ref":"marc-prototype","sha":"f35d9b4bed014eef007297fffd3b352b5ed1630c","user":{"login":"marc-hugh-tom","id":16869451,"avatar_url":"https://avatars.githubusercontent.com/u/16869451?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-hugh-tom","html_url":"https://github.com/marc-hugh-tom","followers_url":"https://api.github.com/users/marc-hugh-tom/followers","following_url":"https://api.github.com/users/marc-hugh-tom/following{/other_user}","gists_url":"https://api.github.com/users/marc-hugh-tom/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-hugh-tom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-hugh-tom/subscriptions","organizations_url":"https://api.github.com/users/marc-hugh-tom/orgs","repos_url":"https://api.github.com/users/marc-hugh-tom/repos","events_url":"https://api.github.com/users/marc-hugh-tom/events{/privacy}","received_events_url":"https://api.github.com/users/marc-hugh-tom/received_events","type":"Organization","site_admin":false},"repo":{"id":50310848,"name":"ship","full_name":"marc-hugh-tom/ship","owner":{"login":"marc-hugh-tom","id":16869451,"avatar_url":"https://avatars.githubusercontent.com/u/16869451?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-hugh-tom","html_url":"https://github.com/marc-hugh-tom","followers_url":"https://api.github.com/users/marc-hugh-tom/followers","following_url":"https://api.github.com/users/marc-hugh-tom/following{/other_user}","gists_url":"https://api.github.com/users/marc-hugh-tom/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-hugh-tom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-hugh-tom/subscriptions","organizations_url":"https://api.github.com/users/marc-hugh-tom/orgs","repos_url":"https://api.github.com/users/marc-hugh-tom/repos","events_url":"https://api.github.com/users/marc-hugh-tom/events{/privacy}","received_events_url":"https://api.github.com/users/marc-hugh-tom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marc-hugh-tom/ship","description":"","fork":false,"url":"https://api.github.com/repos/marc-hugh-tom/ship","forks_url":"https://api.github.com/repos/marc-hugh-tom/ship/forks","keys_url":"https://api.github.com/repos/marc-hugh-tom/ship/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marc-hugh-tom/ship/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marc-hugh-tom/ship/teams","hooks_url":"https://api.github.com/repos/marc-hugh-tom/ship/hooks","issue_events_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues/events{/number}","events_url":"https://api.github.com/repos/marc-hugh-tom/ship/events","assignees_url":"https://api.github.com/repos/marc-hugh-tom/ship/assignees{/user}","branches_url":"https://api.github.com/repos/marc-hugh-tom/ship/branches{/branch}","tags_url":"https://api.github.com/repos/marc-hugh-tom/ship/tags","blobs_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/refs{/sha}","trees_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marc-hugh-tom/ship/statuses/{sha}","languages_url":"https://api.github.com/repos/marc-hugh-tom/ship/languages","stargazers_url":"https://api.github.com/repos/marc-hugh-tom/ship/stargazers","contributors_url":"https://api.github.com/repos/marc-hugh-tom/ship/contributors","subscribers_url":"https://api.github.com/repos/marc-hugh-tom/ship/subscribers","subscription_url":"https://api.github.com/repos/marc-hugh-tom/ship/subscription","commits_url":"https://api.github.com/repos/marc-hugh-tom/ship/commits{/sha}","git_commits_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/commits{/sha}","comments_url":"https://api.github.com/repos/marc-hugh-tom/ship/comments{/number}","issue_comment_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues/comments{/number}","contents_url":"https://api.github.com/repos/marc-hugh-tom/ship/contents/{+path}","compare_url":"https://api.github.com/repos/marc-hugh-tom/ship/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marc-hugh-tom/ship/merges","archive_url":"https://api.github.com/repos/marc-hugh-tom/ship/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marc-hugh-tom/ship/downloads","issues_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues{/number}","pulls_url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls{/number}","milestones_url":"https://api.github.com/repos/marc-hugh-tom/ship/milestones{/number}","notifications_url":"https://api.github.com/repos/marc-hugh-tom/ship/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marc-hugh-tom/ship/labels{/name}","releases_url":"https://api.github.com/repos/marc-hugh-tom/ship/releases{/id}","deployments_url":"https://api.github.com/repos/marc-hugh-tom/ship/deployments","created_at":"2016-01-24T22:12:58Z","updated_at":"2016-01-24T22:12:58Z","pushed_at":"2016-02-04T11:56:17Z","git_url":"git://github.com/marc-hugh-tom/ship.git","ssh_url":"git@github.com:marc-hugh-tom/ship.git","clone_url":"https://github.com/marc-hugh-tom/ship.git","svn_url":"https://github.com/marc-hugh-tom/ship","homepage":null,"size":15,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"marc-hugh-tom:master","ref":"master","sha":"a8bf3d770e38ed51453db4e140969d59361b23f5","user":{"login":"marc-hugh-tom","id":16869451,"avatar_url":"https://avatars.githubusercontent.com/u/16869451?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-hugh-tom","html_url":"https://github.com/marc-hugh-tom","followers_url":"https://api.github.com/users/marc-hugh-tom/followers","following_url":"https://api.github.com/users/marc-hugh-tom/following{/other_user}","gists_url":"https://api.github.com/users/marc-hugh-tom/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-hugh-tom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-hugh-tom/subscriptions","organizations_url":"https://api.github.com/users/marc-hugh-tom/orgs","repos_url":"https://api.github.com/users/marc-hugh-tom/repos","events_url":"https://api.github.com/users/marc-hugh-tom/events{/privacy}","received_events_url":"https://api.github.com/users/marc-hugh-tom/received_events","type":"Organization","site_admin":false},"repo":{"id":50310848,"name":"ship","full_name":"marc-hugh-tom/ship","owner":{"login":"marc-hugh-tom","id":16869451,"avatar_url":"https://avatars.githubusercontent.com/u/16869451?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-hugh-tom","html_url":"https://github.com/marc-hugh-tom","followers_url":"https://api.github.com/users/marc-hugh-tom/followers","following_url":"https://api.github.com/users/marc-hugh-tom/following{/other_user}","gists_url":"https://api.github.com/users/marc-hugh-tom/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-hugh-tom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-hugh-tom/subscriptions","organizations_url":"https://api.github.com/users/marc-hugh-tom/orgs","repos_url":"https://api.github.com/users/marc-hugh-tom/repos","events_url":"https://api.github.com/users/marc-hugh-tom/events{/privacy}","received_events_url":"https://api.github.com/users/marc-hugh-tom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marc-hugh-tom/ship","description":"","fork":false,"url":"https://api.github.com/repos/marc-hugh-tom/ship","forks_url":"https://api.github.com/repos/marc-hugh-tom/ship/forks","keys_url":"https://api.github.com/repos/marc-hugh-tom/ship/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marc-hugh-tom/ship/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marc-hugh-tom/ship/teams","hooks_url":"https://api.github.com/repos/marc-hugh-tom/ship/hooks","issue_events_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues/events{/number}","events_url":"https://api.github.com/repos/marc-hugh-tom/ship/events","assignees_url":"https://api.github.com/repos/marc-hugh-tom/ship/assignees{/user}","branches_url":"https://api.github.com/repos/marc-hugh-tom/ship/branches{/branch}","tags_url":"https://api.github.com/repos/marc-hugh-tom/ship/tags","blobs_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/refs{/sha}","trees_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marc-hugh-tom/ship/statuses/{sha}","languages_url":"https://api.github.com/repos/marc-hugh-tom/ship/languages","stargazers_url":"https://api.github.com/repos/marc-hugh-tom/ship/stargazers","contributors_url":"https://api.github.com/repos/marc-hugh-tom/ship/contributors","subscribers_url":"https://api.github.com/repos/marc-hugh-tom/ship/subscribers","subscription_url":"https://api.github.com/repos/marc-hugh-tom/ship/subscription","commits_url":"https://api.github.com/repos/marc-hugh-tom/ship/commits{/sha}","git_commits_url":"https://api.github.com/repos/marc-hugh-tom/ship/git/commits{/sha}","comments_url":"https://api.github.com/repos/marc-hugh-tom/ship/comments{/number}","issue_comment_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues/comments{/number}","contents_url":"https://api.github.com/repos/marc-hugh-tom/ship/contents/{+path}","compare_url":"https://api.github.com/repos/marc-hugh-tom/ship/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marc-hugh-tom/ship/merges","archive_url":"https://api.github.com/repos/marc-hugh-tom/ship/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marc-hugh-tom/ship/downloads","issues_url":"https://api.github.com/repos/marc-hugh-tom/ship/issues{/number}","pulls_url":"https://api.github.com/repos/marc-hugh-tom/ship/pulls{/number}","milestones_url":"https://api.github.com/repos/marc-hugh-tom/ship/milestones{/number}","notifications_url":"https://api.github.com/repos/marc-hugh-tom/ship/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marc-hugh-tom/ship/labels{/name}","releases_url":"https://api.github.com/repos/marc-hugh-tom/ship/releases{/id}","deployments_url":"https://api.github.com/repos/marc-hugh-tom/ship/deployments","created_at":"2016-01-24T22:12:58Z","updated_at":"2016-01-24T22:12:58Z","pushed_at":"2016-02-04T11:56:17Z","git_url":"git://github.com/marc-hugh-tom/ship.git","ssh_url":"git@github.com:marc-hugh-tom/ship.git","clone_url":"https://github.com/marc-hugh-tom/ship.git","svn_url":"https://github.com/marc-hugh-tom/ship","homepage":null,"size":15,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5"},"html":{"href":"https://github.com/marc-hugh-tom/ship/pull/5"},"issue":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/issues/5"},"comments":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/marc-hugh-tom/ship/statuses/f35d9b4bed014eef007297fffd3b352b5ed1630c"}}}}