Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP!
#1
I cant figure out whats wrong in my program, run it and you will see the problem. I am sure it is in plain view but Im too into it too see. You can do anything with the code you want just fix it! :roll: LOL

Code:
Begin:
CLS
SCREEN 13

LINE (40, 40)-(260, 40), 15
LINE (40, 40)-(40, 150), 15
LINE (40, 150)-(260, 150), 15
LINE (260, 150)-(260, 40), 15

LOCATE 4, 10
PRINT " Welcome to the Number Guessing Game"

LOCATE 7, 10
PRINT "(S)tart Game"

LOCATE 9, 10
PRINT "(I)nfo"


DO
A$ = UCASE$(INKEY$)
IF A$ = "S" THEN GOTO NewGame
IF A$ = "I" THEN GOTO INFO
LOOP




NewGame:
CLS

Score = 0

LINE (40, 40)-(260, 40), 15
LINE (40, 40)-(40, 150), 15
LINE (40, 150)-(260, 150), 15
LINE (260, 150)-(260, 40), 15

LOCATE 7, 11
PRINT "(E)asy Mode"

LOCATE 9, 11
PRINT "(M)edium Mode"

LOCATE 11, 11
PRINT "(H)ard mode"

DO
B$ = UCASE$(INKEY$)
IF B$ = "E" THEN GOTO Easy
IF B$ = "M" THEN GOTO Medium
IF B$ = "H" THEN GOTO Hard
LOOP

Easy:
Range = 10
Nog = 5
GOTO Game

Medium:
Range = 50
Nog = 10
GOTO Game

Hard:
Range = 100
Nog = 10
GOTO Game

Game:
RANDOMIZE TIMER
Number = INT(RND * Range) + 1

DO UNTIL Guess = Number
CLS
LOOPTOP:

LINE (40, 40)-(260, 40), 15
LINE (40, 40)-(40, 150), 15
LINE (40, 150)-(260, 150), 15
LINE (260, 150)-(260, 40), 15

LOCATE 7, 10
PRINT "Take a guess"

LOCATE 4, 6
PRINT "Guesses left:"; Nog

LOCATE 4, 25
PRINT "Score:"; Score

LOCATE 9, 14
INPUT Guess

IF Guess > Number THEN GOTO ToHigh
IF Guess < Number THEN GOTO ToLow

ToHigh:
LOCATE 13, 11
PRINT " To High, Try lower"
GOTO LOOPTOP

ToLow:
LOCATE 13, 19
PRINT "   To Low, Try higher"


LOOP

Score = Score + Range

CLS

LINE (40, 40)-(260, 40), 15
LINE (40, 40)-(40, 150), 15
LINE (40, 150)-(260, 150), 15
LINE (260, 150)-(260, 40), 15

LOCATE 10, 10
PRINT "PLAY AGAIN?"
LOCATE 12, 10
PRINT "Y or N"

DO
C$ = UCASE$(INKEY$)
IF C$ = "Y" THEN GOTO Game
IF C$ = "N" THEN GOTO Begin
LOOP



INFO:
Reply
#2
Code:
IF Guess > Number THEN GOTO ToHigh
IF Guess < Number THEN GOTO ToLow

ToHigh:
LOCATE 13, 11
PRINT " To High, Try lower"
GOTO LOOPTOP

ToLow:
LOCATE 13, 19
PRINT "   To Low, Try higher"


LOOP
follow it
If the number is too high then it GOTOs to that, prints it and goes to the top of the loop.

If the number is too low then it GOTOs to that, prints it and loops

If the number is correct then it does nothing, get's the the ToHightL place, prints it, and goes to the top of the loop

Code:
IF Guess = Number THEN EXIT DO
Try that somewhere


(you broke the first two rules of posting a topic, all caps and nondescript)
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#3
Quote:Thanks! That solved that problem, now how I need to figure out how to make the little tip that says to high or to low not dissapear. I might have noticed that if I programmed it in The QB Editor, I have this weird thing of writing my programs in notepad, I know, I know, Im a dumb@$$
From looking at it, it looks like it only clears it if you guess too low. If you guess too high it GOTOs the label which is under the CLS so it misses it
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
also,

Code:
IF Guess > Number THEN GOTO ToHigh
IF Guess < Number THEN GOTO ToLow

ToHigh:
LOCATE 13, 11
PRINT " To High, Try lower"
GOTO LOOPTOP

ToLow:
LOCATE 13, 19
PRINT "   To Low, Try higher"

could be made into this:

Code:
IF Guess > Number THEN
    LOCATE 13, 11
    PRINT " To High, Try lower"
    GOTO LOOPTOP
END IF

IF Guess < Number THEN
   LOCATE 13, 19
   PRINT "   To Low, Try higher"
   GOTO LOOPTOP
END IF


LOOP

personly, that is how i would do it. i think it makes managing little bits of code like that easier. like copy and pasting it to other parts of your program. Big Grin
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)