Do you have an idea for a great mobile phone application, perhaps a game for the Xbox console or a helpful web application? If you have, then you will need to know how to write computer programs (code). This chapter of the book will introduce the common features of computer programs using a language called MS Small Basic, which can be freely obtained from the following website http://smallbasic.com .
Part 1. Talking to machines: computer languages
Part 2. Writing your first program
With just one line of Small Basic code, make the computer print a message to the screen.
Part 3. Responding to user input
Computer programs are pretty boring if they are unable to respond to user input. In this part of the chapter you will learn how to write code that will respond to the user’s keyboard input.
Part 4. Mathematics with Small Basic
Small Basic provides a Math object which makes it easy to generate random numbers, work with trigonometry functions, find the square root and many more functions. It also provides a value for PI. This part of the chapter introduces a few basic functions but also encourages you to explore many others.
Part 5. Repeating things
In this part of the chapter learn how to use Small Basic’s loop structures to enable sections of your code to be repeated a number of times or until a condition is satisfied.
Part 6. Making decisions
Computer programs become far more interesting if they can run different sections of code depending on the outcomes of certain conditions. In this part of the chapter you will learn about Small Basics’s keywords IF, THEN, and ELSE.
Part 7. Drawing with turtles
Turtles have a long association with computer science and in particular programming. In this part of the chapter learn how to use Small Basic’s Turtle object to create graphics.
Part 8. Using graphics
In this next part of the chapter you will learn how to use Small Basic’s Graphics Window so that you can create drawings, animations and a very simple paint program.
Part 9. Using the shape object
The drawing functions of the Graphics Window are fine for static drawings, but the Shape object provides basic shapes and images which can be manipulated with the aid of some of its functions.
Part 10. Making a simple game
It is quite possible to make playable and fun games with Small Basic. In this part of the chapter you make a very simple ‘catch the ball’ type of game.