Im posting the "PAC MAN" code here that I lost interest with. There are a million such clones out there and this slowly sank into my mind. So, I changed a few things, the ghosts see through walls (C`mon, Ghosts cant see through solid matter?) and home in on you - resulting in a very difficult challenge. I had planned a maze that took skill to master without loosing lifes but time/life/another clone of it etc put me off.
You will find in this code a prog that allows you to explore the maze with moving ghosts that hunt you. Erm, thats all I`m afraid. Ive substitued LOADSPRITE with bland blocks.
Theres no pro code here folks, just a foundation I typed up over several evenings to get things running.
If any of you admire it, explore it and make/add changes.
///////
The code
//////
// --------------------------------- //
// Project: PACMAN
// Start: Friday, February 17, 2012
// IDE Version: 10.244
SETTRANSPARENCY RGB(0,0,0) ; SETSCREEN 640,400,0
LOADFONT "smalfont.bmp",1
SETFONT 1
GLOBAL a,b,col ; c=10 ; col=RGB(255,255,20)
//////////////////////////
//// Title Screen
//////////////////////////
WHILE KEY(57)=FALSE
FOR a=0 TO 200
DRAWLINE 0,a-1,640,a-1,RGB(col+10/2+b,col+10+b,col+a+b)
DRAWLINE 0,400-a,640,400-a,RGB(col+10/2+b,col+10+b,col+a+b)
INC b,1
IF b=20 THEN b=0
NEXT
PRINT "SCAPEGHOST", 235,10
PRINT "After Eons of wandering aimlessly ",25,30
PRINT "around mazes, you decide you want out!",2,50
PRINT "By eating the Pills scattered around",15,70
PRINT "your shadow of a body will find a new",8,90
PRINT "existence within the world of man...",15,110
//// Yawn...not another fecking Pac Man Clone :)
PRINT "<SPACE>",250,300
//INC nextpage ; IF nextpage=500 THEN nextpage=0 ; GOSUB highscore
SHOWSCREEN
WEND
//// Maze stuff
ripple1=5 ; ripple2=20 ; count=1 ; syncgrafix1=10 ; wallsize=10 ; syncgrafix=5 ; effect1=10 ; count=0 ; effect=6
DIM map[31][17] ; GOSUB maze
score=0 ; t$="000"+score ; mdir=1 ; ans=0 ; anf=3
//// Player stuff
ghostspeed=8 ; playerspeed=5 ; px=11 ; py=7
game=1
animovementdelayount=1
ans=0 ; anf=3
GOSUB grafix
GOSUB setupghosts
///////////////////////////////////////////////
////////////////////////////////////////////////
/// MAIN LOOP
////////////////////////////////////////////////
///////////////////////////////////////////////
WHILE NOT FALSE
GOSUB domazebackground
GOSUB drawmaze
GOSUB movemuncher // & ghosts via a delay
GOSUB stats
SHOWSCREEN
WEND
////Routines
SUB drawmaze:
INC count,1
FOR y=0 TO 16
FOR x=0 TO 29
xx=x*wallsize+SIN(count+y*ripple1)*effect1 // For the walls
yy=y*wallsize+SIN(count+x*ripple1)*20 // For the walls
xxx=px*wallsize+SIN(count+py*ripple1)*effect1 // To Clip player and spooks to maze
yyy=py*wallsize+SIN(count+px*ripple1)*20 // Ditto
IF map[x][y]=-1 // -1=no pill, 0=pill
DRAWSPRITE 5,xx*2,yy*2
ENDIF
IF map[x][y]=0 // Draw pill
DRAWSPRITE 0,xx*2,yy*2
ENDIF
IF map[x][y]=1 // Maze Walls
col=RGB(COS(count+y*2+x*2.5)*100+100,SIN(count+y*5)*100+100,SIN(count+x*5)*100+100)
DRAWRECT xx*2+effect,yy*2+effect,wallsize,wallsize,RGB(COS(count+y*2)*100+100,SIN(count+y*5)*127+127,SIN(count+x*5)*127+127)
ENDIF
//DRAWANIM 3,image,xxx*2,yyy*2 // Draw Player
DRAWSPRITE 3,xxx*2,yyy*2
FOR a=0 TO 3
IF ghost[a].x=x AND ghost[a].y=y // Draw Spooks
DRAWSPRITE 4,xx*2,yy*2
ENDIF
NEXT
NEXT
NEXT
ENDSUB
SUB movemuncher:
IF KEY(203)
dirx=-1 ; diry=0
ENDIF
IF KEY(205)
diry=0 ; dirx=1
ENDIF
IF KEY(200)
diry=-1 ; dirx=0
ENDIF
IF KEY(208)
diry=1 ; dirx=0
ENDIF
////Check Lefy
IF dirx=-1 AND map[INTEGER(px-1)][INTEGER(py)]<>1
INC movementdelay ; IF movementdelay > playerspeed THEN DEC px ; GOSUB moveghosts
IF movementdelay = playerspeed + 1
dirx=0 ; movementdelay=0
ENDIF
ENDIF
////Check Right
IF dirx=1 AND map[INTEGER(px+1)][INTEGER(py)]<>1
INC movementdelay ; IF movementdelay > playerspeed THEN INC px ; GOSUB moveghosts
IF movementdelay = playerspeed + 1
dirx=0 ; movementdelay=0
ENDIF
ENDIF
////Check Down
IF diry=1 AND map[INTEGER(px)][INTEGER(py+1)]<>1
INC movementdelay ; IF movementdelay > playerspeed THEN INC py ; GOSUB moveghosts
IF movementdelay = playerspeed + 1
diry=0 ; movementdelay=0
ENDIF
ENDIF
////Check Up
IF diry=-1 AND map[INTEGER(px)][INTEGER(py-1)]<>1
INC movementdelay ; IF movementdelay > playerspeed THEN DEC py ; GOSUB moveghosts
IF movementdelay = playerspeed + 1
diry=0 ; movementdelay=0
ENDIF
ENDIF
ENDSUB
SUB moveghosts:
INC ghostdelay ; IF ghostdelay=ghostspeed+1 THEN ghostdelay=0
IF ghostdelay<ghostspeed
GOTO movethespooks
ENDIF
IF ghostdelay=ghostspeed
FOR a=0 TO 3
IF ghost[a].x<INTEGER(px) AND map[ghost[a].x+1][ghost[a].y]=0
ghost[a].x=ghost[a].x+1
ENDIF
IF ghost[a].x>INTEGER(px) AND map[ghost[a].x-1][ghost[a].y]=0
ghost[a].x=ghost[a].x-1
ENDIF
IF ghost[a].y>INTEGER(py) AND map[ghost[a].x][ghost[a].y-1]=0
ghost[a].y=ghost[a].y-1
ENDIF
IF ghost[a].y<INTEGER(py) AND map[ghost[a].x][ghost[a].y+1]=0
ghost[a].y=ghost[a].y+1
ENDIF
NEXT
ENDIF
movethespooks: // via the drawmaze
ENDSUB// set up ghosts
SUB setupghosts:
TYPE spook
x ; y ; im ; spooked ; dead
ENDTYPE
GLOBAL ghost[] AS spook
DIM ghost[4]
RESTORE ghostdata
// Set up xpos,ypos,anim image range, directionx/y, spooked(you ate the power pill,dead
FOR a=0 TO 3
READ aa,b,c,d,e
ghost[a].x=aa ; ghost[a].y=b ; ghost[a].im=c ; ghost[a].spooked=d ; ghost[a].dead=e
NEXT
STARTDATA ghostdata:
DATA 7,2,0,0,0
DATA 12,4,4,0,0
DATA 10,9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,0,0,0,0,0,0,0,0,0,0,1,1
DATA 1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
DATA 1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
ENDDATA
ENDSUB
SUB domazebackground:
FOR a=0 TO 499
IF spot[a].y<300
DRAWRECT spot[a].x,spot[a].y,spot[a].zz,spot[a].zz,RGB(0,0,a)
ELSE
DRAWRECT spot[a].x,spot[a].y,spot[a].zz,spot[a].zz,RGB(0,10,a/10)
ENDIF
INC spot[a].zz,1
IF spot[a].zz>20
spot[a].zz=RND(5)
spot[a].x=RND(639)
spot[a].y=RND(399)
ENDIF
NEXT
ENDSUB
SUB grafix:
//LOADSPRITE "dot.bmp", 0
DRAWRECT 0,0,2,2,RGB(255,255,255)
GRABSPRITE 0,0,0,2,2
//LOADANIM "wall.b
//LOADANIM "player.bmp",3,22
DRAWRECT 0,0,22,23,RGB(255,255,0)
GRABSPRITE 3,0,0,22,23 // player
//LOADANIM "ghosts.bmp",4,24,24
DRAWRECT 0,0,22,23,RGB(0,255,255)
GRABSPRITE 4,0,0,22,23
//LOADSPRITE "nodot.bmp", 5
//LOADANIM "score.bmp",6,162,33
//Background
TYPE dot ; x ; y ; sx ; sy ; zz ; ENDTYPE
GLOBAL spot[] AS dot
DIM spot[1000]
FOR a=0 TO 999
spot[a].x=RND(639) ; spot[a].y=RND(399)
IF RND(1)=0
spot[a].sx=2
ELSE
spot[a].sx=-2
ENDIF
IF RND(1)=0
spot[a].sy=-2
ELSE
spot[a].sy=2
ENDIF
spot[a].zz=RND(5)
NEXT
ENDSUB