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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

first game attempt-unsuccessful, please help

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I was wondering if anyone could look over this code and tell me how to fix it. I can't find the problem.



CLS
SCREEN 12
x = 320
x1 = 50
y1 = 50
xdir = 1
ydir = 1
LINE (5, 5)-(635, 420), 1, B
DO
LOOP UNTIL a$ = "q" OR a$ = "Q"
LINE (x - 32, 375)-(x + 32, 375), 0, BF
LINE (x - 30, 375)-(x + 30, 375), 15
LINE (x1 - 8, y1 - 8)-(x1 + 8, y1 + 8), 0, BF
CIRCLE (x1, y1), 7, 10
PAINT (x1, y1), 10, 10
a$ = INKEY$
IF a$ = CHR$(0) + CHR$(75) AND x > 10 + 30 THEN
x = x - 2
END IF
IF a$ = CHR$(0) + CHR$(77) AND x < 630 - 30 THEN
x = x + 2
END IF
IF x1 > 625 THEN xdir = -1
IF x1 < 15 THEN xdir = 1
IF y1 < 15 THEN ydir = 1
IF y1 = 365 AND x1 < x + 37 AND x1 > x - 37 THEN ydir = -1
x1 = x1 + xdir
y1 = y1 + ydir
IF y1 > 400 THEN END
 
All your statements to draw anything on the screen are outside the DO ... LOOP, to begin with. Your program draws a box, then waits until the user presses the &quot;Q&quot; key, then draws the rest one time and ends.
 
What is your problem exactly? What is it that you're running into?
From what I can see, you need a second loop to contain the first one, like this

DO
DO
A$ = INKEY$
LOOP UNTIL UCASE$(A$) = &quot;q&quot; OR A$ = CHR$(27)

[All of your drawing code here]

LOOP UNTIL A$ = CHR$(27)

That'll make it so that the program will continue until you press the escape key. Without the second loop, it'll wait for you to press Q, and then it will draw everything, and then hit the end of the program and be done.
 
Something else, I just ran your code.

Here's a better way to format it.

DO
DO

[ALL YOUR DRAWING CODE HERE AND THE CODE TO MOVE THE
BALL.]

A$ = INKEY$
LOOP UNTIL A$ <> &quot;&quot;

[YOUR CODE HERE TO RECIEVE THE KEYBOARD INPUT AND MOVE
YOUR PLATFORM]

LOOP UNTIL A$ = CHR$(27)
 
Use one DO...LOOP and a if INKEY$ = UCASE$(&quot;Q&quot;) THEN END,
or maybe GOTO ENDR. Hey I know its like 3 months after last posting, but whatever
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top