{"id":667,"date":"2018-06-30T23:19:44","date_gmt":"2018-06-30T23:19:44","guid":{"rendered":"http:\/\/brasswatchgames.com\/?p=667"},"modified":"2018-06-30T23:19:44","modified_gmt":"2018-06-30T23:19:44","slug":"shipyard-remake-friendship-ended-with-java-now-c-is-my-best-friend","status":"publish","type":"post","link":"http:\/\/brasswatchgames.com\/?p=667","title":{"rendered":"Shipyard Remake: Friendship ended with Java, now C++ is my best friend"},"content":{"rendered":"<p>When I started the original Shipyard, I only knew how to program in Java, a language which makes it very easy to slap together something basically functional but not particularly efficient. This was only exacerbated by my lack of experience. To pick one of many examples, the game&#8217;s graphics were done entirely with Java&#8217;s built-in graphics and user interface library. This relies entirely on &#8220;software rendering,&#8221; or performing graphics calculations on the CPU\u00a0instead of the graphics card, which means the CPU has to do two jobs while the graphics card sits idle, its potential wasted. I didn&#8217;t understand this at the time, naively assuming that the computer &#8220;just knew&#8221; what part of the code\u00a0did the graphics and assigned it to the graphics card. This poor use of resources limited how\u00a0many\u00a0objects could be on screen at once and how complicated they could be. The big-pixel retro style, originally a stylistic choice, increasingly became necessary to cut down on complexity and get a smooth frame rate.<\/p>\n<p>The new game will be written in C++ instead of Java, using a free library called SFML (the same one I used to make <a href=\"http:\/\/brasswatchgames.com\/?p=294\">that 2D tank game for school<\/a> back in the day) to handle the graphics. SFML uses the computer&#8217;s hardware more efficiently allowing it to draw much more complex graphics and still run more smoothly than the old game. Here&#8217;s just one example, using a shader (a small program that runs on the graphics card) to simulate lighting on a shape in real time, regardless of what direction it&#8217;s facing:<\/p>\n<p><a href=\"http:\/\/brasswatchgames.com\/?attachment_id=656\" rel=\"attachment wp-att-656\"><img data-attachment-id=\"656\" data-permalink=\"http:\/\/brasswatchgames.com\/?attachment_id=656\" data-orig-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/red.png?fit=64%2C64\" data-orig-size=\"64,64\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"red\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/red.png?fit=64%2C64\" data-large-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/red.png?fit=64%2C64\" loading=\"lazy\" class=\"wp-image-656 size-full alignnone\" src=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/red.png?resize=64%2C64\" alt=\"\" width=\"64\" height=\"64\" data-recalc-dims=\"1\" \/><\/a><a href=\"http:\/\/brasswatchgames.com\/?attachment_id=657\" rel=\"attachment wp-att-657\"><img data-attachment-id=\"657\" data-permalink=\"http:\/\/brasswatchgames.com\/?attachment_id=657\" data-orig-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/nrm.png?fit=64%2C64\" data-orig-size=\"64,64\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"nrm\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/nrm.png?fit=64%2C64\" data-large-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/nrm.png?fit=64%2C64\" loading=\"lazy\" class=\"size-full wp-image-657 alignnone\" src=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/nrm.png?resize=64%2C64\" alt=\"\" width=\"64\" height=\"64\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p><a href=\"http:\/\/brasswatchgames.com\/?attachment_id=658\" rel=\"attachment wp-att-658\"><img data-attachment-id=\"658\" data-permalink=\"http:\/\/brasswatchgames.com\/?attachment_id=658\" data-orig-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/shadertest.gif?fit=128%2C128\" data-orig-size=\"128,128\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"shadertest\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/shadertest.gif?fit=128%2C128\" data-large-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/shadertest.gif?fit=128%2C128\" loading=\"lazy\" class=\"size-full wp-image-658 alignnone\" src=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/05\/shadertest.gif?resize=128%2C128\" alt=\"\" width=\"128\" height=\"128\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>On the top left is the base color, or what the shape would look like if it was perfectly lit from every angle. Right of that is the &#8220;normal map,&#8221; which tells the shader what direction each pixel is facing by\u00a0representing X, Y, and Z coordinates\u00a0with the red, green, and blue channels of a color.\u00a0On the bottom\u00a0is the final product, which as you can see stays lit from the top even as it rotates continuously.<a href=\"http:\/\/brasswatchgames.com\/?attachment_id=682\" rel=\"attachment wp-att-682\"><img data-attachment-id=\"682\" data-permalink=\"http:\/\/brasswatchgames.com\/?attachment_id=682\" data-orig-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/06\/Capture.png?fit=208%2C274\" data-orig-size=\"208,274\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Capture\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/06\/Capture.png?fit=208%2C274\" data-large-file=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/06\/Capture.png?fit=208%2C274\" loading=\"lazy\" class=\"aligncenter size-full wp-image-682\" src=\"https:\/\/i0.wp.com\/brasswatchgames.com\/wp-content\/uploads\/2018\/06\/Capture.png?resize=208%2C274\" alt=\"\" width=\"208\" height=\"274\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>In this picture I&#8217;m using a more complicated shader to do several things which had to be done manually in the old Shipyard:<\/p>\n<ul>\n<li>Determining the silhouette of the exterior based on the interior plan of the ship<\/li>\n<li>Creating the &#8220;bevel&#8221; effect on the systems that don&#8217;t have an exterior design<\/li>\n<li>Applying lighting to the ship to make it look three-dimensional<\/li>\n<li>Drawing a black outline around the whole thing<\/li>\n<\/ul>\n<p>What this means for you, the player, is that instead of having to manually place both the interior systems\u00a0<em>and<\/em> exterior tiles, all you do is place the systems and the game automatically creates the exterior from that. Of course, this does limit your creative freedom over the style of the exterior, but I have some plans to remedy that which I&#8217;ll discuss in future posts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I started the original Shipyard, I only knew how to program in Java, a language which makes it very easy to slap together something basically functional but not particularly efficient. This was only exacerbated by my lack of experience. To pick one of many examples, the game&#8217;s graphics were done entirely with Java&#8217;s built-in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[7,2,4],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4ieDM-aL","jetpack-related-posts":[{"id":192,"url":"http:\/\/brasswatchgames.com\/?p=192","url_meta":{"origin":667,"position":0},"title":"Sooper Seecret New Project?","date":"July 23, 2014","format":false,"excerpt":"In my previous post,\u00a0I\u00a0hinted that, in addition to getting back to work on Shipyard, I had also started a \"secret new project\" that I would share if it went well. Well, thus far, that seems to be the case, so here's a little sneak-peak of what I have so far:\u2026","rel":"","context":"In &quot;Game Development News&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":655,"url":"http:\/\/brasswatchgames.com\/?p=655","url_meta":{"origin":667,"position":1},"title":"What Happened to Shipyard?","date":"May 20, 2018","format":false,"excerpt":"You may have noticed that\u00a0this website hasn't been awfully active lately, with only\u00a0one\u00a0off-topic post in 2017\u00a0and none this year. There are many reasons for this, not the least of which being poor overall mental health sapping my motivation to take care of myself at a basic level, let alone develop\u2026","rel":"","context":"In &quot;Blogs &amp; Other&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":288,"url":"http:\/\/brasswatchgames.com\/?p=288","url_meta":{"origin":667,"position":2},"title":"Server Troubles: Two Months Later","date":"January 31, 2015","format":false,"excerpt":"The server problem which was preventing me from uploading Shipyard version 0.8.1a is, apparently, still an issue. I tried again to upload the update today (24 Jan. 2015) and it seems waiting for it to sort itself out isn't going to help matters. It's bad enough that this is occurring\u2026","rel":"","context":"In &quot;Game Development News&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":76,"url":"http:\/\/brasswatchgames.com\/?p=76","url_meta":{"origin":667,"position":3},"title":"Shipyard Pre-Alpha 0.7.4 Released!","date":"February 21, 2014","format":false,"excerpt":"This is the last in the series of \"preparation\" updates for the big Combat Update. Major features include AI ships that follow you around (they don't attack yet -- that's next update), a new station, a new weapon, and a bunch of UI tweaks and fixes. As always, full details\u2026","rel":"","context":"In &quot;Game Development News&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":60,"url":"http:\/\/brasswatchgames.com\/?p=60","url_meta":{"origin":667,"position":4},"title":"Shipyard: The Combat Update &#8212; Progress Report #3","date":"February 16, 2014","format":false,"excerpt":"It's getting close to time to start on the actual combat system, but there's just a little more preparation before that can happen. Everything here is coming in version 0.7.4, which will be the last of the minor updates leading up to the combat update. So, without further ado, let's\u2026","rel":"","context":"In &quot;Game Development News&quot;","img":{"alt_text":"AI Ships Early Preview","src":"https:\/\/i0.wp.com\/www.brasswatchgames.com\/wp-content\/uploads\/2014\/02\/scrn_2014_02_15_1392520891147-1024x576.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":58,"url":"http:\/\/brasswatchgames.com\/?p=58","url_meta":{"origin":667,"position":5},"title":"Shipyard PA 0.7.3 and Launcher 2.1 released!","date":"February 7, 2014","format":false,"excerpt":"Shipyard pre-alpha 0.7.3 has been released! This is the second if the series of preliminary updates gearing up for the addition of combat. This time, it adds the crew and power tab to the View Ship screen, as well as some other minor stuff. See the Shipyard page for downloads\u2026","rel":"","context":"In &quot;Game Development News&quot;","img":{"alt_text":"Crew and Power Management","src":"https:\/\/i0.wp.com\/www.brasswatchgames.com\/wp-content\/uploads\/2014\/02\/scrn_2014_02_05_1391671070606-1024x576.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=\/wp\/v2\/posts\/667"}],"collection":[{"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=667"}],"version-history":[{"count":3,"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=\/wp\/v2\/posts\/667\/revisions"}],"predecessor-version":[{"id":686,"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=\/wp\/v2\/posts\/667\/revisions\/686"}],"wp:attachment":[{"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/brasswatchgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}