Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help on arrays
#2
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.

Code:
Copy      Help
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)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)