{"action":"created","comment":{"url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/comments/42668725","id":42668725,"diff_hunk":"@@ -0,0 +1,123 @@\n+---\n+comments: true\n+layout: post\n+slug: scalajs-in-practice\n+title: Scala.js in practice\n+summary: In this post I'm going to present a mini-game that I've prepared using scala.js and three.js library\n+author: Andrzej Janczak\n+feed_group: scala\n+tags:\n+- Scala\n+- Scala.js\n+- Frontend\n+---\n+\n+\n+## <a name=\"intro\" href=\"#intro\">Introduction</a>\n+![](http://i.imgur.com/C3iVcuA.jpg)  \n+\n+This blog post was created to see how Scala.js holding on and have some fun with programming. I decided to do a simple mini-game using Scala.js and three.js libraries.   \n+I chose three.js library because I'm familiar with it and I knew that it'll provide me things I need. Three.js is in fact 3D library and on start I also wanted to create a 3D mini game, but it ended on 2D game ;)  \n+I encourage you to read [this](http://blog.scalac.io/2015/09/24/scala_js.html) blog post about Scala.js basics first, but it's not required. This blog post explore Scala.js from more practical perspective.\n+\n+My inspiration was: [http://oos.moxiecode.com/js_webgl/xwing/](http://oos.moxiecode.com/js_webgl/xwing/ \"xwing\")  \n+Project on github: [https://github.com/andrjew/scalac-fighter](https://github.com/andrjew/scalac-fighter)  \n+\n+\n+## <a name=\"about-project\" href=\"#about-project\">Short about the project</a>  \n+Sorry but I'm not going to write some boring stuff about code here. There is no fancy code to show. Application from Scala point of view is rather boring, so I decided to just leave you here with class structure to get some basic insights:  \n+![](http://i.imgur.com/0bDKxkL.png?1)  \n+\n+If you are interested in how the game works, just get source code from [here](https://github.com/andrjew/scalac-fighter).\n+ \n+And this is how the game looks like :\n+![scalac-figter-screen](http://i.imgur.com/Gbp2VuD.png)\n+\n+\n+## <a name=\"js-code\" href=\"#js-code\">Where is JS ?</a>\n+![where-is-js](http://vignette1.wikia.nocookie.net/starwars/images/c/c6/Maul_Electrobinoculars.png/revision/latest?cb=20140624115902)  \n+After hitting `sbt fastOptJS` you can find a javascript files in `scalac-fighter/target/scala-2.11`.\n+The most important is `scalac-fighter-fastopt.js` which include game code.   \n+Beside code we can observe many code that is Scala.js related. This minus because for person who want to see how JS code looks like it's an serious obstacle.  \n+\n+####Let's take a quick look into some example:\n+\n+**function definition:**  \n+scala: \n+```\n+def movePlayerShip(newX: Option[Double] = None, newY: Option[Doufragmentble] = None) = {\n+    import playerShip.object3d._\n+    position.set(newX.getOrElse(position.x), newY.getOrElse(position.y), position.z)\n+  }\n+```\n+js:\n+```\n+$c_Lmain_Game.prototype.movePlayerShip__s_Option__s_Option__Lorg_denigma_threejs_Vector3 = (function(newX, newY) {\n+  return this.playerShip$1.object3d$1[\"position\"][\"set\"]($uD((newX.isEmpty__Z() ? $uD(this.playerShip$1.object3d$1[\"position\"][\"x\"]) : newX.get__O())), $uD((newY.isEmpty__Z() ? $uD(this.playerShip$1.object3d$1[\"position\"][\"y\"]) : newY.get__O())), $uD(this.playerShip$1.object3d$1[\"position\"][\"z\"]))\n+});\n+```    \n+\n+As we can observe generated code is rather not eyes friendly. Function name in js is 5 times longer than in scala.   ","path":"_posts/2015-10-21-scalajs-in-practice.md","position":60,"original_position":60,"commit_id":"02994c057708db147fcfd74942f5b9b70969307e","original_commit_id":"02994c057708db147fcfd74942f5b9b70969307e","user":{"login":"tomaszperek","id":3693402,"avatar_url":"https://avatars.githubusercontent.com/u/3693402?v=3","gravatar_id":"","url":"https://api.github.com/users/tomaszperek","html_url":"https://github.com/tomaszperek","followers_url":"https://api.github.com/users/tomaszperek/followers","following_url":"https://api.github.com/users/tomaszperek/following{/other_user}","gists_url":"https://api.github.com/users/tomaszperek/gists{/gist_id}","starred_url":"https://api.github.com/users/tomaszperek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomaszperek/subscriptions","organizations_url":"https://api.github.com/users/tomaszperek/orgs","repos_url":"https://api.github.com/users/tomaszperek/repos","events_url":"https://api.github.com/users/tomaszperek/events{/privacy}","received_events_url":"https://api.github.com/users/tomaszperek/received_events","type":"User","site_admin":false},"body":"as we can see the generated code is rather not eye-friendly.","created_at":"2015-10-21T19:14:11Z","updated_at":"2015-10-21T19:14:11Z","html_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io/pull/83#discussion_r42668725","pull_request_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83","_links":{"self":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/comments/42668725"},"html":{"href":"https://github.com/ScalaConsultants/ScalaConsultants.github.io/pull/83#discussion_r42668725"},"pull_request":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83"}}},"pull_request":{"url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83","id":48342628,"html_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io/pull/83","diff_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io/pull/83.diff","patch_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io/pull/83.patch","issue_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/83","number":83,"state":"open","locked":false,"title":"Scala.js in practice post (mini game)","user":{"login":"andrjew","id":1226820,"avatar_url":"https://avatars.githubusercontent.com/u/1226820?v=3","gravatar_id":"","url":"https://api.github.com/users/andrjew","html_url":"https://github.com/andrjew","followers_url":"https://api.github.com/users/andrjew/followers","following_url":"https://api.github.com/users/andrjew/following{/other_user}","gists_url":"https://api.github.com/users/andrjew/gists{/gist_id}","starred_url":"https://api.github.com/users/andrjew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrjew/subscriptions","organizations_url":"https://api.github.com/users/andrjew/orgs","repos_url":"https://api.github.com/users/andrjew/repos","events_url":"https://api.github.com/users/andrjew/events{/privacy}","received_events_url":"https://api.github.com/users/andrjew/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-21T14:56:38Z","updated_at":"2015-10-21T19:14:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d18509ca59c42c5b4f690af5c4eca2a167cb182","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83/commits","review_comments_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83/comments","review_comment_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/83/comments","statuses_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/statuses/02994c057708db147fcfd74942f5b9b70969307e","head":{"label":"ScalaConsultants:post/scalajs-in-practice","ref":"post/scalajs-in-practice","sha":"02994c057708db147fcfd74942f5b9b70969307e","user":{"login":"ScalaConsultants","id":6207831,"avatar_url":"https://avatars.githubusercontent.com/u/6207831?v=3","gravatar_id":"","url":"https://api.github.com/users/ScalaConsultants","html_url":"https://github.com/ScalaConsultants","followers_url":"https://api.github.com/users/ScalaConsultants/followers","following_url":"https://api.github.com/users/ScalaConsultants/following{/other_user}","gists_url":"https://api.github.com/users/ScalaConsultants/gists{/gist_id}","starred_url":"https://api.github.com/users/ScalaConsultants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScalaConsultants/subscriptions","organizations_url":"https://api.github.com/users/ScalaConsultants/orgs","repos_url":"https://api.github.com/users/ScalaConsultants/repos","events_url":"https://api.github.com/users/ScalaConsultants/events{/privacy}","received_events_url":"https://api.github.com/users/ScalaConsultants/received_events","type":"Organization","site_admin":false},"repo":{"id":15366666,"name":"ScalaConsultants.github.io","full_name":"ScalaConsultants/ScalaConsultants.github.io","owner":{"login":"ScalaConsultants","id":6207831,"avatar_url":"https://avatars.githubusercontent.com/u/6207831?v=3","gravatar_id":"","url":"https://api.github.com/users/ScalaConsultants","html_url":"https://github.com/ScalaConsultants","followers_url":"https://api.github.com/users/ScalaConsultants/followers","following_url":"https://api.github.com/users/ScalaConsultants/following{/other_user}","gists_url":"https://api.github.com/users/ScalaConsultants/gists{/gist_id}","starred_url":"https://api.github.com/users/ScalaConsultants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScalaConsultants/subscriptions","organizations_url":"https://api.github.com/users/ScalaConsultants/orgs","repos_url":"https://api.github.com/users/ScalaConsultants/repos","events_url":"https://api.github.com/users/ScalaConsultants/events{/privacy}","received_events_url":"https://api.github.com/users/ScalaConsultants/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io","description":"Scalac blog","fork":false,"url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io","forks_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/forks","keys_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/teams","hooks_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/hooks","issue_events_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/events","assignees_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/tags","blobs_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/languages","stargazers_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/stargazers","contributors_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/contributors","subscribers_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/subscribers","subscription_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/subscription","commits_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/merges","archive_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/downloads","issues_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/labels{/name}","releases_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/releases{/id}","created_at":"2013-12-21T22:28:57Z","updated_at":"2015-10-19T07:58:30Z","pushed_at":"2015-10-21T18:40:09Z","git_url":"git://github.com/ScalaConsultants/ScalaConsultants.github.io.git","ssh_url":"git@github.com:ScalaConsultants/ScalaConsultants.github.io.git","clone_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io.git","svn_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io","homepage":null,"size":5446,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":2,"forks":9,"open_issues":2,"watchers":2,"default_branch":"master"}},"base":{"label":"ScalaConsultants:master","ref":"master","sha":"f4111495abedf6455e474417c856b45140d22eda","user":{"login":"ScalaConsultants","id":6207831,"avatar_url":"https://avatars.githubusercontent.com/u/6207831?v=3","gravatar_id":"","url":"https://api.github.com/users/ScalaConsultants","html_url":"https://github.com/ScalaConsultants","followers_url":"https://api.github.com/users/ScalaConsultants/followers","following_url":"https://api.github.com/users/ScalaConsultants/following{/other_user}","gists_url":"https://api.github.com/users/ScalaConsultants/gists{/gist_id}","starred_url":"https://api.github.com/users/ScalaConsultants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScalaConsultants/subscriptions","organizations_url":"https://api.github.com/users/ScalaConsultants/orgs","repos_url":"https://api.github.com/users/ScalaConsultants/repos","events_url":"https://api.github.com/users/ScalaConsultants/events{/privacy}","received_events_url":"https://api.github.com/users/ScalaConsultants/received_events","type":"Organization","site_admin":false},"repo":{"id":15366666,"name":"ScalaConsultants.github.io","full_name":"ScalaConsultants/ScalaConsultants.github.io","owner":{"login":"ScalaConsultants","id":6207831,"avatar_url":"https://avatars.githubusercontent.com/u/6207831?v=3","gravatar_id":"","url":"https://api.github.com/users/ScalaConsultants","html_url":"https://github.com/ScalaConsultants","followers_url":"https://api.github.com/users/ScalaConsultants/followers","following_url":"https://api.github.com/users/ScalaConsultants/following{/other_user}","gists_url":"https://api.github.com/users/ScalaConsultants/gists{/gist_id}","starred_url":"https://api.github.com/users/ScalaConsultants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScalaConsultants/subscriptions","organizations_url":"https://api.github.com/users/ScalaConsultants/orgs","repos_url":"https://api.github.com/users/ScalaConsultants/repos","events_url":"https://api.github.com/users/ScalaConsultants/events{/privacy}","received_events_url":"https://api.github.com/users/ScalaConsultants/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io","description":"Scalac blog","fork":false,"url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io","forks_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/forks","keys_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/teams","hooks_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/hooks","issue_events_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/events","assignees_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/tags","blobs_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/languages","stargazers_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/stargazers","contributors_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/contributors","subscribers_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/subscribers","subscription_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/subscription","commits_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/merges","archive_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/downloads","issues_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/labels{/name}","releases_url":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/releases{/id}","created_at":"2013-12-21T22:28:57Z","updated_at":"2015-10-19T07:58:30Z","pushed_at":"2015-10-21T18:40:09Z","git_url":"git://github.com/ScalaConsultants/ScalaConsultants.github.io.git","ssh_url":"git@github.com:ScalaConsultants/ScalaConsultants.github.io.git","clone_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io.git","svn_url":"https://github.com/ScalaConsultants/ScalaConsultants.github.io","homepage":null,"size":5446,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":2,"forks":9,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83"},"html":{"href":"https://github.com/ScalaConsultants/ScalaConsultants.github.io/pull/83"},"issue":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/83"},"comments":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/issues/83/comments"},"review_comments":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83/comments"},"review_comment":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/pulls/83/commits"},"statuses":{"href":"https://api.github.com/repos/ScalaConsultants/ScalaConsultants.github.io/statuses/02994c057708db147fcfd74942f5b9b70969307e"}}}}