{"id":6658,"date":"2025-09-30T14:38:44","date_gmt":"2025-09-30T14:38:44","guid":{"rendered":"https:\/\/obsidiansofteducation.com\/?page_id=6658"},"modified":"2025-12-11T19:21:29","modified_gmt":"2025-12-11T19:21:29","slug":"app-inventor-fruit-ninja-game","status":"publish","type":"page","link":"https:\/\/obsidiansofteducation.com\/index.php\/app-inventor-fruit-ninja-game\/","title":{"rendered":"App Inventor Fruit Ninja Game"},"content":{"rendered":"\n<p class=\"has-medium-font-size\">Hello friends, and welcome to Obsidian Soft,<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Today, I will teach you how to make the Fruit Ninja game in MIT App Inventor. I have tried to cover the best concepts of the game in this tutorial so that we end up with a fully functional, entertaining game. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-12-1024x576.jpg\" alt=\"\" class=\"wp-image-6672\" style=\"width:654px;height:auto\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-12-1024x576.jpg 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-12-300x169.jpg 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-12-768x432.jpg 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-12-800x450.jpg 800w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-12.jpg 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"has-medium-font-size\">So, let\u2019s begin. Open up MIT App Inventor.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Start a new project and call it Fruit Ninja Game<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Upload media: 3 fruit images and one slice sound effect.&nbsp; Resource links are given below:<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><a href=\"https:\/\/www.freepik.com\/free-vector\/set-collection-vector-flat-various-fruit-illustration_44691433.htm\" target=\"_blank\" rel=\"noopener\">https:\/\/www.freepik.com\/free-vector\/set-collection-vector-flat-various-fruit-illustration_44691433.htm<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Steel blade slice 3 from <a href=\"https:\/\/pixabay.com\/sound-effects\/search\/slice\" target=\"_blank\" rel=\"noopener\">https:\/\/pixabay.com\/sound-effects\/search\/slice<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">After uploading media, make the screen orientation portrait in screen1&#8217;s properties.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Add a horizontal arrangement with align horizontal and align vertical properties both centered. Make the background color black. Change background color to&nbsp; Make height 15% and width fill parent. Add a label to show the score. Rename to scoreLbl. Change the color to yellow. Make the font bold and font size 20.&nbsp; Select the score label and duplicate it by pressing<strong> Ctrl + C &amp; Ctrl + V<\/strong> on the keyboard for Windows OR<strong> Command + C &amp; Command + V<\/strong> on the keyboard for MacOS. Rename to timeLbl. Change the color to red. Also, add a button in the same layout. Rename to restartBtn. Make the font bold and font size 20. And change the color to green.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">&nbsp;And change the text to Restart. Add a canvas from Drawing and animation. Make background color black, font size 40, height 80% and width fill parent. Set the Line width to&nbsp; 5 and the paint color to red. You can increase this line width to make the slice thicker and change the color to another color if you prefer something other than red for the slice.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Add an image sprite from the drawing and animation palette. Make height and width both 70 px. Choose one of the fruit images as the picture. And set the interval to 50.&nbsp; Turn off rotates checkbox. Select the image sprite and duplicate it by pressing<strong> Ctrl + C &amp; Ctrl + V<\/strong> on the keyboard for Windows OR<strong> Command + C &amp; Command + V<\/strong> on the keyboard for MacOS. Just change the picture to another fruit. You can add as many fruits as you want with different fruit pictures.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, add a clock from sensors. Rename to gameTimer. Uncheck the timer-enabled property. The timer interval should stay 1000 ms, which means 1 second.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Duplicate this gameTimer. Rename to clearSlashTimer. Just change the timer interval to 150. It should stay disabled.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Lastly, add a sound from media and choose your uploaded slice sound effect as the source. UX design is done, so let\u2019s go to the blocks section.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Go to the blocks section. Make global variables for score and time left. And a status variable indicating whether the game is active or not.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"448\" height=\"174\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-40.png\" alt=\"\" class=\"wp-image-6659\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-40.png 448w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-40-300x117.png 300w\" sizes=\"auto, (max-width: 448px) 100vw, 448px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">First, let\u2019s make a procedure for resetting a fruit sprite\u2019s properties. The procedure takes an input fruit. First we check that the game is active. Every time a fruit sprite is reset, it should be given a new random position on the canvas. It can be anywhere on the screen width-wise, but it should always start from the bottom of the canvas. So, X should be randomized between canvas width and imagesprite.width, and Y is a little over the canvas. height, so we are not touching the bottom edge. We don\u2019t want that; otherwise, our edge-touched event will be triggered. We are using any component blocks, so this way we can have as many fruits in the game, and we don\u2019t have to write code for each fruit separately. I have already covered any component blocks in my picture-matching game and snow globe tutorials. We give a random speed between 9-12, and we give a random heading\/direction. The fruit can go from left top slant to right top slant\u2026.a heading between 60 degrees and 120 degrees, where a degree of 90 means straight up. And we make the sprite visible.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"570\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-41-1024x570.png\" alt=\"\" class=\"wp-image-6660\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-41-1024x570.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-41-300x167.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-41-768x428.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-41-1536x855.png 1536w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-41.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Then, we make a procedure for resetting the entire game. First, we make the game active. Set score and time left back to original values of 0 and 30, respectively. Update the labels for these variables accordingly. And then using any component -&gt; any image sprite -&gt; every image sprite block that automatically contains all the fruit image sprites in our project, we use a for each item loop from Control to reset each fruit. Lastly, we enable the game timer so that the game starts.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"998\" height=\"682\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-42.png\" alt=\"\" class=\"wp-image-6661\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-42.png 998w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-42-300x205.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-42-768x525.png 768w\" sizes=\"auto, (max-width: 998px) 100vw, 998px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Next, we call this reset game procedure in the initialize event for the screen. And we also call it when resetbtn is clicked.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"416\" height=\"130\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-43.png\" alt=\"\" class=\"wp-image-6662\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-43.png 416w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-43-300x94.png 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"392\" height=\"130\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-44.png\" alt=\"\" class=\"wp-image-6663\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-44.png 392w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-44-300x99.png 300w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><br>Now, we get the any image sprite edge reached event that will be automatically triggered when any image sprite, i.e., a fruit, touches the edge. This is the reason why we didn\u2019t reset the fruit\u2019s Y&nbsp; to the canvas. height, but a little over it, so this event isn\u2019t triggered. We call the resetFruit procedure for the component i.e., fruit that has reached the edge.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"714\" height=\"234\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-45.png\" alt=\"\" class=\"wp-image-6664\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-45.png 714w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-45-300x98.png 300w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Next comes the main event of when we drag our finger on our screen. Get the canvas. dragged event. We have to do two main things. We have to draw a line wherever our finger drags, and we also have to check if our drag has come somewhere inside the fruit.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-medium-font-size\">First, use canvas.drawLine to draw a line from the previous position (prevX, prevY) to the current position (currentX, currentY).&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"310\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-46-1024x310.png\" alt=\"\" class=\"wp-image-6665\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-46-1024x310.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-46-300x91.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-46-768x232.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-46.png 1290w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Then, check if the current position is inside any of the fruits. We are going to again use a for each item loop on every image sprite list.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"405\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-47-1024x405.png\" alt=\"\" class=\"wp-image-6666\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-47-1024x405.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-47-300x119.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-47-768x304.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-47.png 1290w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">We are going to check if the currentX, currentY are both within the bounding box of our image sprite. For example, in the following picture, point 1 is outside but point 2 is inside, so in that case, if condition will be true and we will slice the fruit. If you don\u2019t understand this logic, no worries, I have explained it in more detail at the end of this tutorial.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"643\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-48-1024x643.png\" alt=\"\" class=\"wp-image-6667\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-48-1024x643.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-48-300x188.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-48-768x482.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-48.png 1054w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">For actual fruit slicing, we will just reset the sliced fruit to a new position. Increase the score and reflect it on the screen using the score label. We will also break, as there is no need to check other fruits (not simulating double slicing in this tutorial). Outside the for loop, we also enable our clear slash timer.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"197\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-49-1024x197.png\" alt=\"\" class=\"wp-image-6668\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-49-1024x197.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-49-300x58.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-49-768x148.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-49-1536x296.png 1536w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-49.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">We play the slice sound in canvas. touchdown event.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"182\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/12\/image-22.png\" alt=\"\" class=\"wp-image-6814\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/12\/image-22.png 470w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/12\/image-22-300x116.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">&nbsp;And in clearSlashTimer, which is triggered after 150 ms of being enabled, we will first disable it so that it is not triggered again and again and then we clear the canvas so that the slash disappears.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"894\" height=\"182\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-50.png\" alt=\"\" class=\"wp-image-6669\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-50.png 894w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-50-300x61.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-50-768x156.png 768w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">At the end, we have a game timer event that runs after 1000 ms, equal to 1 second. It decreases or decrements the time left variable and updates the time left label on the screen. It checks if the time left is equal to 0 for game game-over condition. In case it is, it disables all timers, makes all the image sprites invisible, and updates timeLbl with Game Over text.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"998\" height=\"748\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-51.png\" alt=\"\" class=\"wp-image-6670\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-51.png 998w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-51-300x225.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-51-768x576.png 768w\" sizes=\"auto, (max-width: 998px) 100vw, 998px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">And this is done. I hope you like this fun Fruit Ninja game made completely in MIT App Inventor, perfect for school and college projects or just to impress your friends. <\/p>\n\n\n\n<p class=\"has-large-font-size\"><a href=\"https:\/\/obsidiansoft.gumroad.com\/l\/hcknlj\" target=\"_blank\" rel=\"noopener\"><strong>Download AIA file for the Fruit Ninja Game in MIT App Inventor<\/strong><\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">You can also check out the video tutorial for this project on my channel.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><a href=\"https:\/\/youtu.be\/EZn6uYreT9w\" target=\"_blank\" rel=\"noopener\">https:\/\/youtu.be\/EZn6uYreT9w<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Please like my tutorials and share it with your friends and family. Also, subscribe to my channel and press the bell icon so you don\u2019t miss any of the great projects I have planned for you.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><a href=\"https:\/\/www.youtube.com\/c\/obsidiansofteducation\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/c\/obsidiansofteducation<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Please like my Facebook page and Instagram page for more educational resources and tips.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Facebook:<\/strong><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\"><strong>Instagram:<\/strong><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\"><strong>Pinterest:<\/strong>&nbsp;<a href=\"https:\/\/www.pinterest.com\/obsidiansoft\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.pinterest.com\/obsidiansoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">For links to free educational&nbsp;<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/flappy-bird-game-mit-app-inventor\/#\">&nbsp;apps<\/a>, have a look at the&nbsp;<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/mobile-apps\/\">educational apps page<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\"><strong><em>More details for successful slicing:<\/em><\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"643\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-52-1024x643.png\" alt=\"\" class=\"wp-image-6671\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-52-1024x643.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-52-300x188.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-52-768x482.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-52.png 1054w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading has-medium-font-size\"><strong>Step-by-step logic<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"has-medium-font-size\"><strong>currentX<\/strong><strong> and <\/strong><strong>currentY<\/strong><strong><br><\/strong>\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">These are the coordinates of the player\u2019s finger during the swipe.<br><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>Fruit.X<\/strong><strong> and <\/strong><strong>Fruit.Y<\/strong><strong><br><\/strong>\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">These are the top-left corner of the fruit sprite.<br><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>Fruit.X + Fruit.Width<\/strong><strong> and <\/strong><strong>Fruit.Y + Fruit.Height<\/strong><strong><br><\/strong>\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">These give the bottom-right corner of the fruit sprite.<br><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-medium-font-size\">The whole condition is basically asking:<br><br>\u201cIs the player\u2019s finger inside the rectangle of this fruit?\u201d<br>\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">(currentX &gt; Fruit.X) \u2192 finger is to the right of the left edge.<br><\/li>\n\n\n\n<li class=\"has-medium-font-size\">(currentX &lt; Fruit.X + Fruit.Width) \u2192 finger is to the left of the right edge.<br><\/li>\n\n\n\n<li class=\"has-medium-font-size\">(currentY &gt; Fruit.Y) \u2192 finger is below the top edge.<br><\/li>\n\n\n\n<li class=\"has-medium-font-size\">(currentY &lt; Fruit.Y + Fruit.Height) \u2192 finger is above the bottom edge.<br><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-medium-font-size\">If all of these are true \u2192 the finger is inside the box.<br><\/li>\n\n\n\n<li class=\"has-medium-font-size\">If the finger is inside \u2192 we slice the fruit<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-large-font-size\"><strong>Even simpler explanation:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Every fruit is just a rectangle with a top-left corner, a width, and a height.<br>When we swipe, our finger gives us a point (X, Y).<br>If that point is inside the rectangle, we say the fruit is sliced.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends, and welcome to Obsidian Soft, Today, I will teach you how to make the Fruit Ninja game in MIT App Inventor. I have tried to cover the best concepts of the game in this tutorial so that we end up with a fully functional, entertaining game. So, let\u2019s begin. Open up MIT App [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6658","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6658","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=6658"}],"version-history":[{"count":3,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6658\/revisions"}],"predecessor-version":[{"id":6821,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6658\/revisions\/6821"}],"wp:attachment":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media?parent=6658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}