Posts: 383
Threads: 14
Joined: Mar 2004
Simple question:
I'm putting 100 dots on a random place on the screen. Now I want to be able to select them one by one and then move them (one at the time). Which method should I use here? (I was thinking about arrays, but I can't get it to work that way)
Posts: 3,616
Threads: 287
Joined: Jan 2003
Array of TYPEs. Like, if each one has a color, x and y position, then this could be your code structure:
Code:
DEFINT A-Z
TYPE dot
x AS INTEGER
y AS INTEGER
clr AS INTEGER
END TYPE
DIM dots(1 TO 100) AS dot
RANDOMIZE TIMER
'We fill the x, y and color values for each dot, randomly:
FOR i=1 TO 100
dots(i).x=INT(RND * 320)
dots(i).y=INT(RND * 200)
dots(i).clr=INT(RND * 16)
NEXT
SCREEN 13
'Now to move each dot, just go through this routine:
FOR i=1 TO 100
'now, access dots(i).x, dots(i).y, and dots(i).clr (x, y, and color of each dot)
'in order to get the information you need to move them
NEXT
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 383
Threads: 14
Joined: Mar 2004
*cough* I guess I was just lazy, that's just too simple :lol: Thanks