{"id":574,"date":"2025-07-27T15:25:24","date_gmt":"2025-07-27T05:25:24","guid":{"rendered":"https:\/\/nonlinearexperience.com\/?p=574"},"modified":"2025-07-27T15:53:32","modified_gmt":"2025-07-27T05:53:32","slug":"game-objects","status":"publish","type":"post","link":"https:\/\/nonlinearexperience.com\/index.php\/2025\/07\/27\/game-objects\/","title":{"rendered":"Game objects"},"content":{"rendered":"<h1 class=\"wp-block-post-title\">Game objects<\/h1>\n\n\n<p>See also:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Any game object can pass in its own animation definition\/behaviour (into the sprite object, which also handles animation<br>Game objects all have an ID &#8211; it is drawn from the data in overworldMap\u2026<\/p>\n\n\n\n<p>Game objects are drawn in order of the data &#8211; e.g. top most item in data is drawn FIRST and then will be at the BOTTOM of the stack\u2026<\/p>\n\n\n\n<p>Game objects &#8211; how to add in new ones<br>see: Creating Pizzas for the Lineup! Pizza RPG Ep. 14 <a href=\"https:\/\/www.youtube.com\/watch?v=r74OW5olIMI&amp;list=PLcjhmZ8oLT0r9dSiIK6RB_PuBWlG1KSq_&amp;index=23\">https:\/\/www.youtube.com\/watch?v=r74OW5olIMI&amp;list=PLcjhmZ8oLT0r9dSiIK6RB_PuBWlG1KSq_&amp;index=23<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Make new gameObject <\/strong><strong><em>PlayerState<\/em><\/strong><\/p>\n\n\n\n<p>Make a new file &#8220;pizzaStone.js&#8217; and add to HTML<\/p>\n\n\n\n<p>It will extend GameObject &#8211; this is the pattern:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nclass PizzaStone extends GameObject {\n\u00a0\u00a0\u00a0\u00a0constructor(config){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0super(config);\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0}\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p><strong>A more fleshed out version of <\/strong><strong><em>PizzaStone.js<\/em><\/strong><\/p>\n\n\n\n<p>(1:12) <a href=\"https:\/\/www.youtube.com\/watch?v=r74OW5olIMI&amp;list=PLcjhmZ8oLT0r9dSiIK6RB_PuBWlG1KSq_&amp;index=23\">Creating Pizzas for the Lineup! Pizza RPG Ep. 14<\/a><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nclass PizzaStone extends GameObject {\n\u00a0\u00a0\u00a0\u00a0constructor(config){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0super(config);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.sprite = new Sprite({\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0gameObject: this,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0src: &quot;images\/characters\/pizza-stone.png&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0animations: {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;used-down&quot; \u00a0 : &#x5B; &#x5B;0,0] ],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;unused-down&quot; : &#x5B; &#x5B;1,0] ],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0},\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0currentAnimation: &quot;used-down&quot;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\n\u00a0\u00a0\u00a0\u00a0}\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The pizza stone and dough ball\u2026<\/p>\n\n\n\n<p>64&#215;32 pixels<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf0BR6_FfGxlk1qXNdiiw5rnDnJeglwWIU4JgqhdcnutXXIxDukFUQOzXw8nvNCYcdVcyjhhuO2fPybfbpbm_nPYh7u-h4BkRdTkHKbPsdHWToq-jQExpNKAOCorqQJypWyvOJsNUZX_xpqK1KiUT7fSk5D?key=-XKYfBSXpJ_6Ax12RysESw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Add the pizza stone to <\/strong><strong><em>OverworldMap.js<\/em><\/strong><\/p>\n\n\n\n<p>Place it in the demo room<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\npizzaStone: new PizzaStone({\n\u00a0\u00a0\u00a0x: utils.withGrid(2),\n\u00a0\u00a0\u00a0y: utils.withGrid(7)\n})\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p>Already, it is in the room, and is not walkable:)<\/p>\n\n\n\n<p><strong>Add a &#8216;used pizza stone&#8217; story flag in <\/strong><strong><em>OverworldMap.js<\/em><\/strong><\/p>\n\n\n\n<p>Add a story flag to the pizza stone in the map:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\npizzaStone: new PizzaStone({\n\u00a0\u00a0\u00a0\/\/ CODE OMITTED\u2026\n\u00a0\u00a0\u00a0storyFlag: &quot;USED_PIZZA_STONE&quot;\n})\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p><strong>Handle the story flag in <\/strong><strong><em>PizzaStone.js<\/em><\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nclass PizzaStone extends GameObject {\n\u00a0\u00a0\u00a0\u00a0constructor(config){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ CODE OMITTED\u2026\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.storyFlag = config.storyFlag;\n\u00a0\u00a0\u00a0\u00a0}\n}\nupdate() {\n\u00a0\u00a0\u00a0this.sprite.currentAnimation = playerState.storyFlags&#x5B;this.storyFlag]\n\u00a0\u00a0\u00a0? &quot;used-down&quot;\n\u00a0\u00a0\u00a0: &quot;unused-down&quot;;\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p><strong>Adding the talking into <\/strong><strong><em>PizzaStone.js<\/em><\/strong><\/p>\n\n\n\n<p>(6:10) <a href=\"https:\/\/www.youtube.com\/watch?v=r74OW5olIMI&amp;list=PLcjhmZ8oLT0r9dSiIK6RB_PuBWlG1KSq_&amp;index=23\">Creating Pizzas for the Lineup! Pizza RPG Ep. 14<\/a><\/p>\n\n\n\n<p>Two approaches to talking &#8211; see <a href=\"https:\/\/docs.google.com\/document\/d\/1-F5AUCgCMoi2p-x4N3mE8R-R8_VvGjWPZEpikCZUDdw\/edit#heading=h.m4vqfuq11048\">Talking and messages &#8211; two approaches<\/a><\/p>\n\n\n\n<p>We go with <strong>OPTION 2<\/strong> here\u2026<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nthis.talking = &#x5B;\n\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0required: &#x5B;this.storyFlag],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0events: &#x5B;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ type: &quot;textMessage&quot;, text: &quot;You have already used this.&quot;},\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\n\u00a0\u00a0\u00a0},\n\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0events: &#x5B;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ type: &quot;textMessage&quot;, text: &quot;Approaching the legendary pizza stone...&quot;},\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ type: &quot;addStoryFlag&quot;, flag: this.storyFlag}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\n\u00a0\u00a0\u00a0}\n]\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p><strong>Allow ability to pass in pizzas from config in <\/strong><strong><em>PizzaStone.js<\/em><\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nclass PizzaStone extends GameObject {\n\u00a0\u00a0\u00a0constructor(config){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ CODE OMITTED\u2026\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.storyFlag = config.storyFlag;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.pizzas = config.pizzas;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.talking = &#x5B;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ CODE OMITTED\u2026\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0events: &#x5B;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ type: &quot;textMessage&quot;, text: &quot;Approaching the legendary pizza stone...&quot;},\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ type: &quot;craftingMenu&quot;, pizzas: this.pizzas },\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ type: &quot;addStoryFlag&quot;, flag: this.storyFlag}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\n\u00a0\u00a0\u00a0}\n\/\/ CODE OMITTED\u2026\npizzaStone: new PizzaStone({\n\u00a0\u00a0\u00a0x: utils.withGrid(2),\n\u00a0\u00a0\u00a0y: utils.withGrid(7),\n\u00a0\u00a0\u00a0storyFlag: &quot;USED_PIZZA_STONE&quot;,\n\u00a0\u00a0\u00a0pizzas: &#x5B;&quot;v001&quot;, &quot;f001&quot;],\n})\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p>It should now appear on screen &#8211; now, you can add extra stuff, as needed.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>See also: Any game object can pass in its own animation definition\/behaviour (into the sprite object, which also handles animationGame objects all have an ID &#8211; it is drawn from the data in overworldMap\u2026 Game objects are drawn in order of the data &#8211; e.g. top most item in data is drawn FIRST and then [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"wp-custom-template-nlx-the-knowledge-page","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-574","post","type-post","status-publish","format-standard","hentry","category-the-knowledge"],"_links":{"self":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/comments?post=574"}],"version-history":[{"count":2,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/574\/revisions"}],"predecessor-version":[{"id":578,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/574\/revisions\/578"}],"wp:attachment":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/media?parent=574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/categories?post=574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/tags?post=574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}