programs/testWhile.toby
author Ryan C. Gordon <icculus@icculus.org>
Tue, 18 Mar 2008 02:05:22 +0000
changeset 499 96e88f292dc8
parent 1 d7cb562e4e24
permissions -rw-r--r--
Updated Lua from 5.1.1 to 5.1.3.
//----------------------------------------------------
// This is an over-glorified test of the
//  WHILE/ENDWHILE construct, buried in the
//  doTriangle() function. If it works, you should
//  end up with three filled-in triangles.
//
// Copyright (c) 1999 Lighting and Sound Technologies.
//  Written by Ryan C. Gordon.
//----------------------------------------------------

function main() returns nothing
	hideTurtle()
	nuclearSymbol(150)
endfunction


function nuclearSymbol(number size) returns nothing
	number i

	setPenColor(14)

	for i = 1 to size
		setAngle(300)
		doTriangle(i)
	
		setAngle(180)
		doTriangle(i)
	
		setAngle(60)
		doTriangle(i)
	endfor
endfunction


function doTriangle(number size) returns number
	number i

	i = 1

	while (i <= 3)
		i = i + 1
		goForward(size)
		turnRight(360 / 3)
	endwhile
endfunction