Need help with project please help

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
sh
Newbie
Posts: 2
Joined: Mon Apr 28, 2008 8:55 pm

Need help with project please help

Post by sh »

I need to make each line a different color does anyone know how i can change each line a different color instead of green?




DECLARE SUB drawthelines ()
'Programmer:
'Chapter 3 project P.40 #1 4-25-08
'Period 2
SCREEN 7
COLOR 4, 0
CLS

drawthelines
END

SUB drawthelines
'This subprogram draws the lines.

FOR x = 10 TO 240 STEP 40
LINE (0, x)-(320, x), 2
NEXT x

END SUB
User avatar
burger2227
Veteran
Posts: 2467
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Just change the color value

Post by burger2227 »

But you are limited to 16 colors from 0 to 15

Syntax: LINE(c1, r1)-(c2, r2), colour, '[box] = B or BF

Ted
Last edited by burger2227 on Mon Apr 28, 2008 11:54 pm, edited 2 times in total.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
sh
Newbie
Posts: 2
Joined: Mon Apr 28, 2008 8:55 pm

Post by sh »

so u are saying just put this code in and it should change the colors??
Syntax: LINE(c1, r1)-(c2, r2), colour, [box]
User avatar
burger2227
Veteran
Posts: 2467
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

READ the QB HELP

Post by burger2227 »

A LINE statement can also create boxes. You don't need B or BF if you just want lines. That was a syntax of the LINE statement.

To change a line color, just increment the value of the variable colour.

Code: Select all


SCREEN 7         'MUST use a screen mode for graphics!
DO
    colour = colour + 1                   'increment color
    r1 = r1 + 5                              'increase rows
    LINE( 100, r1)-(220, r1), colour
    IF colour = 15 THEN colour = 0

LOOP UNTIL r1 > 200 
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Post Reply