SlideShare una empresa de Scribd logo
1 de 9
Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour
Collision Detection In this lesson, you will learn about: Using the concept of collision detection in games.
What is Collision Detection? Now let’s talk about collision detection in games. In general, collision detection is about determining the intersection of two moving objects. Collision detection in games takes place in the following steps: ,[object Object]
 Checking whether a collision occurred between the identified objects or not.,[object Object]
 Hit the Target – The Game You use the logic of collision detection to detect the collision between the turtle and the target. The game ends as soon as the two objects collide. The game involves two objects: the turtle and the target. The player has to make the turtle hit the target by entering the correct angle and the distance. Now that you have understood the concept of collision detection in games, let’s make a game that uses the logic of collision detection.
Hit the Target – How to Play It’s time to play the game! Steps to play the game: ,[object Object]
Enter the distance that the turtle needs to cover to hit the target.
Click the ‘Hit’ button to hit the target.
Click the ‘Reset’ button to reset the position of the target.,[object Object]

Más contenido relacionado

La actualidad más candente

2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
allenbailey
 
Scratch Lesson 1 – Basics
Scratch Lesson 1 – BasicsScratch Lesson 1 – Basics
Scratch Lesson 1 – Basics
David Oromaner
 
Lesson three presentation
Lesson three presentationLesson three presentation
Lesson three presentation
sutt202
 

La actualidad más candente (20)

Computer Coding with Scratch: Lesson 2_primaryschoollessons
Computer Coding with Scratch: Lesson 2_primaryschoollessonsComputer Coding with Scratch: Lesson 2_primaryschoollessons
Computer Coding with Scratch: Lesson 2_primaryschoollessons
 
Programming in scratch
Programming in scratchProgramming in scratch
Programming in scratch
 
Scratch Animation
Scratch AnimationScratch Animation
Scratch Animation
 
3 Kodu
3 Kodu3 Kodu
3 Kodu
 
Coding Basics with Scratch
Coding Basics with ScratchCoding Basics with Scratch
Coding Basics with Scratch
 
Scratch programming introduction to game creation
Scratch programming  introduction to game creationScratch programming  introduction to game creation
Scratch programming introduction to game creation
 
Scratch an Editing App
 Scratch  an Editing App  Scratch  an Editing App
Scratch an Editing App
 
Scratch Lesson 5
Scratch Lesson 5Scratch Lesson 5
Scratch Lesson 5
 
Kodu
KoduKodu
Kodu
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
 
Scratch Lesson 6
Scratch Lesson 6Scratch Lesson 6
Scratch Lesson 6
 
Scratch Lesson 1 – Basics
Scratch Lesson 1 – BasicsScratch Lesson 1 – Basics
Scratch Lesson 1 – Basics
 
Scratch Programming
Scratch ProgrammingScratch Programming
Scratch Programming
 
Lasso tool
Lasso toolLasso tool
Lasso tool
 
Information technology
Information technologyInformation technology
Information technology
 
Information technology
Information technologyInformation technology
Information technology
 
Arcade Game Design with Sploder - Library Program
Arcade Game Design with Sploder - Library ProgramArcade Game Design with Sploder - Library Program
Arcade Game Design with Sploder - Library Program
 
6. production reflection(2)
6. production reflection(2)6. production reflection(2)
6. production reflection(2)
 
Lesson three presentation
Lesson three presentationLesson three presentation
Lesson three presentation
 
Houchens jeffrey secret helper gdd
Houchens jeffrey secret helper gddHouchens jeffrey secret helper gdd
Houchens jeffrey secret helper gdd
 

Similar a 4.3 collision detection

Run and jump tutorial (part 1) actors
Run and jump tutorial (part 1)   actorsRun and jump tutorial (part 1)   actors
Run and jump tutorial (part 1) actors
Muhd Basheer
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenes
Muhd Basheer
 
Scratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditScratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek pandit
BibekPandit2
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behaviours
Muhd Basheer
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
Dao Tung
 

Similar a 4.3 collision detection (20)

Unity - Building your first real-time 3D project
Unity - Building your first real-time 3D projectUnity - Building your first real-time 3D project
Unity - Building your first real-time 3D project
 
A mazing Game
A mazing GameA mazing Game
A mazing Game
 
Unity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All SlidesUnity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All Slides
 
Run and jump tutorial (part 1) actors
Run and jump tutorial (part 1)   actorsRun and jump tutorial (part 1)   actors
Run and jump tutorial (part 1) actors
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenes
 
Excite artificial intelligence Class 9
Excite artificial intelligence Class 9Excite artificial intelligence Class 9
Excite artificial intelligence Class 9
 
02 unity 3_d_part_1
02 unity 3_d_part_102 unity 3_d_part_1
02 unity 3_d_part_1
 
GameMaker 1) intro to gamemaker
GameMaker 1) intro to gamemakerGameMaker 1) intro to gamemaker
GameMaker 1) intro to gamemaker
 
intern.pdf
intern.pdfintern.pdf
intern.pdf
 
Scratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditScratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek pandit
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
 
Gamemaker lesson 1
Gamemaker lesson 1Gamemaker lesson 1
Gamemaker lesson 1
 
Pres.p game.2
Pres.p game.2Pres.p game.2
Pres.p game.2
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behaviours
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
 
Up cloth - GameDesignDoccument
Up cloth - GameDesignDoccumentUp cloth - GameDesignDoccument
Up cloth - GameDesignDoccument
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
 
How to Design Effective Learning Games: Sharon Boller and Karl Kapp
How to Design Effective Learning Games: Sharon Boller and Karl KappHow to Design Effective Learning Games: Sharon Boller and Karl Kapp
How to Design Effective Learning Games: Sharon Boller and Karl Kapp
 
Work Flow for 2D Game
Work Flow for 2D GameWork Flow for 2D Game
Work Flow for 2D Game
 

Más de allenbailey

5.1 sharing code
5.1   sharing code5.1   sharing code
5.1 sharing code
allenbailey
 
3.6 debugging aids
3.6   debugging aids3.6   debugging aids
3.6 debugging aids
allenbailey
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
allenbailey
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
allenbailey
 
3.3 the math object
3.3   the math object3.3   the math object
3.3 the math object
allenbailey
 
3.2 stacks and arrays
3.2   stacks and arrays3.2   stacks and arrays
3.2 stacks and arrays
allenbailey
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
allenbailey
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
allenbailey
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
allenbailey
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objects
allenbailey
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
allenbailey
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
allenbailey
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutines
allenbailey
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
allenbailey
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
allenbailey
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basic
allenbailey
 

Más de allenbailey (17)

5.1 sharing code
5.1   sharing code5.1   sharing code
5.1 sharing code
 
3.6 debugging aids
3.6   debugging aids3.6   debugging aids
3.6 debugging aids
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
 
3.3 the math object
3.3   the math object3.3   the math object
3.3 the math object
 
3.2 stacks and arrays
3.2   stacks and arrays3.2   stacks and arrays
3.2 stacks and arrays
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objects
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutines
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
 
1.3 variables
1.3   variables1.3   variables
1.3 variables
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basic
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

4.3 collision detection

  • 1. Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour
  • 2. Collision Detection In this lesson, you will learn about: Using the concept of collision detection in games.
  • 3.
  • 4.
  • 5. Hit the Target – The Game You use the logic of collision detection to detect the collision between the turtle and the target. The game ends as soon as the two objects collide. The game involves two objects: the turtle and the target. The player has to make the turtle hit the target by entering the correct angle and the distance. Now that you have understood the concept of collision detection in games, let’s make a game that uses the logic of collision detection.
  • 6.
  • 7. Enter the distance that the turtle needs to cover to hit the target.
  • 8. Click the ‘Hit’ button to hit the target.
  • 9.
  • 10. Next, use the Controls object to add a click button and text box and set the size of control buttons.
  • 11. Use the Shapes object to add an image of the shape, and to move and animate the shape and set its opacity level.
  • 12.
  • 13. It’s Time to Apply Your Learning… Using the concept of collision detection, create a game that involves two objects: a bucket and apples. The apples fall randomly from the top of the screen. The player tries to catch the apples in the bucket. The game runs for 30 seconds. Include a score board to display the total number of apples caught by the player in 30 seconds. Your game should look somewhat like the following.

Notas del editor

  1. Code:' Copyright (c) Microsoft Corporation. All rights reserved.GraphicsWindow.Hide()gw = 620gh = 450GraphicsWindow.BackgroundColor = "LightBlue"GraphicsWindow.CanResize = "False"GraphicsWindow.Width = gwGraphicsWindow.Height = ghGraphicsWindow.Top = ( Desktop.Height - gh ) / 2GraphicsWindow.Left = ( Desktop.Width - gw ) / 2GraphicsWindow.Title = "Hit the Target"GraphicsWindow.Show()Turtle.Hide()rx = 40ry = 20turtlex = 315turtley = 300width = 550height = 390ScoreboxX = 400Enterkey = "Return"target = 10life = 3score = 0GraphicsWindow.FontSize = 30GraphicsWindow.DrawText(100, 200, "Press ENTER to start the game!")GraphicsWindow.KeyDown = OnpressSub Onpress enter = enter + 1If GraphicsWindow.LastKey = Enterkey And enter = 1 ThenGraphicsWindow.Clear()GraphicsWindow.FontSize = 12 GUI()MovingShape()ScoreShow()Controls.ButtonClicked = hitClickEndIfEndSubSub hitClick angle = Math.Round(Controls.GetTextBoxText(angletxt)) distance = Math.Round(Controls.GetTextBoxText(distancetxt)) clicked = Controls.GetButtonCaption(Controls.LastClickedButton) If clicked = "Hit" ThenGraphicsWindow.PenWidth = 0Turtle.Angle = angleTurtle.Move(distance)If Turtle.x > x and Turtle.x < x + 93 and Turtle.y > y and Turtle.y < y + 96 ThenShapes.HideShape(target) score = score + 10 scoreshow()Program.Delay(500)If target = score ThenGameEnd()EndIfControls.SetTextBoxText(angletxt, "")Controls.SetTextBoxText(distancetxt, "")MovingShape()ElseProgram.Delay(1000)If life > 1 ThenGraphicsWindow.ShowMessage("Click Ok to continue the game","Reset") clicked = "Reset"Else GameEnd()EndIfEndIfEndIfIf clicked = "Reset" Then life = life - 1If score >= 10 Then score = score - 5EndIfscoreshow()Controls.SetTextBoxText(angletxt, "")Controls.SetTextBoxText(distancetxt, "")MovingShape() If life < 1 ThenGameEnd()EndIfEndIfEndSubSub GUI image = Program.Directory + "cartoon.gif" GraphicsWindow.DrawRectangle(rx, ry, width, height) target = Shapes.AddImage(image) GraphicsWindow.BrushColor = "Black"Shapes.Move(target, 100, 50) Turtle.Show()Turtle.X = turtlexTurtle.y = turtleyTurtle.Angle = 0GraphicsWindow.DrawText(rx + 5, height - 10, "Enter Angle:")angletxt = Controls.AddTextBox(turtlex - 190, Turtley + 70)Controls.SetSize(angletxt, 40, 30) GraphicsWindow.DrawText(rx + 130, height - 10, "Enter Distance:")distancetxt = Controls.AddTextBox(turtlex - 50, Turtley + 70)Controls.SetSize(distancetxt, 40, 30) firebutton = Controls.AddButton("Hit", turtlex + 20, Turtley + 70) Controls.SetSize(firebutton, 80, 30) EndsubSub MovingShapeShapes.ShowShape(target)Turtle.x = turtlexTurtle.Y = turtleyTurtle.Angle = 0 x = Math.GetRandomNumber(450) y = Math.GetRandomNumber(80)If x <= 40 Then x = 40Shapes.Animate(target, x, y, 1000)ElseIf y <= 20 Then y = 20Shapes.Animate(target, x, y, 1000)Else Shapes.Animate(target, x, y, 1000)EndIfEndSubSub GameEndGraphicsWindow.ShowMessage("Your score is:" + score, "Game Over") Program.End()EndSubSub ScoreShowGraphicsWindow.FontSize = 14GraphicsWindow.BrushColor = "Gray"GraphicsWindow.FillRectangle(ScoreboxX + 50, ScoreboxX - 65, 135, 70) GraphicsWindow.BrushColor = "White"GraphicsWindow.DrawText(ScoreboxX + 60, ScoreboxX - 55, "Score :")GraphicsWindow.DrawText(ScoreboxX + 110, ScoreboxX - 55, score)GraphicsWindow.DrawText(ScoreboxX + 60, ScoreboxX - 20, "Life :")GraphicsWindow.DrawText(ScoreboxX + 110, ScoreboxX - 20, life) EndSub
  2. Code: ' Copyright (c) Microsoft Corporation. All rights reserved.GraphicsWindow.Hide()gw = 620gh = 450GraphicsWindow.CanResize = "False"GraphicsWindow.Width = gwGraphicsWindow.Height = ghGraphicsWindow.Top = (Desktop.Height - gh) / 2GraphicsWindow.Left = (Desktop.Width - gw) / 2GraphicsWindow.Title = "Catch the Apples!"GraphicsWindow.Show()applesLeft = 30gameScore = 0catcherImage = Program.Directory + "catcher.jpg"appleimage = Program.Directory + "apple.jpg"GraphicsWindow.MouseMove = OnMouseMoveCreateUI() While applesLeft > 0DropApple()applesLeft = applesLeft - 1 Shapes.SetText(applesLeftTextBox, "Apples Left: " + applesLeft)EndWhileGraphicsWindow.ShowMessage("Your Score is: " + gameScore, "GameOver")Program.End()Sub CreateUIGraphicsWindow.BackgroundColor = "LightBlue" catcher = Shapes.AddImage(catcherImage) apple = Shapes.AddImage(appleimage) GraphicsWindow.BrushColor = "Gray"GraphicsWindow.FillRectangle(1, 1, gw, 40) GraphicsWindow.FontName = "Verdana"GraphicsWindow.FontSize = 18GraphicsWindow.BrushColor = "White"GraphicsWindow.DrawText(220, 5, "Catch the Apples!") scoreTextBox = Shapes.AddText("Score: 0")Shapes.Move(scoreTextBox, 480, 5)applesLeftTextBox = Shapes.AddText("Apples Left: " + applesLeft)Shapes.Move(applesLeftTextBox, 5, 5)GraphicsWindow.PenColor = "Black"GraphicsWindow.DrawLine(0, 50, 620, 50)Shapes.Move(catcher, 0, gh - 40) Mouse.HideCursor()EndSubSub OnMouseMovecatcherX = Math.Min(GraphicsWindow.MouseX, 570)Shapes.Move(catcher, catcherX, gh - 40)EndSubSub DropAppleappleX = Math.GetRandomNumber(600)appleY = 50While (appleY < gh + 20)Shapes.Move(apple, appleX, appleY)Program.Delay(15)DetectCatch()appleY = appleY + 5EndWhileEndSubSub DetectCatchIf appleY >= gh - 40 And appleX < catcherX + 50 And appleX >= catcherX ThengameScore = gameScore + 1Shapes.SetText(scoreTextBox, "Score: " + gameScore) appleY = gh + 20EndIfEndSub