06-20-2005, 12:28 PM
This example uses an user-defined type to store all data into single array. This array has two dimensions. Indices in each dimension are from 0 to 7.
type XYANDCOLOR x y color
int w10 ;;window handle
int sqwidth=30 ;;square width and height
int xoffset=50 ;;first square x offset relative to window
int yoffset=150 ;;first square y offset relative to window
ARRAY(XYANDCOLOR) a.create(8 8) ;;create 8x8 array
;fill coordinates and colors (colors also can be filled later similarly)
int row col
for row 0 8
,for col 0 8
,,XYANDCOLOR& sq=a[row col] ;;using sq instead a[row col] will be shorter and faster
,,sq.x=col*sqwidth+xoffset
,,sq.y=row*sqwidth+yoffset
,,sq.color=pixel(sq.x sq.y w10)