CONDITIONAL STATEMENTS:

CONDITIONAL STATEMENTS:
PROGRAMMING EXERCISES
1. Create a Shape Selector program that prompts the user to select a shape to draw followed by the
colour they would like to use. When the program starts the following input dialog should appear
prompting the user for a shape:
Once users make a selection, prompt them to select a colour:
Once users select a colour, draw the shape the user selected filled in with the colour they selected.
Make sure the shape is centred in the room:
Conditional Statements
Page 1 of 3
You will need to prompt the user for the shape and the colour in a Create event, and you will need
to draw the shape in a Draw event.
Save the program as ShapeSelector.gmk in your UNIT 5 folder.
2. Creating a Baby Gnu program that bounces a gnu off the walls of the screen. When the program
starts the gnu object should be located at the top-left corner and should start moving diagonally.
Whenever it hits a wall, the gnu should bounce off the wall and its speed should go up by 2.
Conditional Statements
Page 2 of 3
Once the gnu’s speed reaches 50 it should stop and the following message should be outputted to
the user before the program exits:
You will need to use the the motion_set() function to get Baby Gnu moving when the object is first
created. The motion_set() function takes two arguments: a number representing the direction you
want the object moving, and a number representing the speed (in pixels) you want it to move by.
You will then need to create a Step event to continuously check if Baby Gnu hits the top, right,
bottom or left sides of the room. You will also need to use the speed, vspeed and hspeed built-in
variables to adjust the object’s speed and the direction it moves.
Save the program as BabyGnu.gmk in your UNIT 5 folder.
Conditional Statements
Page 3 of 3