Hola buenas tardes
anexo prg del archivo del juego de pacman hecho en fivewin
le faltan detallitos pero ya se puede jugar
http://www.eleben.com.mx/pacman.zip
// 15 de abril del 2015
// chino72vale@hotmail.com
#include "Fivewin.ch"
MEMVAR xTeclas
MEMVAR nXPos, nYPos, xDonde, oSprite, nXposa, nYposa
MEMVAR aMatriz, Maxren, MaxCol, Omuro, xVidas
MEMVAR oComida, nComida, Van, aComidas, oFantasmas, fXpos, fYpos
MEMVAR xfdonde, XOTRA, XPOS, osay, csay, ofanta1, ofanta2, ofanta3, ofanta4, ofanta5, Ownd
FUNCTION MAIN()
聽 聽 local oBrush, oTimer
聽 聽 local i, y, n:=0, m:=0
聽 聽
聽 聽 PUBLIC xTeclas, xvidas
聽 聽 PUBLIC nXPos, nYPos
聽 聽 PUBLIC Xdonde, oSprite, oMuro
聽 聽 PUBLIC aMatriz, Maxren, Maxcol, Omuro
聽 聽 PUBLIC oComida, nComida, Van, Acomidas
聽 聽 PUBLIC fXpos, fYpos, Ofantasmas
聽 聽 PUBLIC xFdonde, xotra, XPOS
聽 聽 PUBLIC OSAY, CSAY, OFANTA, OFANTA2, OFANTA3, OFANTA4, ofanta5, Ownd
聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽//12345678901234567890123456789
聽 聽 amatriz := { {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"x 聽o 聽o o o xxxxx o o o 聽o 聽x"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"x xxx xxoxx ooooo xxoxx xxx x"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxoxxoxxxxxoxxoxxoxxxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xooooooooooooooooooooooooooox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxoxxxxxoxxxxxoxxoxxxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoooooxxoooooxoxoooooxxooooox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxxxxxoxoxoxxxxxxoxxxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxoooooooooooooxxoxxxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"toooooxxoxxxxxoxxxxxoxxooooof"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxoxxxxxoxxxxxoxxoxxxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxoooooooooooooxxoxxxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxxxxxoxoxoxxxxxxoxxxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoooooxxoooooxoxoooooxxooooox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxoxxxxxoxxxxxoxxoxoxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoooooooooooooooooooxoxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoooooxxxxoxxxoxxxxoxxxoxoxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xoxxxoxxxxooooooooooxxxoxoxox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xooooooooooxxxxxxxxooooooooox"},;
聽 聽 聽 聽 聽 聽 聽 聽 聽{"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}
聽 聽 聽 聽 聽 聽 聽 聽 聽//65*37
聽 聽
聽 聽 nComida:=0
聽 聽 XTECLAS = 0
聽 聽 Van:=0
聽 聽 XPOS:=0
聽 聽 nXPos 聽 = 450 聽 聽 // columna
聽 聽 nYPos 聽 = 540 聽 聽 // rengloN
聽 聽 xdonde = 1
聽 聽 Maxren:=20
聽 聽 Maxcol:=29
聽 聽 xotra:=0
聽 聽 xfdonde:=2
聽 聽 // posicion inicial fantasma
聽 聽 fXpos:=5*30
聽 聽 fYpos:=15*30
聽 聽 xVidas:=0
聽 聽
聽 聽 aComidas:=array(MaxRen,MaxCol)
聽 聽 for i:=1 to maxren
聽 聽 聽 for y:= 1 to maxcol
聽 聽 聽 聽 aComidas[i][y]=substr(amatriz[i][1],y,1)
聽 聽 聽 聽 if substr(amatriz[i][1],y,1)="o"
聽 聽 聽 聽 聽 聽nComida++
聽 聽 聽 聽 endif
聽 聽 聽 next y
聽 聽 next i
聽 聽
聽 聽 omuro:=array(maxren,maxcol)
聽 聽
聽 聽 DEFINE WINDOW oWnd FROM 1,1 to 50,125
聽 聽 @ nYpos, nxPos BITMAP oSprite FILE "recpac\pacman.bmp" 聽PIXEL 聽size 30,30 NOBORDER
聽 聽
聽 聽 @ fxPos, fYpos BITMAP ofantasmas FILE "recpac\fanta1.bmp" 聽PIXEL 聽size 30,30 NOBORDER
聽 聽
聽 聽 oFanta1:=TFANTASMON():NEW(270,300,,"recpac\fanta2.bmp")
聽 聽 ofanta2:=TFANTASMON():NEW(360,360,,"recpac\fanta3.bmp")
聽 聽 ofanta3:=TFANTASMON():NEW(360,360,,"recpac\fanta4.bmp")
聽 聽 ofanta4:=TFANTASMON():NEW(360,360,,"recpac\fanta5.bmp")
聽 聽 ofanta5:=TFANTASMON():NEW(360,360,,"recpac\fanta6.bmp")
聽 聽 n:=30 聽
聽 聽
聽 聽 // DIBUJANDO LA PANTALLA MAESTRA
聽 聽 for i:= 1 to maxren
聽 聽 聽 聽m:=30
聽 聽 聽 聽for y:= 1 to maxcol
聽 聽 聽 聽 聽 if aComidas[i][y]="x"
聽 聽 聽 聽 聽 聽 聽@ n, m BITMAP omuro[i][y] size 30,30 of ownd ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FILE "recpac\marcos.bmp" PIXEL NO BORDER
聽 聽 聽 聽 聽 ELSE
聽 聽 聽 聽 聽 聽 if aComidas[i][y]="o"
聽 聽 聽 聽 聽 聽 聽 聽 聽@ n, m BITMAP omuro[i][y] size 30,30 of ownd ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FILE "recpac\comidita.bmp" PIXEL 聽NOBORDER
聽 聽 聽 聽 聽 聽 聽ENDIF
聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 m:=m+30
聽 聽 聽 next y
聽 聽 聽 n:=n+30
聽 聽 聽
聽 聽 next i
聽 聽 聽 聽 聽
聽 聽 // TERMINA dibujo pantalla
聽 聽
聽 聽 oWnd:bKeyDown :={ | nKey | xteclas:=Teclas(nKey, oSprite) 聽} 聽 聽 聽 聽
聽
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 oSprite:lTransparent = .t.
聽 聽
聽 聽 ownd:binit := { || vueltacompleta() }
聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 ACTIVATE WINDOW oWnd // CENTERED
聽
聽 聽 RETURN NIL
聽 聽
聽 聽
聽 聽
FUNCTION TERMINO()
LOCAL DEV:=.t.
LOCAL I, Y
FOR I:=1 TO MAXREN
聽 FOR Y:=1 TO MAXCOL
聽 聽 聽if aComidas[i][y]="o"
聽 聽 聽 聽 dev:=.f.
聽 聽 聽endif
聽 next y
next i
return dev 聽 聽
聽 聽 聽
聽 聽
FUNCTION VUELTACOMPLETA()
LOCAL I
local xcol:=15, xren:=18
sonido_Inicial()
聽
聽
do while xdonde<>10
checapos()
ofanta1:movimiento_Checapos()
ofanta2:movimiento_Checapos()
ofanta3:movimiento_Checapos()
ofanta4:movimiento_Checapos()
ofanta5:movimiento_Checapos()
nXposa:=nXpos
nyPosa:=nYpos
IF XDONDE =1 // abajo
聽 聽nypos = nypos +30
聽 聽xren:=nypos/30
聽 聽xcol:=nxpos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 nYpos := nYpos -30
聽 聽endif
聽 oSprite:LoadBmp( "recpac\pacmana.bmp")
聽 oWnd:Refresh()
ENDIF
IF XDONDE =0 聽// arriba
聽 聽nypos = nypos -30
聽 聽xren:=nypos/30
聽 聽xcol:=nxpos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 nYpos := nYpos +30
聽 聽endif
聽 聽oSprite:LoadBmp( "recpac\pacmant.bmp")
聽 聽oWnd:Refresh()
聽 聽
ENDIF
IF XDONDE =2 聽// izquierda
聽 聽nXpos = nXpos -30
聽 聽xren:=nypos/30
聽 聽xcol:=nxpos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 nXpos := nXpos +30
聽 聽else
聽 聽 聽 if aComidas[xren][xcol]="t"
聽 聽 聽 聽 聽nxpos:=870
聽 聽 聽 endif
聽 聽 聽
聽 聽endif
聽 聽oSprite:LoadBmp( "recpac\pacmani.bmp")
聽 聽oWnd:Refresh()
聽 聽
ENDIF
IF XDONDE =3 // derecha
聽 聽nXpos:= nXpos +30
聽 聽xren:=nypos/30
聽 聽xcol:=nxpos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 nXpos := nxpos -30
聽 聽else
聽 聽 聽 if aComidas[xren][xcol]="f"
聽 聽 聽 聽 聽nxpos:=30
聽 聽 聽 endif
聽 聽endif
聽 聽
聽 oSprite:LoadBmp( "recpac\pacmand.bmp")
聽 oWnd:Refresh()
聽 聽
ENDIF
if aComidas[xren][xcol]="o"
聽 聽 omuro[xren][xcol]:end()
聽 聽 aComidas[xren][xcol]:=" "
聽 聽 van ++
聽 聽 Sonido_Comiendo()
else
聽 聽// Sonido_sincomer()
聽 聽 聽
endif 聽
// corrida del fantasmon wey
ofanta1:Movimiento_Fantasma()
ofanta2:Movimiento_Fantasma()
ofanta3:Movimiento_Fantasma()
ofanta4:movimiento_Fantasma()
ofanta5:movimiento_Fantasma()
IF XFDONDE =1 // abajo
聽 聽fxpos = fxpos +30
聽 聽xren:=fxpos/30
聽 聽xcol:=fypos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 fxpos := fxpos -30
聽 聽endif
聽 聽
ENDIF
IF XFDONDE =0 聽// arriba
聽 聽fxpos = fxpos -30
聽 聽xren:=fxpos/30
聽 聽xcol:=fypos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 fxpos := fxpos +30
聽 聽endif
聽 聽
ENDIF
IF XFDONDE =2 聽// izquierda
聽 聽fypos = fypos -30
聽 聽xren:=fxpos/30
聽 聽xcol:=fypos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 聽fypos := fypos +30
聽 聽// 聽 xfdonde:=1
聽 聽// 聽 fxpos:=fxpos+30
聽 聽 聽
聽 聽else
聽 聽 聽 if aComidas[xren][xcol]="t"
聽 聽 聽 聽//fypos := fypos +30
聽 聽 聽 聽 聽 聽 聽fYpos:=840
聽 聽 聽 endif
聽 聽 聽
聽 聽endif
聽 聽
ENDIF
IF XFDONDE =3 // derecha
聽 聽fypos:= fypos +30
聽 聽xren:=fxpos/30
聽 聽xcol:=fypos/30
聽 聽if aComidas[xren][xcol]="x"
聽 聽 聽 fypos := fypos -30
聽 聽else
聽 聽 聽 if aComidas[xren][xcol]="f"
聽 聽 聽 聽 // fypos := fypos -30
聽 聽 聽 聽 聽fYpos:=60
聽 聽 聽 endif
聽 聽endif
聽 聽
ENDIF
聽
// movimiento del fantasma
Mueve_Pacman()
Mueve_Fantasma()
ofanta1:Mover_Fantasma()
oFanta2:Mover_Fantasma()
ofanta3:Mover_Fantasma()
ofanta4:Mover_Fantasma()
ofanta5:Mover_Fantasma()
if (nYpos=fxpos .and. nXpos=fypos) .or. (nYposa=fXpos .and. nxposa=fypos) 聽 聽 // agarre del fantamas al pacman
聽 聽sonido_tecomio()
聽 聽syswait(1.9)
聽
聽// 聽? "ey estoy en 3 son dos opciones ", xpos, xotra, xfdonde
聽 聽nXPos 聽 = 450 聽 聽 // movemos al pacman alos valor de inicio we
聽 聽nYPos 聽 = 540 聽
聽 聽
聽 聽fXpos:=5*30 聽 聽 聽 // movemos al fantasmas al valor inicial
聽 聽fYpos:=15*30
聽 聽xfdonde:= 2
聽 聽 聽
聽 聽xVidas++ 聽 聽 // ya le dio en la madre los fantamas del caribe al pacman
聽 聽if xvidas=3
聽 聽 聽 Sonido_final()
聽 聽 聽 syswait(5)
聽 聽 聽 quit
聽 聽endif
聽 聽
endif 聽
IF XDONDE=10 .or. van=nComida 聽// vamanos para fuera
// "ey estoy en 3 son dos opciones ",xpos, xotra, 聽xfdonde
聽 聽Sonido_final()
聽 聽syswait(5)
聽 聽QUIT
ENDIF
enddo
?//finalizo bye"
Sonido_final()
syswait(5)
RETURN NIL
聽
Function Mueve_Pacman()
聽 聽oSprite:Move( nYPos, nXPos, , , .T. )
聽 聽syswait(.15)
Return NIl
Function Mueve_fantasma()
聽 聽ofantasmas:Move( fxPos, fyPos, , , .T. )
Return NIl
Function Sonido_Termina()
聽 聽SndPlaySound( "recpac\cry.wav", 3 )
聽 聽syswait(.5)
Return NIL
Function Sonido_Comiendo()
聽 聽SndPlaySound( "recpac\comida.wav", 3 )
Return Nil
Function Sonido_Inicial()
聽 聽 SndPlaySound( "recpac\pacman_beginning\pacman_beginning.wav", 3 )
聽 聽 syswait(4.0)
Return Nil
Function Sonido_rComiendo()
聽 聽 SndPlaySound( "recpac\pacman_eatfruit\pacman_eatfruit.wav", 3 )
Return Nil
Function Sonido_Final()
聽 聽 SndPlaySound( "recpac\pacman_intermission.wav", 3 )
Return Nil
Function Sonido_tecomio()
聽 聽SndPlaySound( "recpac\pacman_death\pacman_death.wav", 3 )
Return Nil
Function Sonido_finalizar()
聽 聽SndPlaySound( "recpac\pacman_death\pacman_death.wav", 3 )
Return Nil
聽 聽
Function teclas(xKey, oSprite)
IF xkey = 38 聽//ARRIBA
聽 聽XDONDE = 0
endif
if xkey = 40 聽 // abajo
聽 聽 XDONDE = 1
聽 聽
endif
if xkey = 37
聽 聽XDONDE = 2
endif
if xkey = 39
聽 聽 XDONDE =3
endif
if xkey = 27
聽 聽xdonde=10
聽 聽
endif 聽
聽
Return XKEY
Function 聽checapos()
local xren, xcol
//local xotra:=0
local xnpos :=0
聽 聽xren:=fxpos/30
聽 聽xcol:=fypos/30
xotra:=0 聽
XPOS:=0
if !acomidas[xren+1][xcol]="x"
聽 聽xpos++
聽 聽xotra:=xotra + 1
endif
if !acomidas[xren-1][xcol]="x"
聽 聽xpos++
聽 聽xotra:= xotra + 2
endif
if !acomidas[xren][xcol-1]="x"
聽 聽xpos++
聽 聽xotra:= xotra + 3
endif
if !acomidas[xren][xcol+1]="x"
聽 聽xpos++
聽 聽xotra:= xotra + 4
endif
if xpos>2 聽 聽// quire decir que ay que random para decidi a que lugar ir we 聽
聽 聽xfdonde:=nrandom(3)
聽
else
聽 聽if xpos=2
聽 聽 聽 if xotra = 4 聽.or. xotra=6 .OR. XOTRA=5 聽//quire decir que esta en la esquina del 聽muro
聽 聽 聽 聽 聽xfdonde:=nrandom(3)
聽 聽 聽else
聽 聽 聽
聽 聽 聽 endif
聽 聽endif
聽 聽
endif
Return NIL
CLASS TFANTASMON
聽 聽DATA 聽 xfdonde INIT 2
聽 聽DATA 聽 ny 聽 聽 聽INIT 0
聽 聽DATA 聽 xModo 聽 INIT 0
聽 聽DATA 聽 xRen 聽 聽INIT 0
聽 聽DATA 聽 XcOL 聽 聽INIT 0
聽 聽DATA 聽 fXpos 聽 INIT 0
聽 聽DATA 聽 FyPOS 聽 INIT 0
聽 聽DATA 聽 oFanta 聽
聽 聽METHOD New()
聽 聽METHOD Mover_Fantasma()
聽 聽METHOD Movimiento_Fantasma()
聽 聽METHOD Movimiento_ChecaPos()
聽 聽METHOD Movimiento_Agarre()
ENDCLASS
METHOD New(fxPos, fyPos, ofanta, odibujo ) 聽CLASS TFANTASMON
聽 聽 聽@ fxPos, fYpos BITMAP ofanta FILE odibujo 聽PIXEL 聽size 30,30 NOBORDER 聽
聽 聽 聽::oFanta:=ofanta
聽 聽 聽::fxPos:=fxpos
聽 聽 聽::fYpos:=fYpos
RETURN SELF
METHOD Mover_Fantasma() CLASS TFANTASMON
聽 聽::ofanta:Move( ::fxPos, ::fyPos, , , .T. )
聽 聽::Movimiento_Agarre()
Return NIl
// agarre del fantamas
METHOD Movimiento_Agarre() 聽 CLASS TFANTASMON
if (nYpos=::fxpos .and. nXpos=::fypos) 聽.or. (nYposa=::fXpos .and. nxposa=::fypos) 聽// agarre del fantamas al pacman
聽 聽sonido_tecomio()
聽 聽syswait(1.9)
聽 聽// 聽? "ey estoy en 3 son dos opciones ", xpos, xotra, xfdonde
聽 聽nXPos 聽 = 450 聽 聽 // movemos al pacman alos valor de inicio we
聽 聽nYPos 聽 = 540 聽
聽 聽
聽 聽xVidas++ 聽 聽 // ya le dio en la madre los fantamas del caribe al pacman
聽 聽if xvidas=3
聽 聽 聽 Sonido_final()
聽 聽 聽 syswait(5)
聽 聽 聽 quit
聽 聽endif
聽 聽
Endif
RETURN NIL
// corrida del fantasmon wey
METHOD Movimiento_Fantasma() 聽 CLASS TFANTASMON
IF ::XFDONDE =1 // abajo
聽 聽::fxpos = ::fxpos +30
聽 聽::xren:=::fxpos/30
聽 聽::xcol:=::fypos/30
聽 聽if aComidas[::xren][::xcol]="x"
聽 聽 聽 ::fxpos := ::fxpos -30
聽 聽endif
聽 聽
聽 聽
ENDIF
IF ::XFDONDE =0 聽// arriba
聽 聽::fxpos = ::fxpos -30
聽 聽::xren:=::fxpos/30
聽 聽::xcol:=::fypos/30
聽 聽if aComidas[::xren][::xcol]="x"
聽 聽 聽 ::fxpos := ::fxpos +30
聽 聽endif
聽 聽
ENDIF
IF ::XFDONDE =2 聽// izquierda
聽 聽::fypos = ::fypos -30
聽 聽::xren:=::fxpos/30
聽 聽::xcol:=::fypos/30
聽 聽if aComidas[::xren][::xcol]="x"
聽 聽 聽 聽::fypos := ::fypos +30
聽 聽 聽
聽 聽else
聽 聽 聽 if aComidas[::xren][::xcol]="t"
聽 聽 聽 聽//fypos := fypos +30
聽 聽 聽 聽 聽 聽 聽::fYpos:=840
聽 聽 聽 endif
聽 聽 聽
聽 聽endif
聽 聽
ENDIF
IF ::XFDONDE =3 // derecha
聽 聽::fypos:= ::fypos +30
聽 聽::xren:=::fxpos/30
聽 聽::xcol:=::fypos/30
聽 聽if aComidas[::xren][::xcol]="x"
聽 聽 聽 ::fypos := ::fypos -30
聽 聽else
聽 聽 聽 if aComidas[::xren][::xcol]="f"
聽 聽 聽 聽 // fypos := fypos -30
聽 聽 聽 聽 聽::fYpos:=60
聽 聽 聽 endif
聽 聽endif
聽 聽
ENDIF
RETURN NIL
METHOD Movimiento_ChecaPos() 聽 CLASS TFANTASMON
local xren, xcol
local xnpos :=0
xren:=::fxpos/30
xcol:=::fypos/30
xotra:=0 聽
XPOS:=0
if !acomidas[xren+1][xcol]="x"
聽 聽xpos++
聽 聽xotra:=xotra + 1
endif
if !acomidas[xren-1][xcol]="x"
聽 聽xpos++
聽 聽xotra:= xotra + 2
endif
if !acomidas[xren][xcol-1]="x"
聽 聽xpos++
聽 聽xotra:= xotra + 3
endif
if !acomidas[xren][xcol+1]="x"
聽 聽xpos++
聽 聽xotra:= xotra + 4
endif
if xpos>2 聽 聽// quire decir que ay que random para decidi a que lugar ir we 聽
聽 聽::xfdonde:=nrandom(3)
聽
else
聽 聽if xpos=2
聽 聽 聽 if xotra = 4 聽.or. xotra=6 .OR. XOTRA=5 聽//quire decir que esta en la esquina del 聽muro
聽 聽 聽 聽 聽::xfdonde:=nrandom(3)
聽 聽 聽 聽// ? "ey estoy en 3 son dos opciones ", xotra, xfdonde
聽 聽 聽else
聽 聽 聽 聽 // xfdonde:=nrandom(3)
聽 聽 聽 聽// 聽? " son 1 opciones ", xotra, xfdonde
聽 聽 聽
聽 聽 聽 endif
聽 聽endif
聽 聽
endif
Return NILCd. Obreg贸n, Sonora, M茅xico
chino72vale@hotmail.com
Fivewin 24.04, Harbour 3.3, xharbour 1.2.1, Fivelinux, Visual Estudio 2022
Oracle Api Rest, SDK Contpaq, Facturaci贸n Electr贸nica, XML DIOT 2025
