06-05-2003, 02:17 AM
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
Theres the code......anyone have any help???
PS. I CANNOT USE GOTO OR GOSUB!
BYE
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