vector
Purpose
Create a variable of the vector type
Description
Initialises a variable of the vector type. Can be used to initialise an array or within a structure definition. The vector can have up to 4 dimensions (x, y, z and w / r, g, b and a)
Syntax
struct name
vector field1
...
typen fieldn
endStruct
Arguments
name name of the structure
field1 name of the first field
fieldn name of the last field
typen type of the last field
Example
struct shape
string name
int sides
int size
vector pos
int col
endStruct
shape shapes[3]
shapes[0] = [ .name = "triangle", .sides=3, .size=150, .pos = { 400, 150 }, .col = red ]
shapes[1] = [ .name = "square", .sides=4, .size=150, .pos = { 400, 500 }, .col = yellow ]
shapes[2] = [ .name = "pentagon", .sides=5, .size=150, .pos = { 800, 150 }, .col = blue ]
shapes[3] = [ .name = "hexagon", .sides=6, .size=150, .pos = { 800, 500 }, .col = green ]
loop
clear()
printAt( 0, 0, "Press A to show labels" )
c = controls( 0 )
for i = 0 to 4 loop
drawShape( shapes[i], c.a )
repeat
update()
repeat
function drawShape( s, label )
circle( s.pos.x, s.pos.y, s.size, s.sides, s.col, 0 )
if label then
drawText( s.pos.x - s.size/2, s.pos.y, s.size / 5, black, s.name )
endIf
return void
Associated Commands