This is a simple program for simple people (me). It draws rows of bricks. I use it as a measuring tool to decide if a language is usable/interesting for middle school students. If I can get this program coded in an hour or so in a new language I consider the language good for kids. This was originally written in AppleLogo many moons ago. Try writing this in C# or VB. Way too much overhead for kids. There are lots of little refinements that I could careless about; brick size inputs, evening out brick spacing, color the bricks and so on that the kids can play with. I like doing tesselations with the kids. They require thinking, math, geometry, programming, and the result is cool. SmallBasic seems just the trick. We have started using Scratch for a middle school language but I like the idea of having a line code language the kids can also use.
| Turtle.Show() |
| Turtle.Speed=100 |
| |
| 'initialize some sizes |
| radius = 0 |
| brickWidth = 10 |
| brickHeight = 20 |
| |
| |
| TextWindow.Write("Enter radius of first row: ") |
| radius = TextWindow.ReadNumber() |
| TextWindow.Write("Enter the number of desired rows: ") |
| numRows = TextWindow.ReadNumber() |
| |
| ' Main program starting point |
| Main() |
| |
| 'Draw the rows of bricks |
| Sub Main |
| For rowCnt = 1 To numRows |
| Angle() |
| DrawRow() |
| radiusradius = radius + brickHeight |
| EndFor |
| EndSub |
| |
| 'compute central angle for the turtle to turn |
| Sub Angle |
| cir = 2 * 3.14159 * radius 'compute circumference at given radius |
| numBricks = cir / brickWidth 'how many bricks can fit at this radius |
| centralAngle = 360 / numBricks 'what angle does the turtle have to turn at the center to draw the next brick |
| EndSub |
| |
| 'Draw a row of bricks |
| Sub DrawRow |
| For i = 1 To numBricks |
| Turtle.PenUp() |
| Turtle.Move(radius) |
| Turtle.PenDown() |
| Brick() |
| Turtle.PenUp() |
| Turtle.Move(-radius) |
| Turtle.Turn(centralAngle) |
| EndFor |
| EndSub |
| |
| 'Draw one brick |
| Sub Brick |
| Turtle.TurnLeft() |
| Turtle.Move(brickWidth / 2) |
| Turtle.TurnRight() |
| Turtle.Move(brickHeight) |
| Turtle.TurnRight() |
| Turtle.Move(brickWidth) |
| Turtle.TurnRight() |
| Turtle.Move(brickHeight) |
| Turtle.TurnRight() |
| Turtle.Move(brickWidth / 2) |
| Turtle.TurnRight() |
| EndSub |
| |
| |
| |