1 / 11

Microsoft ® Small Basic

Microsoft ® Small Basic. Responding to Events. Estimated time to complete this lesson : 1 hour. Responding to Events. In this lesson, you will learn how to:. Create interactive games that respond to events. Fun with Shapes .

rasia
Télécharger la présentation

Microsoft ® Small Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microsoft® Small Basic Responding to Events Estimated time to complete this lesson: 1 hour

  2. Responding to Events In this lesson, you will learn how to: Create interactive games that respond to events.

  3. Fun with Shapes And you also know that you can use these shapes, controls, and events collectively to create interactive games in Small Basic. So far, you have learned how to insert and animate various shapes in your Small Basic programs. You have also learned how to use controls and keyboard and mouse events to include interactivity in your Small Basic program.

  4. Make the Turtle Draw – The Game In this simple game, you tell the Turtle to draw unique shapes in the graphics window by specifying how many sides each shape has. Notice how you use the Turtle object to draw shapes and how you use mouse and keyboard events to choose the color and the number of sides. The game demonstrates how to work with colors and use the properties of Turtle and GraphicsWindow to draw different shapes.

  5. Make the Turtle Draw – How to Play So how do you play this game? • Steps to play the game: • First, you must select a color from the color palette. • Next, you define what shape the Turtle should draw by specifying the number of sides. • When you click Submit, the Turtle starts to draw.

  6. Make the Turtle Draw - Code Now let’s understand the code for the game in detail… To create this game, you use the GraphicsWindowto create a user interface. You use the Controls object to add a button and a text box and set the size for the control buttons. You use the Shapes object to add different shapes. Then, you use the Shapes object to show, move, and hide shapes. You also use the Turtle object and set its angle, speed, and position. You use different conditions for different actions.

  7. Bounce the Ball – The Game Let’s look at a more complex game, in which you click a ball to keep it floating above the ground. Notice how we use mouse events to keep the ball from touching the ground. The ball responds to mouse clicks and stays afloat. The objective of the game is to keep the ball afloat as long as possible.

  8. Bounce the Ball – How to Play So how do you play this game? • Steps to play the game: • On the screen, a ball is dropped on the ground. • You click the ball to make it bounce up in the air. • You keep clicking the ball to keep it from touching the ground. • The timer shows how many seconds you keep the ball from touching the ground.

  9. Bounce the Ball – The Code Now let’s understand the code for the game in detail… To develop this game, you create the user interface by using the GraphicsWindow object. You use the Controls object to define the mouse event that will be used to balance the ball. You use the Shapes object to add the image of the ball. You also use conditional statements to define the action to be performed when a particular mouse event occurs.

  10. Let’s Summarize… Congratulations! Now you know how to: • Create interactive games that respond to events.

  11. Show What You Know Write a program to display a graphics window, and perform the following steps: • Create a series of statements to appear in the graphics window. • Create a button that you label True and another button that you label False. • For each statement, the user will click True or False. • The user scores points by correctly identifying statements as true or false.

More Related