Le concept je l'ai copier d'un mini-jeux du jeux Fable: The Lost Chapters.
Sa m'a pris 30min pour créer se petit simpatique mais gonflant

Code : Tout sélectionner
InitSprite()
InitKeyboard()
InitSound()
Enumeration
#window
#move
#win
#lose
#up
#down
#player
EndEnumeration
Dim map(5,5)
Global playerx
Global playery
Global nmap
playerx=1
playery=5
Procedure nextmap()
;PlaySound(#win)
nmap=nmap+1
Debug nmap
Select nmap
Case 1
Restore map1
Case 2
Restore map2
Case 3
Restore map3
Case 4
Restore map4
Case 5
Restore map5
Case 6
;PlaySound(#lose)
MessageRequester("Terminée","Désoler c la fin de cette petite demonstration de mon nouveau jeu trés basique")
End
EndSelect
For i=1 To 5
For k=1 To 5
Read a
If a=1
DisplayTransparentSprite(#up,128*(k-1),128*(i-1))
Else
DisplayTransparentSprite(#down,128*(k-1),128*(i-1))
EndIf
map(i,k)=a
Next
Next
playerx=1
playery=5
EndProcedure
Procedure verif()
If map(playery,playerx)=1
map(playery,playerx)=0
Else
map(playery,playerx)=1
EndIf
test=0
For i=1 To 5
For k=1 To 5
a=map(i,k)
test = test+a
Next
Next
If test=25
nextmap()
Debug "Next map"
EndIf
If test=0
;tryagain()
Debug "tryagain"
EndIf
EndProcedure
OpenWindow(#window,100,100,640,640,#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget,"Le Puzz 0.1 Grosse Beta Par CameleonTH")
OpenWindowedScreen(WindowID(#window),0,0,640,640,1,1,1)
;LoadSound(#move,"sounds\explode.wav")
;LoadSound(#win,"sounds\applause.wav")
;LoadSound(#lose,"sounds\laugh.wav")
CreateSprite(#up,128,128)
CreateSprite(#down,128,128)
CreateSprite(#player,128,128)
StartDrawing(SpriteOutput(#up))
Box(0,0,218,218,RGB(0,255,0))
Circle(64,64,64,RGB(255,0,0))
StopDrawing()
StartDrawing(SpriteOutput(#down))
Box(0,0,218,218,RGB(0,255,0))
Circle(64,64,64,RGB(0,0,255))
StopDrawing()
StartDrawing(SpriteOutput(#player))
Box(0,0,218,218,RGB(0,255,0))
Circle(64,64,32,RGB(255,255,0))
StopDrawing()
TransparentSpriteColor(#up,0,255,0)
TransparentSpriteColor(#down,0,255,0)
TransparentSpriteColor(#player,0,255,0)
nextmap()
DisplayTransparentSprite(#player,128*playerx,128*playery)
Repeat
event=WindowEvent()
Select event
Case #PB_Event_CloseWindow
quit=1
EndSelect
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
quit=1
EndIf
If KeyboardReleased(#PB_Key_Up)
If playery>1
playery = playery-1
;PlaySound(#move)
verif()
EndIf
EndIf
If KeyboardReleased(#PB_Key_Down)
If playery<5
playery = playery+1
;PlaySound(#move)
verif()
EndIf
EndIf
If KeyboardReleased(#PB_Key_Left)
If playerx>1
playerx = playerx-1
;PlaySound(#move)
verif()
EndIf
EndIf
If KeyboardReleased(#PB_Key_Right)
If playerx<5
playerx = playerx+1
;PlaySound(#move)
verif()
EndIf
EndIf
For i=1 To 5
For k=1 To 5
a=map(i,k)
If a=1
DisplayTransparentSprite(#up,128*(k-1),128*(i-1))
Else
DisplayTransparentSprite(#down,128*(k-1),128*(i-1))
EndIf
Next
Next
DisplayTransparentSprite(#player,128*(playerx-1),128*(playery-1))
FlipBuffers()
ClearScreen(0,0,0)
Until quit=1
;-----------------------------
;--------- Map Data ----------
;-----------------------------
DataSection
map1:
Data.l 1,1,1,1,1
Data.l 1,1,1,1,0
Data.l 1,1,1,0,0
Data.l 1,0,0,0,0
Data.l 0,0,0,0,0
map2:
Data.l 0,0,0,1,1
Data.l 1,1,1,0,1
Data.l 1,1,1,0,1
Data.l 1,0,0,0,1
Data.l 0,1,0,1,1
map3:
Data.l 1,0,1,1,1
Data.l 1,0,0,1,0
Data.l 1,1,0,0,0
Data.l 1,1,1,0,0
Data.l 0,0,0,0,0
map4:
Data.l 0,0,0,0,0
Data.l 1,1,1,1,1
Data.l 0,0,0,0,0
Data.l 1,1,1,1,1
Data.l 0,0,0,0,0
map5:
Data.l 1,0,1,0,1
Data.l 0,1,0,1,0
Data.l 1,0,1,0,1
Data.l 0,1,0,1,0
Data.l 1,0,1,0,1
EndDataSection