On October 23rd, 2014, we updated our
By continuing to use LinkedIn’s SlideShare service, you agree to the revised terms, so please take a few minutes to review them.
Microsoft® Small Basic Playing with Shapes Estimated time to complete this lesson: 1 hour
Playing with Shapes In this lesson, you will learn about: Creating games with the help of shapes. Using various properties and operations of the Shapes object to create game elements.
Fun with Shapes Let’s start with a very simple game that you can create with the help of the Shapes object in Small Basic. So far, you’ve learned about drawing various shapes with the help of the Shapes object in the graphics window. Now it’s time to have some fun with shapes… Do you know you can play with shapes and create games? As you know, the Shapes object provides various operations that allow you to draw, color, rotate, and animate shapes in the graphics window. Now you will learn how you can use different shapes to make games.
Balancing the Ball – The Game In this simple game, you balance the ball on a seesaw in the graphics window. The game tests a person’s responsiveness. The timer displays the amount of time that the user keeps the ball balanced on the seesaw. Notice how you can use different shapes available with the Shapes object to create colorful elements for the game.
Balancing the Ball – How to Play So how do you play this game? Steps to play the game:
First, you need to drop the ball on the seesaw by pressing the ENTER key on the keyboard.
After the ball is dropped, you use the LEFT ARROW and the RIGHT ARROW to balance the ball on the seesaw and avoid dropping it.
Balancing the Ball – The Code Now let’s understand the code for the game in detail… You use the Graphicswindow object to create a user interface for the game. You use different operations and properties of the Shapes object to add a shape and move it. You also use the Turtle object and set its speed as well as its x- and y-coordinates. You use different conditions for different actions.
Hit the Right Shape – The Game Now let’s move on to a more complex game. In this game, you score points by using the mouse to select the correct shape from the shapes displayed on the screen. Again, notice how we are using different types of colorful shapes on the screen by using the Shapes object. The objective of the game is to score points by clicking the correct shape on the screen.
Hit the Right Shape – How to Play So how do you play this game? Steps to play the game:
Various shapes move across the screen.
A shape name is flashed on the screen. The user has to click the shape on the screen that matches the shape name.
The user scores points for clicking the correct shape.
Hit the Right Shape – The Code Now let’s understand the code for the game in detail… You use the GraphicsWindow object to create a user interface for the game. You use different operations of the Controls object to add the text box and set the text in the text box. You use the Shapes object to add and move different types of shapes in your game. You also use the Clock object to add a timer in the game. In addition, you set different conditions to carry out different actions.
Let’s Summarize… Congratulations! Now you know how to: Create games with the help of shapes. Use various properties and operations of the Shapes object to create game elements.
It’s Time to Apply Your Learning… Write a program to display a graphics window, and then perform the following steps:
Create a slightly opaque flower in the graphics window by using various shapes.
Create a separate panel on the screen containing separate, corresponding shapes that have been used to create the flower.
Select the shapes on the panel one by one and map the shape to its position in the flower.