Patricjs - object orientated JavaScript



This is an example program running in the Patric.js environment. Please note new teaching isa

The code is as follows;

loop 50;
   dodecagon 60;
   move 0,-40;
   star 40;
next;

The loop command tells the program to repeat the lines between the loop and the next command by the number of times indicated by the number or argument that follows the loop statement. The dodecagon 60; statement tell the computer to draw a regular dodecagon size 60 pixels at a random position with a random colour. The move 0, -40; statement tell it to move 0 pixels along the x axis and 40 pixels up the y axis, from the current position and draw a star. Note a - number is used to move up the screen and positive numbers to move down. The star 10; statement tells it to draw a star with a random colour and in the current position as it follows a move statement. Note all statements need to be followed by a semicolon on the same line. The lines that are repeated are those between the loop and next commands.



Copyright © 2016 · All Rights Reserved · patric.co.uk