{"id":240,"date":"2018-05-30T18:00:37","date_gmt":"2018-05-30T23:00:37","guid":{"rendered":"http:\/\/www.chroniclesoftright.com\/blog\/?p=240"},"modified":"2018-05-30T09:10:03","modified_gmt":"2018-05-30T14:10:03","slug":"piggies-in-a-ditch","status":"publish","type":"post","link":"https:\/\/www.chroniclesoftright.com\/blog\/2018\/05\/30\/piggies-in-a-ditch\/","title":{"rendered":"Piggies in a ditch"},"content":{"rendered":"<p>Here&#8217;s screenshot showing the boars following the terrain as they move around:<\/p>\n<p><a href=\"http:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.30.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-241\" src=\"http:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.30-300x160.png\" alt=\"\" width=\"300\" height=\"160\" srcset=\"https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.30-300x160.png 300w, https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.30-768x409.png 768w, https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.30-1024x546.png 1024w, https:\/\/www.chroniclesoftright.com\/blog\/wp-content\/uploads\/2018\/05\/Lyridia-2018.05.30.png 1852w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>I&#8217;ve been thinking about how I want to do things like this.\u00a0 Specifically, how much I want the client to control the world, and how much the server should control.\u00a0 Right now the server only keeps up with the x and z coordinates of each boar.\u00a0 The client (browser) then takes those coordinates and figures out the terrain&#8217;s height at that point, then draws the boar there.\u00a0 I&#8217;m doing it this way because determining the terrain&#8217;s height requires access to the terrain data as well as the THREE.js raycasting function, and giving the server access to that information would make it much more complicated so I just haven&#8217;t done it yet.\u00a0 This probably isn&#8217;t a workable scheme in the long run.\u00a0 Soon enough I&#8217;ll want players to be able to attack the boars, but to do that I&#8217;ll need to know if the boar is within the player&#8217;s attack range, which will require definitive information about the boar and player&#8217;s x, y, and z positions.\u00a0 In order to prevent cheating or otherwise messing with the game, I think I&#8217;m going to have to assume the client is completely untrustworthy.\u00a0 It&#8217;s basically a terminal that displays what the server tells it to.<\/p>\n<p>This is, of course, not the final answer on this topic.\u00a0 It&#8217;s something I will need to do much more research and testing on because I&#8217;m making some significant assumptions to come up with the conclusion above.\u00a0 But for now the boars roam around on the terrain and everyone is happy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s screenshot showing the boars following the terrain as they move around: I&#8217;ve been thinking about how I want to do things like this.\u00a0 Specifically, how much I want the client to control the world, and how much the server should control.\u00a0 Right now the server only keeps up with the x and z coordinates&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-240","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\/240","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=240"}],"version-history":[{"count":1,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"predecessor-version":[{"id":242,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/240\/revisions\/242"}],"wp:attachment":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}