Posts: 19
Threads: 7
Joined: May 2003
Hey guys, ummm im having trouble making my pacman game....its working fine, but its just not appealing...and i have till friday to finish it, im really screwed....if anyone can help me, im all for it.......thanx in advance.........
p.s. Ill post my code tommorow, its on my school computer
but feel free to post ideas/code to help....thanx
Posts: 3,368
Threads: 195
Joined: Jan 2003
add fruit.
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.
Posts: 19
Threads: 7
Joined: May 2003
ok heres the code, but 1st, i would like to know is it possible to make the ghosts move without having to move pacman, and also if its possible to, when u hit a movement key, that pacman keeps going that way until another movement key is pressed..... just wondering....
Code: CLS 'clear screen
SCREEN 13 'set screen resolution
DIM maze$(11) 'Declares that there is 6 maze variables
DIM oldrow
DIM oldcol
maze$(1) = "ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃû" 'the following is the maze in
maze$(2) = "º º º" 'the variables
maze$(3) = "º º ÃÃÃÃÃÃÃÃà º º"
maze$(4) = "º º º º"
maze$(5) = "º ÃÃû ÃÃà ÃÃü º"
maze$(6) = "º º º º º"
maze$(7) = "º º"
maze$(8) = "º ÃÃÃÃÃÃÃÃÃÃà º"
maze$(9) = "º º º"
maze$(10) = "º º"
maze$(11) = "ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃü"
row = 4 'says which row pacman is at
col = 7 'says which column pacman is at
ghostrow = 9 'says which row the ghost starts at
ghostcol = 10 'says which column the ghost starts at
dots = 54 'declares how many dots there are
DO 'Begins the Game loop
LOCATE 1, 1 'positions the maze
FOR count = 1 TO 11 'Prints the maze out
PRINT maze$(count)
NEXT count
LOCATE row, col
COLOR 14 'Prints Pacman
PRINT "C"
COLOR 15
LOCATE ghostrow, ghostcol
COLOR 4 'makes ghost red
PRINT "" 'Prints ghost
COLOR 15
IF dots = 0 THEN 'declares when the user can win
LOCATE 15, 1
PRINT "You Have Won" 'Prints You win, if you eat all
END 'dots
END IF
'The following condition is for
'when you get eaten by a ghost
IF ((row = ghostrow) AND (col = ghostcol)) THEN
LOCATE 15, 1
PRINT "Your Dead" 'Prints your dead
END
END IF
DO 'Program freezes until user press'
press$ = INKEY$ 'any key
LOOP UNTIL press$ <> ""
oldrow = row 'every move is stored into the variable
oldcol = col
SELECT CASE press$ 'the following is the conditions for
CASE CHR$(0) + CHR$(72) 'the key press'
row = row - 1
CASE CHR$(0) + CHR$(80)
row = row + 1
CASE CHR$(0) + CHR$(75)
col = col - 1
CASE CHR$(0) + CHR$(77)
col = col + 1
END SELECT
SELECT CASE MID$(maze$(row), col, 1) 'wont let you get passed maze
CASE "¹", "º", "»", "¼", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã"
row = oldrow
col = oldcol
CASE "." 'when you eat a dot, it dissapears
MID$(maze$(row), col, 1) = " ": BEEP
dots = dots - 1
END SELECT
'*******************
'Ghost Movements
'*******************
IF RND < .9 THEN 'randomizes the ghosts movements
oldrow = ghostrow
SELECT CASE ghostrow
CASE IS < row 'moves ghost closer to you
ghostrow = ghostrow + 1
CASE IS > row
ghostrow = ghostrow - 1
END SELECT
oldrow = ghostrow
SELECT CASE ghostcol 'moves ghost closer to you
CASE IS < row
ghostrow = ghostrow + 1
CASE IS > row
ghostrow = ghostrow - 1
END SELECT
'wont let ghost go through walls
SELECT CASE MID$(maze$(ghostrow), ghostcol, 1)
CASE "¹", "º", "»", "¼", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã"
ghostrow = oldrow
END SELECT
'makes the ghost stay if he tries to
'get out of maze
SELECT CASE MID$(maze$(ghostrow), ghostcol, 1)
CASE "¹", "º", "»", "¼", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã"
ghostcol = oldcol
END SELECT
END IF
LOOP UNTIL press$ = CHR$(13)
and thats that......
Posts: 2,765
Threads: 138
Joined: Nov 2002
nifty
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,368
Threads: 195
Joined: Jan 2003
just have a var to store the key and have pacman move the next turn with that var if a new one has not been set...
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.
Posts: 1,813
Threads: 284
Joined: Mar 2003
It was an okay game. Problem is, CHR$(27) is [ESCAPE]. Better for "escaping" the program than [ENTER] is. Also, your monster jumped across the whole "level" at one point. I don't know how, but he did. And I managed to walk right past him at one point also, and he didn't even chase after me or kill me. What a loser ghost he is!
I wanna try my hand at a pacman game. Only problem is I'd have to go all out on it (graphics, keyhandling, memory, etc) and that would take too much time.
earn.
Posts: 19
Threads: 7
Joined: May 2003
OK heres my new code.....
with title screen and all..
Code: CLS 'clear screen
SCREEN 13 'set screen resolution
DIM maze(1 TO 11) AS STRING 'Declares that there is 6 maze variables
DIM maze2(1 TO 18) AS STRING
DIM ghostrow(1 TO 3) AS INTEGER
DIM ghostcol(1 TO 3) AS INTEGER
DIM oldrow
DIM oldcol
maze$(1) = "ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃû" 'the following is the maze in
maze$(2) = "º.......º.......º" 'the variables
maze$(3) = "º.º.ÃÃÃÃÃÃÃÃÃ.º.º"
maze$(4) = "º.º...........º.º"
maze$(5) = "º.ÃÃû.ÃÃÃ.ÃÃü.º"
maze$(6) = "º.......º.......º"
maze$(7) = "º....º.. ..º....º"
maze$(8) = "º...ÃÃÃÃÃÃÃÃÃ...º"
maze$(9) = "º...º...º...º...º"
maze$(10) = "º....... .......º"
maze$(11) = "ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃü"
maze2$(1) = "ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ"
maze2$(2) = "Ã........ÃÃ..........ÃÃ........Ã"
maze2$(3) = "Ã.ÃÃÃÃÃÃ.ÃÃ.ÃÃÃÃÃÃÃÃ.ÃÃ.ÃÃÃÃÃÃ.Ã"
maze2$(4) = "Ã..............................Ã"
maze2$(5) = "ÃÃÃÃ.ÃÃÃ.ÃÃÃÃÃ.ÃÃ.ÃÃÃÃÃ.ÃÃÃ.ÃÃÃÃ"
maze2$(6) = " Ã.ÃÃÃ.ÃÃÃÃÃ.ÃÃ.ÃÃÃÃÃ.ÃÃÃ.Ã"
maze2$(7) = "ÃÃÃÃ.ÃÃÃ.......ÃÃ.......ÃÃÃ.ÃÃÃÃ"
maze2$(8) = " .ÃÃÃÃÃÃ ÃÃÃÃÃÃÃÃ ÃÃÃÃÃÃ. "
maze2$(9) = "ÃÃÃÃ. .ÃÃÃÃ"
maze2$(10) = " Ã.ÃÃÃÃÃà ÃÃÃÃÃÃÿ ÃÃÃÃÃÃ.Ã"
maze2$(11) = " Ã.ÃÃà ³ ³ ÃÃÃ.Ã"
maze2$(12) = "ÃÃÃÃ.ÃÃÃ ÃÃ ÃÃÃÃÃÃÃÃ ÃÃ ÃÃÃ.ÃÃÃÃ"
maze2$(13) = " . ÃÃ ÃÃ . "
maze2$(14) = "ÃÃÃÃ.ÃÃÃÃÃÃÃÃÃ ÃÃ ÃÃÃÃÃÃÃÃÃ.ÃÃÃÃ"
maze2$(15) = " Ã........ ÃÃ .......Ã"
maze2$(16) = "ÃÃÃÃ.ÃÃÃÃÃÃ.ÃÃÃÃÃÃÃÃÃ.ÃÃÃÃÃ.ÃÃÃÃ"
maze2$(17) = "Ã.............. ..............Ã"
maze2$(18) = "Ã.ÃÃÃÃÃ.ÃÃÃÃÃÃ.ÃÃ.ÃÃÃÃÃÃ.ÃÃÃÃÃ.Ã"
row = 7 'says which row pacman is at
col = 9 'says which column pacman is at
ghostrow = 10 'says which row the ghost starts at
ghostcol = 9 'says which column the ghost starts at
dots = 93 'declares how many dots there are
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
CIRCLE (50, 150), 40, 14, .9, 5.4
DRAW "s8 bm50,150 e13 g13 f13"
DO
press$ = INKEY$
LOOP UNTIL press$ = CHR$(13)
SCREEN 0
LOCATE 10, 8
PRINT "Created By: Justin Malcolm"
FOR i# = 1 TO 10000000 STEP 2
NEXT i#
LOCATE 10, 6
PRINT "Originally Created By: Micro$oft"
FOR b# = 1 TO 10000000 STEP 2
NEXT b#
PRINT
PRINT
PRINT
COLOR 14, 0
PRINT TAB(25); "C is PaQman"
PRINT
COLOR 4, 0
PRINT TAB(25); " is a Ghost"
PRINT
COLOR 15, 0
PRINT TAB(25); "'.' are the food"
PRINT
COLOR 6, 0
PRINT
PRINT TAB(25); "Press any key to play..."
DO
press$ = INKEY$
LOOP UNTIL press$ <> ""
CLS
points% = 0
lives% = 3
DO 'Begins Game loop
LOCATE 1, 1 'positions the maze
FOR count = 1 TO 11
COLOR 1, 0 'Prints the maze out
PRINT maze$(count)
COLOR 15
NEXT count
LOCATE row, col
COLOR 14, 0 'Prints Pacman
PRINT "C"
LOCATE ghostrow, ghostcol
COLOR 4, 0 'makes ghost red
PRINT "" 'Prints ghost
COLOR 15
LOCATE 13, 2: PRINT "Lives: "; lives%; " Points: "; points%
IF dots = 0 THEN 'declares when the user can win
LOCATE 15, 1
PRINT "You Have Won" 'Prints You win, if you eat all
PRINT "Get Ready for..." 'dots
PRINT "LEVEL 2"
END
END IF
'The following condition is for
'when you get eaten by a ghost
IF ((row = ghostrow) AND (col = ghostcol)) THEN
LOCATE row, col
PRINT " "
row = 7
col = 9
LOCATE row, col
COLOR 14, 0
PRINT "C"
COLOR 15, 0
lives% = lives% - 1
ELSEIF lives% <= 0 THEN
CLS
LOCATE 12, 8
PRINT "You Lost All Of Your Lives"
FOR i# = 1 TO 10000000 STEP 5
NEXT i#
END
END IF
'DO 'Program freezes until user press'
press$ = INKEY$ 'any key
'LOOP UNTIL press$ <> ""
blah = TIMER + .01
DO
LOOP UNTIL TIMER > blah
oldrow = row 'every move is stored into the variable
oldcol = col
SELECT CASE press$ 'the following is the conditions for
CASE CHR$(0) + CHR$(72) 'the key press'
'DO WHILE press$ = CHR$(0) + CHR$(72)
row = row - 1
'LOOP
CASE CHR$(0) + CHR$(80)
'DO WHILE press$ = CHR$(0) + CHR$(80)
row = row + 1
'LOOP
CASE CHR$(0) + CHR$(75)
'DO WHILE press$ = CHR$(0) + CHR$(75)
col = col - 1
'LOOP
CASE CHR$(0) + CHR$(77)
'DO WHILE press$ = CHR$(0) + CHR$(77)
col = col + 1
'LOOP
END SELECT
SELECT CASE MID$(maze$(row), col, 1) 'wont let you get passed maze
CASE "¹", "º", "»", "¼", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã"
row = oldrow
col = oldcol
CASE "." 'when you eat a dot, it dissapears
MID$(maze$(row), col, 1) = " ": PLAY "l16<<<b-"
points% = points% + 10
dots = dots - 1
END SELECT
'*******************
'Ghost Movements
'*******************
IF RND < .1 THEN 'randomizes the ghosts movements
oldrow = ghostrow
SELECT CASE ghostrow
CASE IS < row 'moves ghost closer to you
ghostrow = ghostrow + 1
CASE IS > row
ghostrow = ghostrow - 1
END SELECT
'wont let ghost go through walls
SELECT CASE MID$(maze$(ghostrow), ghostcol, 1)
CASE "¹", "º", "»", "¼", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã"
ghostrow = oldrow
END SELECT
IF ghostrow = oldrow THEN 'moves ghost closer to you
oldcol = ghostcol
SELECT CASE ghostcol
CASE IS < col
ghostcol = ghostcol + 1
CASE IS > col
ghostcol = ghostcol - 1
END SELECT
END IF
'makes the ghost stay if he tries to
'get out of maze
SELECT CASE MID$(maze$(ghostrow), ghostcol, 1)
CASE "¹", "º", "»", "¼", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã"
ghostcol = oldcol
END SELECT
END IF
LOOP UNTIL press$ = CHR$(13)
any suggestions...besides that the second maze is unfinished?
Posts: 1,241
Threads: 107
Joined: Feb 2003
for moving, and then keeping the pac man moving, store his direction to a var.
Code: dir$=up
if dir$ = up then
pacy = pacy + 1
end if
if dir$ = down then
pacy = pacy - 1
end if
and so on and so forth. dont use that code though, there are so many problems with it unless you modify it.
the mind is a beautiful thing, use it and make the world a more beautiful place.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Suggestion: Make the playing area bigger, and let the ghost move even if Pacman isn't. Otherwise wholeGame=veryEasy.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 19
Threads: 7
Joined: May 2003
Ok how i do that then?? its due on Friday....tommorow.....so i have no time
if u can, please help
|