{"id":56,"date":"2024-06-26T21:47:00","date_gmt":"2024-06-26T21:47:00","guid":{"rendered":"https:\/\/shrubbgames.com\/?p=56"},"modified":"2024-06-28T01:52:21","modified_gmt":"2024-06-28T01:52:21","slug":"vv-eekly-update-3-godot","status":"publish","type":"post","link":"https:\/\/shrubbgames.com\/?p=56","title":{"rendered":"VV Eekly Update #3 \u2013 Godot"},"content":{"rendered":"\n<p>Welcome back to VV Eekly Update. This week, let&#8217;s go in a slightly different direction than the past two weeks and talk about the actual development of Vyn and Verdan.<\/p>\n\n\n\n<p class=\"has-huge-font-size\">Godot<\/p>\n\n\n\n<p>Godot is the game engine used to create Vyn and Verdan. It&#8217;s free and open-source &#8211; you can download it and open it right now!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"554\" src=\"https:\/\/shrubbgames.com\/wp-content\/uploads\/2024\/06\/image-1024x554.png\" alt=\"\" class=\"wp-image-34\" srcset=\"https:\/\/shrubbgames.com\/wp-content\/uploads\/2024\/06\/image-1024x554.png 1024w, https:\/\/shrubbgames.com\/wp-content\/uploads\/2024\/06\/image-300x162.png 300w, https:\/\/shrubbgames.com\/wp-content\/uploads\/2024\/06\/image-768x416.png 768w, https:\/\/shrubbgames.com\/wp-content\/uploads\/2024\/06\/image-1536x831.png 1536w, https:\/\/shrubbgames.com\/wp-content\/uploads\/2024\/06\/image.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Screenshot of actual Vyn and Verdan development<\/figcaption><\/figure>\n\n\n\n<p>Godot has been under development for a long while, and it&#8217;s been becoming much more popular due to the recent <a href=\"https:\/\/www.theverge.com\/23873852\/unity-new-pricing-model-news-updates\" title=\"\">Unity debacle<\/a>. A few fairly successful games are made with Godot, including <a href=\"https:\/\/store.steampowered.com\/app\/1942280\/Brotato\/\" title=\"\">Brotato<\/a> and the upcoming <a href=\"https:\/\/store.steampowered.com\/app\/2868840\/Slay_the_Spire_2\/\" title=\"\">Slay the Spire 2<\/a>. Godot has its own custom language called <a href=\"https:\/\/docs.godotengine.org\/en\/stable\/tutorials\/scripting\/gdscript\/gdscript_basics.html\" title=\"\">GDScript<\/a>, or you can use C#. I have chosen to use GDScript, and that&#8217;s what we&#8217;ll be talking about here.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><a href=\"https:\/\/docs.godotengine.org\/en\/stable\/tutorials\/scripting\/gdscript\/gdscript_basics.html#doc-gdscript\">GDScript<\/a>&nbsp;is a high-level,&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Object-oriented_programming\">object-oriented<\/a>,&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Imperative_programming\">imperative<\/a>, and&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Gradual_typing\">gradually typed<\/a>&nbsp;programming language built for Godot. It uses an indentation-based syntax similar to languages like&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Python_%28programming_language%29\">Python<\/a>. Its goal is to be optimized for and tightly integrated with Godot Engine, allowing great flexibility for content creation and integration.<\/p>\n<cite>&#8211; GDScript Reference Page<\/cite><\/blockquote>\n\n\n\n<p><strong>As a fairly experienced software engineer, I chose to go with Godot when developing Vyn and Verdan due to its open-source nature and good reputation for documentation.<\/strong><\/p>\n\n\n\n<p>Other game engines might or might not be more powerful, but I can&#8217;t use features that I don&#8217;t know or can&#8217;t learn about. The standard documentation covers a surprising amount of the capabilities of Godot, and the rest is usually covered by someone making a free tutorial on YouTube. I&#8217;ve been very grateful that many people have taken time to explain how to work in Godot and GDScript. In that spirit, I want to release back to the community some of the things I&#8217;ve been learning about Godot from the perspective of an experienced systems-oriented backend software engineer.<\/p>\n\n\n\n<p><strong>I&#8217;ll be talking less about <em>what<\/em> you can do with Godot &#8211; syntax and code &#8211; and more about <em>how<\/em> you can work with Godot &#8211; design and patterns.<\/strong> I&#8217;ll assume that you have a basic understanding of Godot syntax, but please feel free to ask for clarifications!<\/p>\n\n\n\n<p class=\"has-huge-font-size\">Setters and Getters<\/p>\n\n\n\n<p>In Godot, each property in a class can be defined with a <em>setter<\/em> and a <em>getter<\/em>. I have found setters to be much more useful than getters, but they are both powerful tools. The <a href=\"https:\/\/docs.godotengine.org\/en\/stable\/tutorials\/scripting\/gdscript\/gdscript_basics.html#properties-setters-and-getters\" title=\"\">documentation<\/a> makes a brief reference to setters and getters, but I think they&#8217;re useful enough in GDScript to warrant a special callout. Here are some examples where setters or getters are useful:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Ensures various properties are synced.\nvar is_speedy := false :\n    set(val):\n        is_speedy = val\n        speedy_sprite.visible = val\n        play_speedy_sound()<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># behavior_type is synced to multiplayer clients via RPCs.\n# behavior cannot be synced directly via RPCs since it's an object.\nvar behavior_type : String :\n    set(val):\n        behavior_type = val\n        behavior = load_behavior(behavior_type)\nvar behavior : Behavior\n\n\n# Alternate setup if behavior is not expensive to load.\nvar behavior_type : String\nvar behavior : Behavior :\n    get:\n        return load_behavior(behavior_type)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># We need to wait for the players to be set before setting the camera.\nvar camera_player : PlayerNum :\n    set(val):\n        camera_player = val\n        if !are_players_ready():\n            await players_set\n       set_camera(camera_player)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># Boss health should trigger stage changes.\nvar boss_health : float :\n    set(val):\n        boss_health = val\n        boss_health_changed.emit(boss_health)  # Emit a custom signal.\n\n        if boss_health &lt; 30:\n            stage_num = 3\n        elif boss_health &lt; 60:\n            stage_num = 2<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># A room needs to know which floor it is on before setting the\n# atmosphere, so let's wait until the floor num is set.\nvar floor_num : int :\n    set(val):\n        set_lighting(floor_num)\n        set_music(floor_num)\n\n        # Wait for the node to be ready, then pass the floor num on.\n        if !is_node_ready():\n            await ready\n        reward_chest.set_floor_num(floor_num)<\/code><\/pre>\n\n\n\n<p>That&#8217;s enough examples for now, although even more will be coming when we talk about multiplayer and RPCs in the future. For now, please feel free to set any comments in the Discord (or go do something with Godot)!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome back to VV Eekly Update. This week, let&#8217;s go in a slightly different direction than the past two weeks and talk about the actual development of Vyn and Verdan. Godot Godot is the game engine used to create Vyn and Verdan. It&#8217;s free and open-source &#8211; you can download it and open it right [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":73,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[3],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vv-eekly-updates"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/shrubbgames.com\/index.php?rest_route=\/wp\/v2\/posts\/56"}],"collection":[{"href":"https:\/\/shrubbgames.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shrubbgames.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shrubbgames.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shrubbgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=56"}],"version-history":[{"count":2,"href":"https:\/\/shrubbgames.com\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":77,"href":"https:\/\/shrubbgames.com\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/77"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shrubbgames.com\/index.php?rest_route=\/wp\/v2\/media\/73"}],"wp:attachment":[{"href":"https:\/\/shrubbgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shrubbgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shrubbgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}