Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WONT LOOP!!!
#1
Hey guys, i know u prolly dont want me posting another string about pacman, but no one is answering my other one....so heres my prob.....there are 2 conditions in the program that would make u start the game over....when u lose all lives, or when u eat all the dots.....the problem is....its not working.....also when i select 2 from the Menu, it wont priint the maze at all??? what is going on....im so lost.....please any help is nice...thanx alot

Code:
CLS                                         'clear screen
SCREEN 13                                    'set screen resolution
DIM maze(22) AS STRING                'Declares that there is 22 maze variables
DIM ghostrow(4) AS INTEGER
DIM ghostcol(4)  AS INTEGER
DIM oldrow(5) AS INTEGER
DIM oldcol(5) AS INTEGER
DIM row(5) AS INTEGER
DIM col(5) AS INTEGER


maze$(1) = "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"        'this is the maze
maze$(2) = "Û........ÛÛ..........ÛÛ........Û"
maze$(3) = "Û.ÛÛÛÛÛÛ.ÛÛ.ÛÛÛÛÛÛÛÛ.ÛÛ.ÛÛÛÛÛÛ.Û"
maze$(4) = "Û..............................Û"
maze$(5) = "ÛÛÛÛ.ÛÛÛ.ÛÛÛÛÛ.ÛÛ.ÛÛÛÛÛ.ÛÛÛ.ÛÛÛÛ"
maze$(6) = "   Û.ÛÛÛ.ÛÛÛÛÛ.ÛÛ.ÛÛÛÛÛ.ÛÛÛ.Û"
maze$(7) = "ÛÛÛÛ.ÛÛÛ.......ÛÛ.......ÛÛÛ.ÛÛÛÛ"
maze$(8) = "Û   .ÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛ.   Û"
maze$(9) = "ÛÛÛÛ.                      .ÛÛÛÛ"
maze$(10) = "   Û.ÛÛÛÛÛÛ ÚÄ====Ä¿ ÛÛÛÛÛÛ.Û"
maze$(11) = "   Û.ÛÛÛ.   ³      Â³   .ÛÛÛ.Û"
maze$(12) = "ÛÛÛÛ.ÛÛÛ.ÛÛ ÀÄÄÄÄÄÄÙ ÛÛ.ÛÛÛ.ÛÛÛÛ"
maze$(13) = "Û   .....ÛÛ          Ã›Ã›.....   Û"
maze$(14) = "ÛÛÛÛ.ÛÛÛÛÛÛÛÛÛ.ÛÛ.ÛÛÛÛÛÛÛÛÛ.ÛÛÛÛ"
maze$(15) = "   Û...........ÛÛ...........Û"
maze$(16) = "ÛÛÛÛ.ÛÛÛÛÛÛ.ÛÛÛÛÛÛÛÛÛ.ÛÛÛÛÛ.ÛÛÛÛ"
maze$(17) = "Û..............  ..............Û"
maze$(18) = "Û.ÛÛÛÛÛ.ÛÛÛÛÛÛ.ÛÛ.ÛÛÛÛÛÛ.ÛÛÛÛÛ.Û"
maze$(19) = "Û.ÛÛÛÛÛ.ÛÛÛ....ÛÛ....ÛÛÛ.ÛÛÛÛÛ.Û"
maze$(20) = "Û.ÛÛÛÛÛ.ÛÛÛ.ÛÛÛÛÛÛÛÛ.ÛÛÛ.ÛÛÛÛÛ.Û"
maze$(21) = "Û..............................Û"
maze$(22) = "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"



row(5) = 13                                     'says which row pacman is at
col(5) = 16                                     'says which column pacman is at

ghostrow(1) = 2                               'says which row the ghost starts at
ghostcol(1) = 2                              'says which column the ghost starts at

ghostrow(2) = 2
ghostcol(2) = 31

ghostrow(3) = 21
ghostcol(3) = 31

ghostrow(4) = 21
ghostcol(4) = 2

dots% = 225                                   'declares how many dots there are

FOR q% = 1 TO 4
DRAW "s8 bm4,3 c14 d50 r10 u23 r20 u27 l30 bm25,25 u2 r10 d10 l10 u8" 'P
DRAW "s8 bm38,102 u20 r20 d20 l7 u7 l6 d7 l7 bm48,78 u5 r7 d5 l7"     'A
DRAW "s8 bm88,102 u20 r15 g10 f10 l15"                                'C
CIRCLE (118, 82), 5                                                   'o
CIRCLE (138, 82), 5                                                   'o
CIRCLE (158, 82), 5                                                   'o
DRAW "s8 bm173,102 c14 u20 r5 f5 e5 r5 d20 l5 u10 g5 h5 d10 l5"       'M
DRAW "s8 bm223,102 u20 r20 d20 l7 u7 l6 d7 l7 bm233,78 u5 r7 d5 l7"   'A
DRAW "s8 bm273,102 u20 r5 f11 u11 r5 d20 l5 h11 d11 l5"               'N

    READ column%, word$

    FOR row2% = 2 TO 19
        LOCATE row2%, column%
        PRINT word$
        LOCATE row2% - 1, column%
        PRINT SPACE$(LEN(word$))
        SOUND (2400 / row2%), 1
DRAW "s8 bm4,3 c14 d50 r10 u23 r20 u27 l30 bm25,25 u2 r10 d10 l10 u8" 'P
DRAW "s8 bm38,102 u20 r20 d20 l7 u7 l6 d7 l7 bm48,78 u5 r7 d5 l7"     'A
DRAW "s8 bm88,102 u20 r15 g10 f10 l15"                                'C
CIRCLE (118, 82), 5                                                   'o
CIRCLE (138, 82), 5                                                   'o
CIRCLE (158, 82), 5                                                   'o
DRAW "s8 bm173,102 c14 u20 r5 f5 e5 r5 d20 l5 u10 g5 h5 d10 l5"       'M
DRAW "s8 bm223,102 u20 r20 d20 l7 u7 l6 d7 l7 bm233,78 u5 r7 d5 l7"   'A
DRAW "s8 bm273,102 u20 r5 f11 u11 r5 d20 l5 h11 d11 l5"               'N

    NEXT row2%
NEXT q%

DATA 10, "Created", 18, "By:", 22, "User", 27, "202423"


CIRCLE (50, 150), 40, 14, .9, 5.4
DRAW "s8 bm50,150 e13 g13 f13"

row3% = 23
col3% = 14

     READ words$
        LOCATE row3%, col3%
        COLOR 14
        PRINT words$
        COLOR 15
DATA "Press The Enter Key..."

        DO
            press$ = INKEY$
        LOOP UNTIL press$ = CHR$(13)
CLS
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
COLOR 9
PRINT TAB(14); "-=::MenU::=-"
COLOR 8
PRINT TAB(10); "==================="
COLOR 15
PRINT TAB(10); "(1) Play Pac-Man"
PRINT TAB(10); "(2) Read Controls"
PRINT TAB(10); "(3) Quit"
COLOR 8
PRINT TAB(10); "==================="
COLOR 15
PRINT
PRINT

INPUT "Please Press 1,2 or 3 to continue..."; ans$

    SELECT CASE ans$
        CASE "2"
            CLS
            DRAW "bm160,85 c15 f3 h3 g3 e3 d9 bm160,118 e3g3 h3 f3 u9 bm180,113 r9 h3 f3 g3 bm130,113 e3 g3 f3 h3 r9"
            PRINT
            PRINT
            PRINT TAB(11); "Use the Arrow Keys"
            PRINT TAB(10); "To Move Pac-Man Around..."
            PRINT
            PRINT TAB(9); "Press any key to continue..."
            DO
            press$ = INKEY$
            LOOP UNTIL press$ <> ""
        CASE "3"
            CLS
            PRINT
            PRINT
            PRINT
            PRINT
            PRINT
            PRINT TAB(10); "THANKS FOR PLAYING!!!!"
            END
        CASE "1"
    END SELECT


CLS
points% = 0
lives% = 3


        PLAY "mbl8 cedf l16 efge l8 df l16 efgefgab l8 >c<b>c<"
DO
DO                                           'Begins Game loop

        IF dots% = 0 THEN
                CLS
                PRINT : PRINT
                PRINT : PRINT
                PRINT "You Win!!!"
                PRINT : PRINT
                INPUT "Would you like to play again "; again$
                        IF again$ = "n" THEN END
                        ELSEIF again$ = "y" THEN
                        lives% = 3
                        dots% = 225


  
   LOCATE 1, 1                              'positions the maze
        
        FOR count = 1 TO 22
            COLOR 1                       'Prints the maze out
            PRINT maze$(count)
            COLOR 15
        NEXT count
        
                          

    LOCATE row(5), col(5)
    COLOR 14                                   'Prints Pacman
    PRINT "C"
  
    LOCATE ghostrow(1), ghostcol(1)
    COLOR 4                                 'makes ghost red
    PRINT ""                                   'Prints ghost
    COLOR 15

    LOCATE ghostrow(2), ghostcol(2)
    COLOR 5                                 'makes ghost red
    PRINT ""                                   'Prints ghost
    COLOR 15

    LOCATE ghostrow(3), ghostcol(3)
    COLOR 6                                 'makes ghost red
    PRINT ""                                   'Prints ghost
    COLOR 15

    LOCATE ghostrow(4), ghostcol(4)
    COLOR 7                                 'makes ghost red
    PRINT ""                                   'Prints ghost
    COLOR 15


    LOCATE 23, 2: PRINT "Lives: "; lives%; "   Points: "; points%
  

                                            'The following condition is for
                                            'when you get eaten by a ghost
        IF ((row(5) = ghostrow(1)) AND (col(5) = ghostcol(1))) OR ((row(5) = ghostrow(2)) AND (col(5) = ghostcol(2))) OR ((row(5) = ghostrow(3)) AND (col(5) = ghostcol(3))) OR ((row(5) = ghostrow(4)) AND (col(5) = ghostcol(4))) THEN
FOR x% = 1000 TO 800 STEP -20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 800 TO 900 STEP 20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 900 TO 700 STEP -20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 700 TO 800 STEP 20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 800 TO 600 STEP -20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 600 TO 700 STEP 20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 700 TO 500 STEP -20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 500 TO 600 STEP 20
    SOUND x%, x% / 2000
NEXT x%

FOR x% = 600 TO 400 STEP -20
    SOUND x%, x% / 2000
NEXT x%

PLAY "l8 <<<ee"

            LOCATE row(5), col(5)
            PRINT " "
            row(5) = 13
            col(5) = 16
            LOCATE row(5), col(5)
            COLOR 14
            FOR c# = 1 TO 1000000 STEP 2
            NEXT c#
            PRINT "C"
            COLOR 15
            lives% = lives% - 1
        ELSEIF lives% <= 0 THEN
            CLS
            LOCATE 12, 8
            PRINT TAB(5); "You Lost All Of Your Lives"
            INPUT "Would you like to play again (y/n) "; again$
                IF again$ = "n" THEN END
                ELSEIF again$ = "y" THEN
                lives% = 3
                dots% = 226

                END IF
        END IF

  DO                                       'Program freezes until user press'
    press$ = INKEY$                         'any key
  LOOP UNTIL press$ <> ""

blah = TIMER + .01
DO
LOOP UNTIL TIMER > blah


    oldrow(5) = row(5)                            'every move is stored into the variable
    oldcol(5) = col(5)

        SELECT CASE press$                  'the following is the conditions for
            CASE CHR$(0) + CHR$(72)             'the key press'
               row(5) = row(5) - 1
            CASE CHR$(0) + CHR$(80)
               row(5) = row(5) + 1
            CASE CHR$(0) + CHR$(75)
               col(5) = col(5) - 1
            CASE CHR$(0) + CHR$(77)
                col(5) = col(5) + 1
        END SELECT

    SELECT CASE MID$(maze$(row(5)), col(5), 1)    'wont let you get passed maze
      CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
        row(5) = oldrow(5)
        col(5) = oldcol(5)
      CASE "."                              'when you eat a dot, it dissapears
        MID$(maze$(row(5)), col(5), 1) = " ": SOUND 800, .25: SOUND 900, .25
        points% = points% + 10
        dots = dots - 1
    END SELECT


  
    '*******************
    'Ghost Movements
    '*******************

    IF RND < .9 THEN                    'randomizes the ghosts movements
        oldrow(1) = ghostrow(1)
        SELECT CASE ghostrow(1)
            CASE IS < row(5)                  'moves ghost closer to you
                ghostrow(1) = ghostrow(1) + 1
            CASE IS > row(5)
                ghostrow(1) = ghostrow(1) - 1
        END SELECT
  
                                           'wont let ghost go through walls
        SELECT CASE MID$(maze$(ghostrow(1)), ghostcol(1), 1)
                CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
            ghostrow(1) = oldrow(1)
        END SELECT

        IF ghostrow(1) = oldrow(1) THEN          'moves ghost closer to you
            oldcol(1) = ghostcol(1)
            SELECT CASE ghostcol(1)
                CASE IS < col(5)
                    ghostcol(1) = ghostcol(1) + 1
                CASE IS > col(5)
                    ghostcol(1) = ghostcol(1) - 1
            END SELECT
        END IF
                                           'makes the ghost stay if he tries to
                                           'get out of maze
               SELECT CASE MID$(maze$(ghostrow(1)), ghostcol(1), 1)
                    CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
                       ghostcol(1) = oldcol(1)
                END SELECT
        END IF

        'Ghost 2 Movements

    IF RND < .8 THEN                    'randomizes the ghosts movements
        oldrow(2) = ghostrow(2)
        SELECT CASE ghostrow(2)
            CASE IS < row(5)                  'moves ghost closer to you
                ghostrow(2) = ghostrow(2) + 1
            CASE IS > row(5)
                ghostrow(2) = ghostrow(2) - 1
        END SELECT

                                           'wont let ghost go through walls
        SELECT CASE MID$(maze$(ghostrow(2)), ghostcol(2), 1)
                CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
            ghostrow(2) = oldrow(2)
        END SELECT

        IF ghostrow(2) = oldrow(2) THEN          'moves ghost closer to you
            oldcol(2) = ghostcol(2)
            SELECT CASE ghostcol(2)
                CASE IS < col(5)
                    ghostcol(2) = ghostcol(2) + 1
                CASE IS > col(5)
                    ghostcol(2) = ghostcol(2) - 1
            END SELECT
        END IF
                                           'makes the ghost stay if he tries to
                                           'get out of maze
               SELECT CASE MID$(maze$(ghostrow(2)), ghostcol(2), 1)
                    CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
                       ghostcol(2) = oldcol(2)
                END SELECT
        END IF

        'Ghost 3 Movements

    IF RND < .9 THEN                    'randomizes the ghosts movements
        oldrow(3) = ghostrow(3)
        SELECT CASE ghostrow(3)
            CASE IS < row(5)                  'moves ghost closer to you
                ghostrow(3) = ghostrow(3) + 1
            CASE IS > row(5)
                ghostrow(3) = ghostrow(3) - 1
        END SELECT

                                           'wont let ghost go through walls
        SELECT CASE MID$(maze$(ghostrow(3)), ghostcol(3), 1)
                CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
            ghostrow(3) = oldrow(3)
        END SELECT

        IF ghostrow(3) = oldrow(3) THEN          'moves ghost closer to you
            oldcol(3) = ghostcol(3)
            SELECT CASE ghostcol(3)
                CASE IS < col(5)
                    ghostcol(3) = ghostcol(3) + 1
                CASE IS > col(5)
                    ghostcol(3) = ghostcol(3) - 1
            END SELECT
        END IF
                                           'makes the ghost stay if he tries to
                                           'get out of maze
               SELECT CASE MID$(maze$(ghostrow(3)), ghostcol(3), 1)
                    CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
                       ghostcol(3) = oldcol(3)
                END SELECT
        END IF
      
        'Ghost 4 Movements

    IF RND < .8 THEN                    'randomizes the ghosts movements
        oldrow(4) = ghostrow(4)
        SELECT CASE ghostrow(4)
            CASE IS < row(5)                  'moves ghost closer to you
                ghostrow(4) = ghostrow(4) + 1
            CASE IS > row(5)
                ghostrow(4) = ghostrow(4) - 1
        END SELECT

                                           'wont let ghost go through walls
        SELECT CASE MID$(maze$(ghostrow(4)), ghostcol(4), 1)
                CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
            ghostrow(4) = oldrow(4)
        END SELECT

        IF ghostrow(4) = oldrow(4) THEN          'moves ghost closer to you
            oldcol(4) = ghostcol(4)
            SELECT CASE ghostcol(4)
                CASE IS < col(5)
                    ghostcol(4) = ghostcol(4) + 1
                CASE IS > col(5)
                    ghostcol(4) = ghostcol(4) - 1
            END SELECT
        END IF
                                           'makes the ghost stay if he tries to
                                           'get out of maze
               SELECT CASE MID$(maze$(ghostrow(4)), ghostcol(4), 1)
                    CASE "Û", "Ä", "¿", "³", "Ù", "À", "Ú"
                       ghostcol(4) = oldcol(4)
                END SELECT
        END IF

    
        
      
LOOP
LOOP UNTIL again$ = "n"

Theres the code......anyone have any help???

PS. I CANNOT USE GOTO OR GOSUB!

BYE
Reply
#2
just loop around when starting. Exit loop if the option is to play the game. If you want info means you WANT INFO, not get info then play the game.

EDIT: AND GET RID OF THE STUPID SOUNDS!!! ARGH MY HEAD!!! AND MAKE SOMETHING MOVE>> game doesn't WORK!
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#3
Ok, well look, for the info then..........how do i make it go back to the menu after they press a button?

and where do i loop at start.....i dunt undertstand what u mean by that.....
Reply
#4
if the game is in a loop exit out of the loop.... and get back to the main loop....
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)