{"id":222,"date":"2018-05-24T18:00:52","date_gmt":"2018-05-24T23:00:52","guid":{"rendered":"http:\/\/www.chroniclesoftright.com\/blog\/?p=222"},"modified":"2018-05-24T09:12:50","modified_gmt":"2018-05-24T14:12:50","slug":"starting-with-enemies","status":"publish","type":"post","link":"https:\/\/www.chroniclesoftright.com\/blog\/2018\/05\/24\/starting-with-enemies\/","title":{"rendered":"Starting with enemies"},"content":{"rendered":"<p>Look at these lovely little piggies:<\/p>\n<p><a href=\"http:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.24.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-223\" src=\"http:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.24-300x160.png\" alt=\"\" width=\"300\" height=\"160\" srcset=\"https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.24-300x160.png 300w, https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.24-768x410.png 768w, https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.24-1024x546.png 1024w, https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.24.png 1852w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>I realize, again, that it&#8217;s hard to get a real sense of what&#8217;s happening here since it&#8217;s a still frame but the boar models are moving around in a random pattern.\u00a0 Every 1 second the server sends an update to every client with the new location of each boar.\u00a0 Each boar moves a random amount in the x and z directions and stays within a certain range.\u00a0 This is super basic functionality but it&#8217;s neat because it&#8217;s controlled by the server so every player sees the randomly placed boars in the same places.\u00a0 Eventually I&#8217;ll need some actual &#8220;intelligence&#8221; in the ways the boars move around, but for now this is ok.<\/p>\n<p>You may have noticed there&#8217;s no player character in the screenshot above.\u00a0 I&#8217;m still struggling with getting that working on my secondary machine that I&#8217;m using today.\u00a0 Also, the boars don&#8217;t react to the terrain.\u00a0 That opens a can of worms I&#8217;ll have to handle eventually, specifically how much of the game is running on the server and how much is in the client.\u00a0 For instance, should the server somehow load the entire world and make decisions about collision detection, terrain height, etc., or should I leave much of that to the client to just tell the server what the world is like?\u00a0 I&#8217;m guessing it will end up as some sort of hybrid between the two, but that&#8217;s definitely a design topic I haven&#8217;t tackled mentally or in the code, so it will be fun to figure out eventually.<\/p>\n<p>Lastly, I installed <a href=\"https:\/\/www.npmjs.com\/package\/forever\" target=\"_blank\" rel=\"noopener\">Forever<\/a> on my server so that I can leave the <a href=\"http:\/\/nodejs.org\" target=\"_blank\" rel=\"noopener\">Node<\/a> server running all the time.\u00a0 Since the next release will include multiplayer\u00a0 (and now some random boars) it becomes dependent on the server running all the time, and Forever allows me to do that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Look at these lovely little piggies: I realize, again, that it&#8217;s hard to get a real sense of what&#8217;s happening here since it&#8217;s a still frame but the boar models are moving around in a random pattern.\u00a0 Every 1 second the server sends an update to every client with the new location of each boar.\u00a0&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-222","post","type-post","status-publish","format-standard","hentry","category-planning-and-development"],"_links":{"self":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/comments?post=222"}],"version-history":[{"count":1,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/222\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/222\/revisions\/224"}],"wp:attachment":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/media?parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/categories?post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/tags?post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}