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