Qbasicnews.com
December 08, 2019, 06:01:25 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Moving dots one by one  (Read 1237 times)
HQSneaker
Wandering Guru
***
Posts: 394



WWW
« 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)
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #1 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
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
HQSneaker
Wandering Guru
***
Posts: 394



WWW
« Reply #2 on: June 30, 2004, 04:48:43 AM »

*cough* I guess I was just lazy, that's just too simple :lol:  Thanks Tongue
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!