Page 31 - Learn to Program - Basic-256
P. 31
Chapter 2: Drawing Basic Shapes. Page 15
Chapter 2: Drawing Basic Shapes.
In this chapter we will be getting graphical. You will learn how to draw
rectangles, circles, lines and points of various colors. These programs will get
more and more complex, so you will also learn how to save your programs to
long term storage and how to load them back in so you can run them again
or change them.
Drawing Rectangles and Circles:
Let's start the graphics off by writing a graphical program that will draw a
traffic light, specifically a green light.
1 # traffic_light.kbs
2 # Show a traffic light and say a message.
3
4 clg
5
6 color black
7 rect 100,50,100,200
8
9 color darkred
10 circle 150,100,20
11
12 color darkyellow
13 circle 150,150,20
14
15 color green
16 circle 150,200,20
17
18 say "Green light. You may go."
Program 9: Traffic Light
© 2019 James M. Reneau (CC BY-NC-SA 3.0 US)

