06-10-2004, 08:21 AM
When I try to run this code I get a "parameter type mismatch" error on the third argument of the DrawX SUB.. even though the DrawY SUB is the exact same. Please inform me of waht I am doing.
I apologize if my comments move to the new line, creating confusion.
I apologize if my comments move to the new line, creating confusion.
Code:
'**********************************************************
'** This program is fairly simple, and was my first **
'** attempt at really playing around with graphics in QB **
'** x and y control the intersection of the lines. **
'** endtime controls the speed at which the lines move **
'** the higher the #, the slower they move. **
'** xgoway and ygoway are integers with the value of **
'** 1 or -1, depending if the lines are moving L/R/U/D **
'** Written By: Brett Haralson **
'**********************************************************
DECLARE SUB DrawX (x, y, xgoway AS INTEGER)
DECLARE SUB DrawY (x, y, ygoway AS INTEGER)
SCREEN 12 'Set screen to 12, (640 X 480 resolution)
CONST XMAX = 640 'This constants are use to draw the lines to absolute positions
CONST YMAX = 480 'on the monitor. eg. LINE (x, 0)-(x, YMAX) draws up/down line.
DIM x, y, endtime, xgoway, ygoway AS INTEGER
x = 1: y = 0: endtime = 20000: xgoway = 1: ygoway = 1
DO
CALL DrawY(x, y, ygoway) 'This draws the line on Y axis (up down)
FOR i = 0 TO endtime: NEXT 'This creates a small delay so the prog doesn't run too fast.
CALL DrawX(x, y, xgoway) 'This draws the line on the X axis
IF (INKEY$ <> "") THEN : END 'This monitors keyboard input and quits whenever any key is pressed.
LOOP
SUB DrawX (x, y, way AS INTEGER) 'draws the sweeping x line
IF (x = 0) THEN : way = 1 'If x line has reached far left, reverse direction.
IF (x = 639) THEN : way = -1: LINE (640, 0)-(640, YMAX), 9 'If x line has reached far right, reverse direction, and draw last line.
LINE (x - way, 0)-(x - way, YMAX), 0 'Cover up old line.
LINE (x, 0)-(x, YMAX), 9 'Draw new line (notice how change in line position is dictated by the value of variable 'way'
x = x + way 'change the value of x so the sub will know where to draw line next time it is called
END SUB
SUB DrawY (x, y, way AS INTEGER) 'draws the sweeping x line
IF (y = 0) THEN : way = 1
IF (y = 479) THEN : way = -1: LINE (0, 480)-(XMAX, 480), 9
LINE (0, y - way)-(XMAX, y - way), 0
LINE (0, y)-(XMAX, y), 9
y = y + way
'Since DrawX is called in both For loops in Main program, I
'chose to insert the hit any key to quit thing here.
IF (INKEY$ <> "") THEN : END
END SUB