{"id":751,"date":"2025-05-18T19:10:45","date_gmt":"2025-05-18T09:10:45","guid":{"rendered":"http:\/\/electricadventures.net\/?p=751"},"modified":"2025-05-18T19:10:45","modified_gmt":"2025-05-18T09:10:45","slug":"lets-make-a-retro-game-ep-4-the-game-loop","status":"publish","type":"post","link":"https:\/\/electricadventures.net\/?p=751","title":{"rendered":"Lets Make a Retro Game: Ep 4: The Game Loop"},"content":{"rendered":"\n<p>In this episode, we are going to cover what steps we need to take to make our game.\u00a0<\/p>\n\n\n\n<p>So, in a way an overview of the structure of our game.<\/p>\n\n\n\n<p>This is often called The Game Loop.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"637\" src=\"http:\/\/electricadventures.net\/wp-content\/uploads\/2025\/05\/image-119-1024x637.png\" alt=\"\" class=\"wp-image-752\"\/><\/figure>\n\n\n\n<p>The video for this episode is available:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Lets Make a Retro Game - Episode 4 - The Game Loop\" width=\"960\" height=\"540\" src=\"https:\/\/www.youtube.com\/embed\/ubSjAiL2iP0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Next episode, we start looking at learning Z80 assembly language.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Breaking Down a Game<\/h1>\n\n\n\n<p>First, we need to break a game down into some smaller steps as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Setup\/Initialisation<\/li>\n\n\n\n<li>Title\/Intro Screen(s)<\/li>\n\n\n\n<li>Start Game<\/li>\n\n\n\n<li>Game Loop<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Setup\/Initialisation<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Title\/Intro Screen(s)<\/h2>\n\n\n\n<p>This is where the title or intro screens of the game will be displayed, and any game options are selected before the actual game play starts.<\/p>\n\n\n\n<p>We need to go through a couple of steps for this section as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Load any graphics and patterns required to display the title screen<\/li>\n\n\n\n<li>Draw the screen<\/li>\n\n\n\n<li>Start a loop<\/li>\n\n\n\n<li>Wait for user input &#8211; could be just a trigger press, selection of a level, etc<\/li>\n\n\n\n<li>Play music &#8211; quite often, nice to have music playing during the title screen<\/li>\n\n\n\n<li>Change Displayed pattern &#8211; an optional step to display a different screen after a while,e e.g. high score table.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Start Game<\/h2>\n\n\n\n<p>Once the player has started the game, we need to set up a few settings, e.g.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Score<\/li>\n\n\n\n<li>Lives<\/li>\n\n\n\n<li>Stage<\/li>\n<\/ul>\n\n\n\n<p>Then we need to load and graphics and patterns for our game, i.e. background tiles, sprites, etc<\/p>\n\n\n\n<p>Then we need to initialise any other hardware, like sound and joysticks, etc<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Game Loop<\/h2>\n\n\n\n<p>Right next, we move onto the most important part, i.e the actual game loop.<\/p>\n\n\n\n<p>There are a number of common sections that we will need as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Get player input &#8211; move our ship left\/right, fire a bullet<\/li>\n\n\n\n<li>Enemy spawn\/initialisation &#8211; should a new enemy appear, what type, etc<\/li>\n\n\n\n<li>Move enemies &#8211; move any enemy sprites that are on screen<\/li>\n\n\n\n<li>Move player &#8211; move the player ship and bullet(s)<\/li>\n\n\n\n<li>Collision detection &#8211; have any of the enemies hit the player or other fixed objects, etc<\/li>\n\n\n\n<li>Animations &#8211; change the displayed pattern of any of the objects on screen that we want to animate<\/li>\n\n\n\n<li>Draw any changes to the screen &#8211; this is most often done during a vBlank, i.e. when the video processor has completed drawing the screen and is returning to the top of the screen to start drawing again.<\/li>\n<\/ul>\n\n\n\n<p>In our next episode, we will be going over Z80 code itself, learning how to read the sample code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this episode, we are going to cover what steps we need to take to make our game.\u00a0 So, in a way an overview of the structure of our game. This is often called The Game Loop. The video for this episode is available: Next episode, we start looking at learning Z80 assembly language. Breaking<\/p>\n","protected":false},"author":1,"featured_media":752,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[62],"tags":[],"class_list":["post-751","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lets-make-a-retro-game"],"acf":[],"_links":{"self":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts\/751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=751"}],"version-history":[{"count":1,"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts\/751\/revisions"}],"predecessor-version":[{"id":753,"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts\/751\/revisions\/753"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/media\/752"}],"wp:attachment":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}