Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

circles and colors 1

Status
Not open for further replies.

powerfull

IS-IT--Management
Jul 16, 2002
6
0
0
EU
i am trying to put circles and colors into a loop and i cant firgure it out.

I have to have 15 circles on a screen all 15 different colors at the same time so the user can select the color they want to continue with and i have been trying on my own for about 3 days and i cannot figure this out. Please me me out someone.. :(
 
What've u got so far? Post some code. I would start with DO-LOOP
 
I dont really have anything because everything i have tried hasn't worked so i deleted it afterwards.

i have three qbasic books here and i still cant figure it out. if i dont get this to work i am supremly screwed. Please help me out. I am begging..... :(
:(
:(
:(
 
alright: use the FOR-NEXT loop to draw all of the circles
and then use INKEY$ or INPUT to get the input. And then continue, is this what you wanted?
 
yeah, but when i put the circle command in the for next loop is it something like this?



for n = 1 to 15
circle(10,85),7,1
paint (10,85), 1
next n

 
What screen mode are you attempting to do this in?

You don't need the paint (10,85), 1 if your screen mode allows graphics (see help files for which ones do).

Otherwise, your code is OK. --MiggyD

Never be afraid to try something new. Remember that amateurs built the Ark. Professionals built the Titanic.
 
what i am really trying to do is to get 15 different circles filled in color at the same time, but it doesnt work.
 
Ok, now I see why you would want the PAINT command.

Why don't you post your entire code here so that everyone can offer suggestions?
--MiggyD

Never be afraid to try something new. Remember that amateurs built the Ark. Professionals built the Titanic.
 
this is about the only code that i know for doing this
for n = 1 to 15
circle(10,85),7,1
paint (10,85), 1
next n

i am really new to this and i have been trying to learn just by reading the books but as you can see i am not really succeeding. :)
 
You're not too far from what you want to do.

One of your first problems is that you are trying to put a graphics command onto the default screen, which is text only. Take a look at the help for the SCREEN statement and SCREEN MODES. Use SCREEN 12, which is 640 x 480 VGA screen.

The program will now work, but I don't think it's working how you want it to. It IS drawing 15 circles, but all of one colour (1 = blue) and on top of eachother at 10,85

The point of FOR loops is that you want to use the loop a certain number of times. Almost everytime you use these, but not always, something is going to change. It may be counter, a calculation or whatever. In this case you want the positioning and colour to change.

What you need to do is introduce a variable that will change as it goes through the loop. The variable will control both the positioning of the circles and the colour.

You've already got such a variable. It's n. This is what controls the number of loops. Now you've got to use it to control the positioning of the circles and their colour. Try this :-

CIRCLE (10 + 20 * n, 85), 7, n

Every time the loop goes around the centre of the circle changes. The first time it is at 30,85 the second time it is at 50,85, the third time it is at 70,85 and so on.

Replace the 1 at the end of the line as this is the colour that is used to draw the circle. Now each time the loop is stepped through the colour the circle is drawn it changes.

Now for the PAINT command. The centre of the fill needs to be inside the circumfrence of circle, otherwise the whole screen will fill with that colour. The centre of the circle is the mosy obvious to use. So use the same positioning as the CIRCLE command.

The fill colour has to be the same as the circle so change the 1 at the end of that line to n as well.

You should now have enough information to rewrite the code so that it works.

Ray
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top