Trouble Using GET/PUT for simple shooter
Posted: Fri Dec 26, 2008 1:19 pm
Hello, my name is Kris. I'm currently taking a QBasic high school course. It doesn't teach any graphics or gaming however, so I'm teaching myself that. For my first game, I'm trying to put crosshairs and a target on a black background and move the crosshairs to shoot the target. I can't get the crosshairs to move properly, though. After reading through the code over and over again, I have found a fixed several errors, and this has made it run better, but still not properly. The target is supposed to be missing at this point, as all I'm doing right now is testing the function of moving the crosshair and getting that to work. Would you mind taking a look and giving some advice? Thanks. I suspect the problem has to do with the GET/PUT combo.
[code]
SCREEN 13
WAIT &H3DA, 8
DIM crosshair(500)
DIM target(1000)
'Draw the starting position of the crosshair
x1 = 120
x2 = 130
x3 = 125
x4 = 125
y1 = 100
y2 = 100
y3 = 95
y4 = 105
LINE (x1, y1)-(x2, y2), 4 'Color it red Horizontal Line
LINE (x3, y3)-(x4, y4), 4 'Color it red Vertical Line
DO
WAIT &H3DA, 8
GET (x2, y4)-(x1, y3), crosshair 'I suspect the problem is with the GET and PUT statements
press$ = INKEY$
IF press$ = "q" THEN END
IF press$ = "a" THEN x1 = x1 - 10
IF press$ = "a" THEN x2 = x2 - 10
IF press$ = "a" THEN x3 = x3 - 10
IF press$ = "a" THEN x4 = x4 - 10
IF press$ = "s" THEN y1 = y1 + 10
IF press$ = "s" THEN y2 = y2 + 10
IF press$ = "s" THEN y3 = y3 + 10
IF press$ = "s" THEN y4 = y4 + 10
IF press$ = "d" THEN x1 = x1 + 10
IF press$ = "d" THEN x2 = x2 + 10
IF press$ = "d" THEN x3 = x3 + 10
IF press$ = "d" THEN x4 = x4 + 10
IF press$ = "w" THEN y1 = y1 - 10
IF press$ = "w" THEN y2 = y2 - 10
IF press$ = "w" THEN y3 = y3 - 10
IF press$ = "w" THEN y4 = y4 - 10
IF press$ = "w" THEN PUT (x4, y1), crosshair
IF press$ = "s" THEN PUT (x4, y1), crosshair
IF press$ = "d" THEN PUT (x4, y1), crosshair
IF press$ = "a" THEN PUT (x4, y1), crosshair
LOOP[/code]
[code]
SCREEN 13
WAIT &H3DA, 8
DIM crosshair(500)
DIM target(1000)
'Draw the starting position of the crosshair
x1 = 120
x2 = 130
x3 = 125
x4 = 125
y1 = 100
y2 = 100
y3 = 95
y4 = 105
LINE (x1, y1)-(x2, y2), 4 'Color it red Horizontal Line
LINE (x3, y3)-(x4, y4), 4 'Color it red Vertical Line
DO
WAIT &H3DA, 8
GET (x2, y4)-(x1, y3), crosshair 'I suspect the problem is with the GET and PUT statements
press$ = INKEY$
IF press$ = "q" THEN END
IF press$ = "a" THEN x1 = x1 - 10
IF press$ = "a" THEN x2 = x2 - 10
IF press$ = "a" THEN x3 = x3 - 10
IF press$ = "a" THEN x4 = x4 - 10
IF press$ = "s" THEN y1 = y1 + 10
IF press$ = "s" THEN y2 = y2 + 10
IF press$ = "s" THEN y3 = y3 + 10
IF press$ = "s" THEN y4 = y4 + 10
IF press$ = "d" THEN x1 = x1 + 10
IF press$ = "d" THEN x2 = x2 + 10
IF press$ = "d" THEN x3 = x3 + 10
IF press$ = "d" THEN x4 = x4 + 10
IF press$ = "w" THEN y1 = y1 - 10
IF press$ = "w" THEN y2 = y2 - 10
IF press$ = "w" THEN y3 = y3 - 10
IF press$ = "w" THEN y4 = y4 - 10
IF press$ = "w" THEN PUT (x4, y1), crosshair
IF press$ = "s" THEN PUT (x4, y1), crosshair
IF press$ = "d" THEN PUT (x4, y1), crosshair
IF press$ = "a" THEN PUT (x4, y1), crosshair
LOOP[/code]