4.4 - Advanced Games - Microsoft Center

Microsoft® Small Basic
Advanced Games
Estimated time to complete this lesson: 1 hour
Advanced Games
In this lesson, you will learn how to:
Create advanced games by using basic
elements, objects, and other advanced
concepts of Small Basic.
Advanced Games in Small Basic
Congratulations! You are now well acquainted with programming fundamentals
and advanced concepts of Small Basic.
You have learned to use basic
programming concepts in Small Basic.
You have also been introduced to Small
Basic objects and advanced concepts.
Let’s see how we can use all these concepts
to create advanced games.
Tic-Tac-Toe – The Game
You are probably familiar with the popular Tic-Tac-Toe game. Let’s
see how we can create our own version of this game.
The user and the computer try to
win the game by placing Xs or Os
in a horizontal, vertical, or diagonal
row before the other player does.
Notice how you use the Shapes object to draw various game elements. You
use mouse events to enable the user to place Xs in the graphics window.
Tic-Tac-Toe – How to Play
So how do you play this game?
Steps to play the game:
 This game involves two players:
the user and the computer. Each
player takes a turn placing an X or
an O in the 3x3 playing area. To
start the game, the user places an
X on the board.
 The players alternate placing Xs or
Os on the playing area.
 The player who first places three
Xs or three Os in a horizontal,
vertical, or diagonal line wins the
game.
Tic-Tac-Toe – The Code
Now let’s understand the code for the game in detail…
 Create the game interface by using
the GraphicsWindow object.
 Use the Shapes object to create
the playing area for the Xs and Os in
the graphics window.
 Use mouse events and conditions
such as If-Else to describe various
actions that the user and the
computer perform during the game.
Let’s Summarize…
Congratulations! Now you know how to:
Create advanced games by using basic elements,
objects, and advanced concepts of Small Basic.
Show What You Know
Create a game that involves the following objects: a wall of colored and grey
blocks, a ball, and a paddle. The wall slowly moves down toward the paddle.
Using the paddle, you must hit all the colored blocks with the ball before the
wall hits the paddle.
You use the mouse to move the paddle; the
paddle controls the movement of the ball.
The ball will bounce off grey blocks. After you
hit all the colored blocks, you win the game.
You lose the game if the paddle misses the
ball or if the blocks hit the paddle before you
can remove all the colored blocks.