Help....again!
Posted: Thu Jul 21, 2005 4:47 pm
My computer is being stupid. Maybe I enter something wrong but my computer is telling me I have a WEND without a WHILE. Clearly, I have both, but it doesn't get it. Can you help me? Here's the code:
Code: Select all
Start:
SCREEN 0
WIDTH (80)
x = 15
y = 40
x2 = 2
y2 = 79
LOCATE x, y
COLOR 1
PRINT CHR$(219)
LOCATE x2, y2
COLOR 4
PRINT CHR$(219)
Begin:
SCREEN 0
WIDTH (80)
a$ = ""
WHILE a$ = "" ' HERE"S THE WHILE! SEE I TOLD YOU IT WAS THERE!
Start:
SCREEN 0
WIDTH (80)
x = 15
y = 40
x2 = 2
y2 = 79
LOCATE x, y
COLOR 1
PRINT CHR$(219)
LOCATE x2, y2
COLOR 4
PRINT CHR$(219)
Begin:
SCREEN 0
WIDTH (80)
a$ = ""
WHILE a$ = ""
x2 = px2
y2 = py2
delay = .5
finish = TIMER + delay
IF TIMER = finish THEN
IF x2 = x THEN x2 = x2
IF y2 = y THEN y2 = y2
IF x2 > x THEN x2 = x2 - 1
IF y2 > y THEN y2 = y2 - 1
IF x2 < x THEN x2 = x2 + 1
IF y2 < y THEN y2 = y2 + 1
' Only one inkey$ call per loop.
a$ = INKEY$
x = x + xd
y = y + yd
IF x > 23 THEN x = 23
IF x < 1 THEN x = 1
IF y < 1 THEN y = 1
IF y > 80 THEN y = 80
LOCATE x, y
COLOR 1
PRINT CHR$(219)
LOCATE x2, y2
COLOR 4
PRINT CHR$(219)
px = x
py = y
xd = 0
yd = 0
' If we have a two-character code
IF LEN(a$) = 2 THEN
' Get the second character
a2$ = RIGHT$(a$, 1)
' Check against each arrow key
IF a2$ = "H" THEN xd = -.5
IF a2$ = "P" THEN xd = .5
IF a2$ = "K" THEN yd = -.5
IF a2$ = "M" THEN yd = .5
' H = up arrow
' P = down arrow
' K = left arrow
' M = right arrow
x = x + xd
y = y + yd
LOCATE px, py
PRINT " "
LOCATE px2, py2
PRINT " "
END IF
' If an arrow key was pressed
IF xd <> 0 OR yd <> 0 THEN GOTO Begin
IF x = 2 AND y = 79 THEN GOTO finish ELSE GOTO Begin
WEND ' HERE'S THE WEND!
finish:
CLS
LOCATE 12, 39
COLOR 15
PRINT "You won!"
SLEEP 2
CLS
x2 = px2
y2 = py2
delay = .5
finish = TIMER + delay
IF TIMER = finish THEN
IF x2 = x THEN x2 = x2
IF y2 = y THEN y2 = y2
IF x2 > x THEN x2 = x2 - 1
IF y2 > y THEN y2 = y2 - 1
IF x2 < x THEN x2 = x2 + 1
IF y2 < y THEN y2 = y2 + 1
' Only one inkey$ call per loop.
a$ = INKEY$
x = x + xd
y = y + yd
IF x > 23 THEN x = 23
IF x < 1 THEN x = 1
IF y < 1 THEN y = 1
IF y > 80 THEN y = 80
LOCATE x, y
COLOR 1
PRINT CHR$(219)
LOCATE x2, y2
COLOR 4
PRINT CHR$(219)
px = x
py = y
xd = 0
yd = 0
' If we have a two-character code
IF LEN(a$) = 2 THEN
' Get the second character
a2$ = RIGHT$(a$, 1)
' Check against each arrow key
IF a2$ = "H" THEN xd = -.5
IF a2$ = "P" THEN xd = .5
IF a2$ = "K" THEN yd = -.5
IF a2$ = "M" THEN yd = .5
' H = up arrow
' P = down arrow
' K = left arrow
' M = right arrow
x = x + xd
y = y + yd
LOCATE px, py
PRINT " "
LOCATE px2, py2
PRINT " "
END IF
' If an arrow key was pressed
IF xd <> 0 OR yd <> 0 THEN GOTO Begin
IF x = 2 AND y = 79 THEN GOTO finish ELSE GOTO Begin
WEND
finish:
CLS
LOCATE 12, 39
COLOR 15
PRINT "You won!"
SLEEP 2
CLS