Qbasicnews.com

Full Version: Moving dots one by one
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
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
*cough* I guess I was just lazy, that's just too simple :lol: Thanks Tongue