Star

Home

The star program draws a star using the simple drawing tools in KPL       Download KPL

Program Star

    Method Main()

        Color(Blue)

        PenWidth(5)

        Pen(False)

        MoveTo(200,0)

        Pen(True)

        MoveTo(100,300)

        MoveTo(360,100)

        MoveTo(40,100)

        MoveTo(300,300)

        MoveTo(200,0)

    End Method

End Program

 

Lets take a look at this program line by line

We remember this line.  It sets the color just like the one in Hello World

Color(Blue)

This line makes the lines of the star thicker or thinner.  Try changing the number.

PenWidth(5)

These two lines move the pen to the start position.  We use Pen(False) here so the pen does not start to draw while it is moving to the start position.

Pen(False)

MoveTo(200,0)

These lines put the pen down and draw the star.  You can change the points of the star by changing the two numbers in the parenthesis.  The first one is the distance from the left side of the screen, and the second number is the distance from the top edge.

MoveTo(100,300)

MoveTo(360,100)

MoveTo(40,100)

MoveTo(300,300)

MoveTo(200,0)

 

Lets try an exercise.  Can you change the shape of the star?  Try to make these three forms by changing the numbers in the MoveTo or the PenWidth lines:

 

Our Next Program moves a spaceship around the screen.