Discussion My personal test program

  • Wednesday, October 29, 2008 3:42 PM
     
      Has Code
    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  
          
     
     

All Replies

  • Wednesday, October 29, 2008 5:28 PM
    Owner
     
     
    Really nice.  Do you have a screenshot that you can post too? 
  • Wednesday, October 29, 2008 6:09 PM
     
     
    Be glad to, if I knew how to post a screen shot to this forum.  Cut and paste is not doing the trick.
  • Thursday, October 30, 2008 12:16 AM
     
     
    You have to work with pure HTML from within the post editor.
    So, you can insert pictures using the <img> tag, like this:

  • Thursday, October 30, 2008 5:08 PM
     
     
    To mcleod_ideafix

    I can spell HTML (usually), from there on I have no idea what you said or did.  Anyway, thanks for posting the picture.