{"id":1394,"date":"2024-12-12T10:52:13","date_gmt":"2024-12-12T05:52:13","guid":{"rendered":"https:\/\/obsidianeducation.wordpress.com\/?page_id=1394"},"modified":"2025-02-10T08:44:59","modified_gmt":"2025-02-10T08:44:59","slug":"snake-game-app-inventor-part-2-how-to-make-snake-game-in-mit-app-inventor","status":"publish","type":"page","link":"https:\/\/obsidiansofteducation.com\/index.php\/snake-game-app-inventor-part-2-how-to-make-snake-game-in-mit-app-inventor\/","title":{"rendered":"Snake game App Inventor (PART 2) | How to make Snake Game in MIT App Inventor"},"content":{"rendered":"\n<p class=\"has-medium-font-size wp-block-paragraph\">We started the classic Nokia snake game in the <a href=\"https:\/\/obsidiansofteducation.com\/index.php\/snake-game-app-inventor-part-1-how-to-make-snake-game-in-mit-app-inventor\/\"><strong>last tutorial<\/strong><\/a> and we will finish its code today.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">We are going to start with the snake\u2019s movement logic.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">First, remember the screen coordinate system: The x coordinate increases when we move right and decreases when we move left. The y coordinate increases when we move down and decreases when we move up.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXdG_CWdpEOS6rUDBrJqJpvYOYNeOe0uI1YVdSEYCfwXwqlCUNCwmAfgaZZijN1ihQUSF2FHH1BkcOOlM-CgIBQvOexPSidAzm8T4dTDYF1nwMz7E3YmPAgOnZts0IYyx8CUxOE5KyVwCAslJExFW1CRvWj1keymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In each game loop i.e. clock\u2019s timer event of 300 milliseconds, we will call a snake movement procedure.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Let\u2019s see what will happen in this procedure:<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Our snake head starts at position 50,50<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">State of the lists:<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeXList = [50]<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeYList =[50]<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXcoH7EG1gd4smVn1HLvFMDjhLzORHwGaVgfqwY335x0WB2XMVlX3SCkT8Rru57mcN2dwwjl8YHOECdcLiFmaijJ4UE-UP174N3YuNSG2-6XmArHdavZVl37xAukDG3gDW7IyJfYTFwqKgtlArKdaAYcHm8dkeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Let\u2019s assume that the user presses the right arrow button.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, in our moveSnake procedure,&nbsp;<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">We will check the direction and if it is equal to RIGHT, we will insert a new head at index =1 with movement pixels=16 added to the previous head\u2019s X i.e. 50. Our new head\u2019s Y will stay the same<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, now this is the state of our lists:<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeXList = [66, 50]<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeYList =[50, 50]<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXeTlE0T-DWOG-raeppRYn0kyAEAS3DXF2hltdxagbPrE7U7qW5zx_agphPpMlJMjziUu9MdDqkcVauXCGBwAJfq1-jjYp9Qyv2R0dy-WJ1EAtJ32SacIct4r8-ODEWppw0dAzXyIQGrlI3GjYzpebuBrT8keymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">But as you notice, our snake has grown without eating food, so we are going to check if it has eaten food. If it hasn\u2019t, then we will remove the tail, i.e., the last segment in our snake, which in this scenario is the previous head at index =2.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, now this is the state of our lists:<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeXList = [66]<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeYList =[50]<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">You can see that our snake will look as if it has moved right in this cool way of just inserting a new head and removing the extra tail.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXe8hKafMxjTsTj-qtwN6tbENrYwix1wcdD4ndMmwUY3RY_w0vdaCq8Gdr0jD_kqk2ZI_DyDjlZXZldqyn3_aCmPJ8yviKuDnLMGH8iOhS4nQ0Z6Nf7bh2mXIUmgBt8G0tA3ZtqHsHknig0LhZDdgH21ZKd-keymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">After another 300 ms, we will come inside the snake move procedure again and check for directions. Assuming that it is still RIGHT, we will insert another head after adding 16 to the previous head\u2019s X.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, now this is the state of our lists:<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeXList = [82, 66]<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">snakeYList =[50, 50]<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXfrpkq0-BW1Fs2DWxpHXFcEX68rxI6dJRIAI2sxZ9_qno4T_kOk5omh_Kf2vwif8-E-TGNrcLurOTjCF-dyNvK7P3FFl-3MMOF6RZi7tgj_fsQxrJLxTs4W5ljbB8WeETmAwMSCoDt_JAeYMW_wN3_5oTd2keymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">We will also check if the snake\u2019s head is touching food which is true so we will not remove the tail.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXcH3CguTqQxPcjNHfcTU-IhTnnJLOm_u0FJmQqJJF_omc0wfIbAr1ip0JDkOfqqo6RBbJC2VAjNwW0vE-VBDrSg08GXtgHZShUMRl6_CoLkoWxvyTjJTU1c5wjANBA3JA4xIkpmL_m5_YtaxZr2RjeZtv1akeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, this is the basic way our snake moves.&nbsp;<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, let\u2019s work on the moveSnake procedure:<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">First, we make two local variables for storing previousHeadX and previousHeadY values which are values at index 1 for snakeXlist and snakeYlist. We need to store these for later use. Then we insert a new head at index 1 after calculating its new position depending on the value of direction.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXe8lBfjtZvYtOSBcyfHxaVjH0EM57xU6GvRyks2H3wryrnOk8iuer2XzkvqkrOGyTj48MB6H6FmfGz2mIjHVxpeXTkVitFKaBOf4U0QQ-s9rZE34Eq9L79qYVxTpsFmpaC8zHfwErFgvzP23Fmc2NEBaYwkeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, depending on the direction, we have inserted a new head.&nbsp;<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, we will check if we need to remove the tail. I will work on the collision detection code later so let\u2019s just put an if\/else block from control. The condition being true will mean that food was eaten. I will work on that later but the other condition means food was not eaten so remove the extra tail. Tail is the last segment in our snake so it will correspond to index = length of list. Remember that we must remove it from both the X and Y lists.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXe37eIY_PHTwdMedN1VmkgCrcdiNN2KGnelN53BPQ9QPn1mrYmHYQzx6Aj0COVD1mNtjriObanVU-NZevTttGiDXrAWunZDot0fFpQtTLQJO63sIReC8mNraaCERrsJGUEcQAOBiJ4WwWCc2l-mRTadPDr-keymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, we will check for screen edges and give a new position to the head of the snake if it has reached an edge. For example, if the x of the head is greater than the canvas&#8217;s width then this means that it has reached the extreme right of the screen. In such a condition, we are going to change the x to 0 so that the head will now appear on the left side. We will do this kind of logic for all sides.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXe2vKc5D_aW0eGq8szuw_r_WXSYJi9IMj7hhAGNF1uBC12COHEF8IX8PhKk-R-LgUgLCTS_WSoMFSRKto7u8U6_W6h82JzrQqfk36VFQlf51VMbvHpj07SqRZ54_f7KbyMeAL0ZIy48kBXDxBTdWwHHOai3keymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, we have to write some code to detect collisions between circles. Why? Because we have the snake\u2019s head that is a circle and it should detect when it touches the food circle. Similarly, we need to know when the snake\u2019s head touches any other circular part of its body.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">We will use the concept of&nbsp; Euclidean distance. Euclidean distance is the shortest distance between two points (the length of the line between two points)<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">The formula is&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXdT-GY13nfFGSAVwllLhMCfZ9RWqhD23hEjpupv_Vbb4gXyx3wQRbqp2zzP_lmXfBaAhSmXFeMXHIHkLGTphAdKbvKNvQZAqwJdb2RQYD1J_OrC71SazaRrKUSUfyz5-qXK976wqp6kFMreAaCqTAsTDI_keymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, we can find this distance between the centers of two circles. If this distance comes out to be less than or equal to the sum of the radii of the two circles, then this means that the two circles are either touching or overlapping.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, let\u2019s make a new procedure for calculating this distance. It takes in five inputs where four are the x\u00a0 and y coordinates of the two circle centers and one is the radius<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" height=\"41\" width=\"640\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXdJXNCSbq1DBkSFMhfGQFLwCwktgVEhYRWCkfU5tz_PrzXgmc84Uu3828Al_t7ki8kk2_mI8-jbchoHkf_sZMg0eeiFx8_SGTWasn9vVCkncx86UhfWAFofSEj-QQIMjdY5kLvFRu0Fw5cyurQT22w5buKOw640-h41keymiBKTMsU3T2MkvO7gmrR6A.png\"><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Once we have the detection code, let\u2019s complete our moveSnake procedure where we had to detect food.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">We plug the call for detectCollision in our if condition. We will keep radius = circle size as we want the food to be detected even on touch.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXeLjExwHTvuHTXbgepsJC7u0sfD9Y8a9g2rurp_RgfKaonVVfbqTkZONWWPaXXRXlVOLZOuWh7EwUKIj878n1suDwcAxseq8lfpp9quhWzICjjuo093MejOklYes7CRnOKCM-6u7kH1w9kbNdgwY3-thnfukeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">What should happen when the food is supposedly eaten:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">Our score should increase by 1<\/li>\n\n\n\n<li class=\"has-medium-font-size\">The score label should be updated on the screen.<\/li>\n\n\n\n<li class=\"has-medium-font-size\">Food should be given a new position.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXeTwvKvCBQhugz3Q0JQmNFmIoSmNABALQeHZveV6v0S4XOba0li-kkROeCW7S1WqAgV1qPGKxRc5lvzCWkypg_7S_TrVYMN5e9N00bKliWq09lvPHYa-dKgLXSjCm-T1VExlRpDmkvwBu0JETupE9Hw7BTnkeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, moveSnake procedure is complete.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Let&#8217;s finally work on our game loop which is the timer event. First call moveSnake procedure.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXclw-RFlnr4e6iRzACvFqKV6HyN4akjBiJA7toVTdi-scCCpnJPaL05nWzBOEvPEe6fBS0ynnSw7ifFu2GFCULhvhcGCC_39xxfD421XWR43K-hF8RKHN8ejb1hvRh3q6RkSlQ3IsDaylx_R_OaoDCP_lDEkeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Next, we are going to check for collision between the head and each part of its body using a for loop that starts from index 2 i.e. the second segment of the snake and we compare for collision with the head at index =1. We will pass<strong> radius as 4<\/strong> instead of circle size as I want to decrease the sensitivity of collision so that if the snake\u2019s head overlaps with any part of the body, game over is triggered and not just on touching (remember that the snake head is always touching its second segment).&nbsp;<strong>If you change the circle size to some other size, you will have to update this radius of 4 here too (make it half of your circle size ) otherwise your GAME OVER condition will be triggered as soon as the game starts.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXfYq3jFj9gd0oIiLj2PJTdgQyyYUqgdzkS6NQQ1u_pRgCh7cZFT24Bkw4kxR04KEaMWi1esT_W_Wb6Cy0o6xazuqjBjMyYPvNSxoNsWY2Q1lejPt79SRcH0BtErDlU4UUJe-aR5fN3Z-Lwlxpy8Q8LZSLMkeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">If the collision is detected, we will make gameOver true and disable the timer so that the snake stops moving. A break block from control will get us out of the for loop as we don\u2019t need to check further.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In the end, we just draw everything by calling Canvas.draw so this is our final game loop:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXcUxR5We8GTdzIO_0RnobpIRUQYnq9Ao4mnBFViT2TnEc4hnzNtNXZVX-q5pKzFtZ-gV3sdAKOPlv04i3SEpZj4Av-K3eIPfMNlomi7KbPeMb9rPbgOJ5F00qkiJbGezydZQ7vzAF3pcP_X57XeV22mnVpokeymiBKTMsU3T2MkvO7gmrR6A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">The snake game is finally complete.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">You can also get the full AIA project file for MIT App Inventor OR Kodular with a bonus feature: <strong>the Snake has eyes<\/strong><\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color has-link-color has-large-font-size wp-elements-30f9c014f65bb064c485d920a9069453 wp-block-paragraph\"><strong><a href=\"https:\/\/obsidiansoft.gumroad.com\/l\/widahp\" target=\"_blank\" rel=\"noopener\">AIA File<\/a><\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">If you like my tutorials, please consider supporting me so that I continue making such content for you:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/obsidiansoft.gumroad.com\/l\/cxdft\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"372\" height=\"196\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/donate-button-1.png\" alt=\"\" class=\"wp-image-5381\" style=\"width:228px;height:auto\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/donate-button-1.png 372w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/donate-button-1-300x158.png 300w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">You can also watch a video for this here:<\/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<p class=\"responsive-video-wrap clr\"><iframe loading=\"lazy\" title=\"Snake game App Inventor (PART 2) | How to make Snake Game in MIT App Inventor |\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/8Qd_Ai-JJiI?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><\/p>\n<\/div><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">I hope you enjoy making this game as much as I enjoyed designing and creating it for you.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Please like my videos and share them with your friends and family. Also, subscribe to my channel and press the bell icon so you don&#8217;t miss any of the great projects I have planned for you.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/c\/obsidiansofteducation<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Please like my social media pages for more educational resources and tips.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Facebook:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.facebook.com\/ObsidianSoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Instagram:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.instagram.com\/obsidiansoftapps\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Pinterest:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-pinterest wp-block-embed-pinterest\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oceanwp-oembed-wrap clr\"><iframe loading=\"lazy\" title=\"Obsidian Soft\" src=\"https:\/\/assets.pinterest.com\/ext\/embed.html?grid=obsidiansoft&#038;src=oembed\" height=\"900\" width=\"450\" frameborder=\"0\" scrolling=\"no\" ><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">For links to free educational apps, have a look at the&nbsp;<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/mobile-apps\/\">educational apps page<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We started the classic Nokia snake game in the last tutorial and we will finish its code today. We are going to start with the snake\u2019s movement logic. First, remember the screen coordinate system: The x coordinate increases when we move right and decreases when we move left. The y coordinate increases when we move [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1389,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1394","page","type-page","status-publish","has-post-thumbnail","hentry","entry","has-media"],"_links":{"self":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/1394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/comments?post=1394"}],"version-history":[{"count":3,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/1394\/revisions"}],"predecessor-version":[{"id":6239,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/1394\/revisions\/6239"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media\/1389"}],"wp:attachment":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media?parent=1394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}