Qbasicnews.com

QBasic => QB Discussion & Programming Help => Topic started by: HQSneaker on June 29, 2004, 02:35:47 PM



Title: Moving dots one by one
Post by: HQSneaker on June 29, 2004, 02:35:47 PM
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)


Title: Moving dots one by one
Post by: Zack on June 29, 2004, 03:43:53 PM
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


Title: Moving dots one by one
Post by: HQSneaker on June 30, 2004, 04:48:43 AM
*cough* I guess I was just lazy, that's just too simple :lol:  Thanks :P