programs/testTurtleSpace.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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
//-------------------------------------------------------------------
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
// Test that TurtleSpace coordinate functions are functioning
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
//  properly. You should end up with four arrows, east west, north
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
//  and south, extending to the edges of TurtleSpace, centered on the
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
//  edge.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
//
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
// Copyright (c) 1999 Lighting and Sound Technologies.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
//   Written by Ryan C. Gordon.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
//-------------------------------------------------------------------
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
function main() returns nothing
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
    number i
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
	number maxX = getTurtleSpaceWidth()
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
	number maxY = getTurtleSpaceHeight()
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
	number centerX = getTurtleX()
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
	number centerY = getTurtleY()
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
	hideTurtle()
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
		// horizontal shaft.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
	setTurtleXY(0, centerY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
	setAngle(0)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
	goForward(maxX)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
		// vertical shaft.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
	setTurtleXY(centerX, 0)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
	setAngle(90)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
	goForward(maxY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
		// western arrow.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
	setTurtleXY(0, centerY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
	setAngle(-45)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
	setTurtleXY(0, centerY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
	setAngle(45)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
		// eastern arrow.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
	setTurtleXY(maxX, centerY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
	setAngle(-135)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
	setTurtleXY(maxX, centerY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
	setAngle(135)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
		// northern arrow.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
	setTurtleXY(centerX, 0)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
	setAngle(135)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
	setTurtleXY(centerX, 0)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
	setAngle(45)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
		// southern arrow.
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
	setTurtleXY(centerX, maxY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
	setAngle(-135)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
	setTurtleXY(centerX, maxY)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
	setAngle(-45)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
	goForward(100)
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
endfunction
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
d7cb562e4e24 Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68