{"id":904,"date":"2026-02-13T09:26:58","date_gmt":"2026-02-13T01:26:58","guid":{"rendered":"https:\/\/edu.circuspi.com\/?p=904"},"modified":"2026-03-09T16:05:28","modified_gmt":"2026-03-09T08:05:28","slug":"9-2-making-sprites-move-automatically-adding-life-health-function","status":"publish","type":"post","link":"https:\/\/edu.circuspi.com\/index.php\/gamebit-en\/9-2-making-sprites-move-automatically-adding-life-health-function\/","title":{"rendered":"9.2 Making Sprites Move Automatically \u2013 Adding Life (Health) Function"},"content":{"rendered":"\n<p>We want to set a rule: during the game, if the controlled sprite touches the enemy, health will be deducted. Since our current game doesn&#8217;t have a health design, we need to add this feature. Click on &#8220;<strong>Info<\/strong>&#8221; in the <strong>Block Toolbox<\/strong>. You can see blocks related to &#8220;<strong>Life<\/strong>&#8221; here.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"391\" src=\"https:\/\/edu.circuspi.com\/wp-content\/uploads\/2026\/02\/eng-09-2_01.png\" alt=\"\" class=\"wp-image-1228\"\/><\/figure>\n\n\n\n<p>Just like the &#8220;<strong>Score<\/strong>&#8221; blocks in the previous unit, simply drag the Life-related blocks into the <strong>Workspace<\/strong>. After assembling the code correctly, a heart icon will appear in the top-left corner of the <strong>Game Simulator<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"539\" height=\"443\" src=\"https:\/\/edu.circuspi.com\/wp-content\/uploads\/2026\/02\/eng-09-2_02.png\" alt=\"\" class=\"wp-image-1229\"\/><\/figure>\n\n\n\n<p>Now, drag the &#8220;<strong>set life to ( 3 )<\/strong>&#8221; block into &#8220;<strong>on start<\/strong>.&#8221; It can be placed anywhere, as long as it is <strong>before<\/strong> the &#8220;<strong>start countdown ( 10 ) seconds<\/strong>&#8221; block.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"336\" height=\"212\" src=\"https:\/\/edu.circuspi.com\/wp-content\/uploads\/2026\/02\/eng-09-2_03.png\" alt=\"\" class=\"wp-image-1231\"\/><\/figure>\n\n\n\n<p>You can set the number of lives yourself. You can even set it to 100. Note that if the number exceeds 4 hearts, the display style will automatically adjust to avoid blocking the screen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"327\" height=\"438\" src=\"https:\/\/edu.circuspi.com\/wp-content\/uploads\/2026\/02\/eng-09-2_04.png\" alt=\"\" class=\"wp-image-1232\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>We want to set a rule: during the game, if the controll [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,23],"tags":[],"table_tags":[],"class_list":{"0":"post-904","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-gamebit-en","8":"category-freeinfo-en","9":"czr-hentry"},"_links":{"self":[{"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/comments?post=904"}],"version-history":[{"count":2,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/904\/revisions"}],"predecessor-version":[{"id":1247,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/904\/revisions\/1247"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/media\/450"}],"wp:attachment":[{"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/media?parent=904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/categories?post=904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/tags?post=904"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/edu.circuspi.com\/index.php\/wp-json\/wp\/v2\/table_tags?post=904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}