Le principe est le suivant
Dessiner un ou plusieurs niveaux (fait)
Placer le Player (fait)
placer les friandises/ fromages (a faire)
placer les fantômes (a faire)
animation du player avec détection de collision (fait partiellement)
Génération du fichier PB (fait partiellement)
actuellement 1600 lgn
donc je met en le code en zip
https://www.mediafire.com/?gcjcsxq2bc8ucob
Exemple du code généré automatiquement
Code : Tout sélectionner
;-Variable Globales
;{
Global Fin_Program.b=#False
Global mainTitle$=""
Global FrameRate=150
Global ElapsetTime
Global CurrentFrame=2
;}
;-Structures
;{
Structure Decor
ID.i
X.i
Y.i
EndStructure
Structure Rectangle
X.i
Y.i
L.i
H.i
Couleur.i
EndStructure
Structure Ligne
X.i
Y.i
L.i
H.i
Couleur.i
EndStructure
Structure Player
X.i
Y.i
R.i
EndStructure
Global NewList mesRectangles.Rectangle()
Global NewList mesLignes.Ligne()
Global NewList decorSprite.Decor()
Global monPlayer.Player
;}
;-Enumérations
;{
Enumeration
#Main_Windows
#Player
EndEnumeration
;-Constantes
;{
#TaillePlayer=30
;}
;-Déclaration procédure
;{
Declare Open_MainWindows()
;}
Declare ChargeScene1()
Declare DessineScene()
Declare Update_Player()
Declare DetecteColision()
Declare Affiche_decor()
;-Initialisation
;{
If InitSprite()=0
MessageRequester("Erreur","Erreur initialisation DirexX...",#PB_MessageRequester_Ok)
End
EndIf
If InitKeyboard()=0
MessageRequester("Erreur","Erreur initialisation DirexX...",#PB_MessageRequester_Ok)
End
EndIf
Open_MainWindows()
;}
ChargeScene1()
DessineScene()
UsePNGImageDecoder()
CatchSprite(#Player,?PLAYER_IMG,#PB_Sprite_AlphaBlending)
;-Boucle Principale;{
Repeat
ExamineKeyboard()
Event=WindowEvent()
FlipBuffers()
ClearScreen(RGB(0,0,0))
Affiche_decor()
Update_Player()
If KeyboardPushed(#PB_Key_Pad8)<>0
monPlayer\R=270
EndIf
If KeyboardPushed(#PB_Key_Pad6)<>0
monPlayer\R=360
EndIf
If KeyboardPushed(#PB_Key_Pad4)<>0
monPlayer\R=180
EndIf
If KeyboardPushed(#PB_Key_Pad2)<>0
monPlayer\R=90
EndIf
If KeyboardPushed(#PB_Key_Escape)<>0
Fin_Program=#True
EndIf
If Event=#PB_Event_CloseWindow:Fin_Program=#True : EndIf
Until Fin_Program=#True
;}
;-Procédures
;{
Procedure Open_MainWindows()
OpenWindow(#Main_Windows,0,0,800,600,mainTitle$,#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(#Main_Windows),0,0,800,600)
EndProcedure
Procedure ChargeScene1()
Restore Scene1_LGN:
Read.i Scene1_LGN:
While Scene1_LGN <>-1
AddElement(mesLignes())
mesLignes()\X=Scene1_LGN:
Read.i Scene1_LGN:
mesLignes()\Y=Scene1_LGN:
Read.i Scene1_LGN:
mesLignes()\L=Scene1_LGN:
Read.i Scene1_LGN:
mesLignes()\H=Scene1_LGN:
Read.i Scene1_LGN:
mesLignes()\Couleur=Scene1_LGN:
Read.i Scene1_LGN:
Wend
Restore Scene1_PLAYER:
Read.i Scene1_PLAYER:
monPlayer\X=Scene1_PLAYER
Read.i Scene1_PLAYER:
monPlayer\Y=Scene1_PLAYER
monPlayer\R=360
EndProcedure
Procedure DessineScene()
ClearList(DecorSprite())
ForEach mesRectangles()
AddElement(DecorSprite())
DecorSprite()\ID=CreateSprite(#PB_Any,mesRectangles()\L,mesRectangles()\H,#PB_Sprite_PixelCollision)
DecorSprite()\X=mesRectangles()\X
DecorSprite()\Y=mesRectangles()\Y
StartDrawing(SpriteOutput(DecorSprite()\ID))
Box(0,0,mesRectangles()\L,mesRectangles()\H,mesRectangles()\Couleur)
StopDrawing()
Next
ForEach mesLignes()
AddElement(DecorSprite())
DecorSprite()\ID=CreateSprite(#PB_Any,mesLignes()\L,mesLignes()\H,#PB_Sprite_PixelCollision)
DecorSprite()\X=mesLignes()\X
DecorSprite()\Y=mesLignes()\Y
StartDrawing(SpriteOutput(DecorSprite()\ID))
Line(0,0,mesLignes()\L,mesLignes()\H,mesLignes()\Couleur)
StopDrawing()
Next
EndProcedure
;}
Procedure Affiche_decor()
ForEach DecorSprite()
DisplaySprite(DecorSprite()\ID,DecorSprite()\X,DecorSprite()\Y)
Next
EndProcedure
Procedure Update_Player()
ValDep=1
Debug monPlayer\R
If DetecteColision()=#True Or monPlayer\X<=0 Or monPlayer\Y<=0
ValDep=10
Select monPlayer\R
Case 360
monPlayer\R=180
Case 180
monPlayer\R=360
Case 90
monPlayer\R=270
Case 270
monPlayer\R=90
EndSelect
EndIf
If monPlayer\R>360
EndIf
RotateSprite(#Player,monPlayer\R,#PB_Absolute)
If ElapsedMilliseconds()-ElapsetTime>FrameRate
ElapsetTime=ElapsedMilliseconds()
If CurrentFrame=2
CurrentFrame=1
ClipSprite(#Player,0,0,100,100)
ZoomSprite(#Player,20,20)
Else
CurrentFrame=2
ClipSprite(#Player,100,0,100,100)
ZoomSprite(#Player,20,20)
EndIf
EndIf
Select monPlayer\R
Case 360
monPlayer\X+ValDep
Case 270
monPlayer\Y-ValDep
Case 180
monPlayer\X-ValDep
Case 90
monPlayer\Y+ValDep
EndSelect
DisplayTransparentSprite(#Player,monPlayer\X,monPlayer\Y,255)
EndProcedure
Procedure DetecteColision()
ForEach decorSprite()
If SpriteCollision(#Player,monPlayer\X,monPlayer\Y,decorSprite()\ID,decorSprite()\X,decorSprite()\Y)
ProcedureReturn #True
EndIf
Next
ProcedureReturn #False
EndProcedure
;-Data
;{
DataSection
Scene1_LGN:
Data.i 20,20,760,1,16711680
Data.i 780,20,1,560,16711680
Data.i 20,580,760,1,16711680
Data.i 20,20,1,240,16711680
Data.i 20,260,240,1,16711680
Data.i 20,300,240,1,16711680
Data.i 20,300,1,280,16711680
Data.i 260,300,1,160,16711680
Data.i 40,320,1,240,16711680
Data.i 40,560,720,1,16711680
Data.i 760,340,1,220,16711680
Data.i 560,340,200,1,16711680
Data.i 560,340,1,100,16711680
Data.i 560,440,140,1,16711680
Data.i 700,440,1,20,16711680
Data.i 540,460,160,1,16711680
Data.i 540,320,1,140,16711680
Data.i 540,320,220,1,16711680
Data.i 760,160,1,160,16711680
Data.i 40,320,200,1,16711680
Data.i 100,460,160,1,16711680
Data.i 100,380,1,80,16711680
Data.i 100,380,20,1,16711680
Data.i 120,380,1,60,16711680
Data.i 120,440,120,1,16711680
Data.i 240,320,1,120,16711680
Data.i 760,160,1,20,16711680
Data.i 500,160,260,1,16711680
Data.i 500,120,1,40,16711680
Data.i 260,120,240,1,16711680
Data.i 260,220,1,40,16711680
Data.i 240,220,1,20,16711680
Data.i 40,240,200,1,16711680
Data.i 40,40,1,200,16711680
Data.i 40,40,720,1,16711680
Data.i 760,40,1,100,16711680
Data.i 520,140,240,1,16711680
Data.i 520,100,1,40,16711680
Data.i 240,100,280,1,16711680
Data.i 260,120,1,40,16711680
Data.i 240,100,1,60,16711680
Data.i 240,160,20,1,16711680
Data.i 240,220,20,1,16711680
Data.i 780,20,1,560,16711680
Data.i 760,40,1,520,16711680
Data.i 20,580,760,1,16711680
Data.i 40,560,720,1,16711680
Data.i 40,560,20,1,16711680
Data.i 40,560,720,1,16711680
Data.i 40,560,20,1,16711680
Data.i -1
Scene1_PLAYER:
Data.i 45,269
PLAYER_IMG:
IncludeBinary "Img\Pacman.png"
EndDataSection
;}