Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pac-man likes to eat.....pellets...but why cant i make him!!
#1
im making the standered newbie pac-man game in text mode.
i added a few things here and there that arn't in the tut.
um but mainly my counter thing called "pellets" arnt working right.
ill post the code.
Code:
CLS
LOCATE 7, 20
PRINT "PAC-MAN"
SLEEP 2
CLS
DIM pellets AS INTEGER
game:
CLS
y = 2
x = 1
grow% = 6
gcol% = 8

COLOR 4
PRINT "0000000"
PRINT "  * * *"
PRINT "0*000*0"
PRINT "0 0?0 0"
PRINT "0* * *0"
PRINT "0 000 0"
PRINT " * 0 * "
PRINT "0 * * 0"
PRINT "0000000"
pellets = 13

DO
a$ = INKEY$
checky = y: checkx = x

LOCATE y, x: COLOR 0: PRINT "C"                     'print nothing were pacman will be.
LOCATE 8, 6: COLOR 0: PRINT "G"                    ' print nothing were ghost will be

IF a$ = CHR$(0) + CHR$(72) AND y - 1 > 0 THEN checky = y - 1                     'movment and clipping
IF a$ = CHR$(0) + CHR$(75) AND x - 1 > 0 THEN checkx = x - 1
IF a$ = CHR$(0) + CHR$(80) THEN checky = y + 1
IF a$ = CHR$(0) + CHR$(77) THEN checkx = x + 1
IF x > 7 THEN x = 7
IF SCREEN(checky, checkx) <> 48 THEN                        'more clipping
x = checkx
y = checky
END IF

LOCATE y, x: COLOR 4: PRINT "C"        'now we really print pac-man
LOCATE 8, 6: COLOR 5: PRINT "G"                           ' now we really print ghost

IF x = grow% AND y = gcol% THEN GOTO music        ' if pac-man hits ghost then goto music

                                                                                                              
IF x = 7 AND y = 2 THEN x = 1 AND y = 2        'portal upper
LOCATE 2, 7
PRINT " "

IF x = 7 AND y = 7 THEN x = 1 AND y = 7        ' portal lower
LOCATE 7, 7
PRINT " "

IF pellets = 0 THEN            'counter
LOCATE 13, 42
PRINT "YOU WIN"
END IF

IF y = 4 AND x = 4 THEN        ' collision with Power Pellet
LOCATE 11, 20
PRINT "POWER PELLET"
END IF
LOOP UNTIL a$ = CHR$(27)

IF a$ = CHR$(27) THEN
END
END IF

music:
CLS
LOCATE 10, 10
COLOR 3
PRINT "YOU GOT EATEN!!"
PLAY "agfedc"
END

you can see im missing the actual code for the counter"pellets" but that is because i dont know how. Do i go like this:

IF "C" = "*" then pellets = pellets - 1
i tried that and it doesnt work what should i do?
Reply
#2
before this line

Code:
LOCATE y, x: COLOR 4: PRINT "C"      'now we really print pac-man

place this code:

Code:
IF SCREEN(y, x) = ASC("*") THEN pellets = pellets - 1

That line reads the screen contents at position x,y and returns the ASCII code of the char which is placed there. We are comparing it to the ASCII code of "*". For more info, check SCREEN and ASC in the QB help.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
OHHHHH. thank you very much man. really helped.
Reply
#4
now that i have the pellet prob worked out. im trying to reduce flicker. i have read prefvious posts, and triend them but it hasnt worked it keeps saying ilegal function cal when ever i try

if y<>oldy or x<>oldx then
locate oldy,oldx
color 0
print "C"

I dont know whats wrong.
Reply
#5
Make sure that oldx and oldy are both NONZERO when your program starts. This can be done easily:
Code:
'your level loads HERE
'<---
'now we set oldx and oldy to x and y by default

oldx = x
oldy = y
Reply
#6
its still not working here is that part of my code

Code:
pellets = 11

DO

oldx = x
oldy = y

a$ = INKEY$
checky = y: checkx = x
IF oldy <> y OR oldx <> x THEN
LOCATE oldy, oldx
COLOR 0
PRINT "C"
oldy = y
oldx = x
END IF



IF a$ = CHR$(0) + CHR$(72) AND y - 1 > 0 THEN checky = y - 1                     'movment and clipping
IF a$ = CHR$(0) + CHR$(75) AND x - 1 > 0 THEN checkx = x - 1
IF a$ = CHR$(0) + CHR$(80) THEN checky = y + 1
IF a$ = CHR$(0) + CHR$(77) THEN checkx = x + 1
IF x > 7 THEN x = 7
IF SCREEN(checky, checkx) <> 48 THEN                        'more clipping
x = checkx
y = checky
thanks
Reply
#7
Instead of doing this (what YOU did):
Code:
DO

oldx = x
oldy = y

Try doing this (what I do):
Code:
oldx = x
oldy = y

DO

It will help very much Wink
Reply
#8
woah!! your right! thanks
Reply
#9
No problem Wink
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)