{"id":172,"date":"2025-09-19T19:30:10","date_gmt":"2025-09-19T19:30:10","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/a_carpenter\/?p=172"},"modified":"2025-09-19T19:30:10","modified_gmt":"2025-09-19T19:30:10","slug":"free-friday-9-19-25","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/a_carpenter\/2025\/09\/19\/free-friday-9-19-25\/","title":{"rendered":"Free Friday 9\/19\/25"},"content":{"rendered":"\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\n<p><strong>Today I began Working with Godot. I made a two-dimensional character who swims by following a tutorial.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"476\" height=\"719\" src=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-19-152449.png\" alt=\"\" class=\"wp-image-173\" style=\"width:311px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-19-152449.png 476w, https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-19-152449-199x300.png 199w\" sizes=\"auto, (max-width: 476px) 100vw, 476px\" \/><\/figure>\n<\/div>\n\n\n\n<p><strong>And my code:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>extends Area2D\n\nsignal hit\n\n@export var speed = 400\nvar screen_size\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready() -> void:\n\tscreen_size = get_viewport_rect().size\n\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta: float) -> void:\n\tvar velocity = Vector2.ZERO #player movement vector\n\tif Input.is_action_pressed(\"move_right\"):\n\t\tvelocity.x += 1\n\tif Input.is_action_pressed(\"move_left\"):\n\t\tvelocity.x -= 1\n\tif Input.is_action_pressed(\"move_down\"):\n\t\tvelocity.y += 1\n\tif Input.is_action_pressed(\"move_up\"):\n\t\tvelocity.y -= 1\n\t\n\tif velocity.length() > 0:\n\t\tvelocity = velocity.normalized() * speed\n\t\t$AnimatedSprite2D.play()\n\telse:\n\t\t$AnimatedSprite2D.stop()\n\t\t\n\tif velocity.x != 0:\n\t\t$AnimatedSprite2D.animation = \"walk\"\n\t\t$AnimatedSprite2D.flip_v = false\n\t\t# See the note below about the following boolean assignment.\n\t\t$AnimatedSprite2D.flip_h = velocity.x &lt; 0\n\telif velocity.y != 0:\n\t\t$AnimatedSprite2D.animation = \"up\"\n\t\t$AnimatedSprite2D.flip_v = velocity.y > 0\n\t\t\n\tposition += velocity * delta\n\tposition = position.clamp(Vector2.ZERO, screen_size)\n\n\nfunc _on_body_entered(body: Node2D) -> void:\n\thide()\n\thit.emit()\n\t$CollisionShape2D.set_deferred(\"disabled\", true)\n\t\nfunc start(pos):\n\tposition = pos\n\tshow()\n\t$CollisionShape2D.disabled = false\n<\/em>\t<\/code><\/pre>\n\n\n\n<p><strong>Soon<\/strong> <strong>I will add a background, enemies, and maybe even powerups.<\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I began Working with Godot. I made a two-dimensional character who swims by following a tutorial. And my code: Soon I will add a background, enemies, and maybe even powerups.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-172","post","type-post","status-publish","format-standard","hentry","category-friday"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts\/172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/comments?post=172"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts\/172\/revisions"}],"predecessor-version":[{"id":174,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts\/172\/revisions\/174"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/media?parent=172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/categories?post=172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/tags?post=172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}