Je fais un mini jeu pour un petit contest d'halloween
Je suis embêté par une historie de KeyboardReleased
Lorsque je tire, un rayon sort des yeux de ma citrouille... Mais ce dernier ne disparait pas quand je relache "espace"..
J'ai essayé via ellapsemillisecond de modifier le statu shoot = 1 en shoot = 0 mais rien ni fait.
Je suis sûr que c'est une connerie débile mais je ne la vois pas.
Vu que c'est pour le 31 j'aimerai que vous jetiez un oeil pour voir si vous choppez le problème.
Merci
Lien de l'archive : http://share.ldvmultimedia.com/DBF_HALLOWEEN_ARS.7z
Code : Tout sélectionner
; Ghost N Pumpkin
; Code / Gfx / Zik By Ar-S
; For DBF Halloween contest 2018
InitSound()
Enumeration 10
#ZR
#ZL
#PR
#PL
#LAZR
#LAZL
; BackGround
#BG
; Zik
#ZIK
#eua
EndEnumeration
Global shoot.b
Structure SP
ID.i
x.i
y.i
s.b
dir.b
v.b ; velocité
EndStructure
; INTITIALISATION
Shoot = #False
P.SP
P\ID = #PR
P\X = 950
P\Y = 850
Jump = #True
LAZ.SP
LAZ\ID = #LAZR
LAZ\X = P\X -17
LAZ\Y = P\Y - 17
Global Dim Z.SP(9)
InitSprite()
InitKeyboard()
InitMouse()
UsePNGImageDecoder()
UseJPEGImageDecoder()
UseOGGSoundDecoder()
; Procedure fill(Array Z.SP(1), 9)
Procedure InitGhost()
For i = 0 To 9
Z.SP(i)\Dir = Random(1,0)
Z.SP(i)\Y = Random(910,0)
If Z.SP(i)\Dir = 0
Z.SP(i)\ID = #ZR
Z.SP(i)\X = -180
Z.SP(i)\s = Random (5,1)
Else
Z.SP(i)\ID = #ZL
Z.SP(i)\X = 1860
Z.SP(i)\s = Random (5,1)
EndIf
Next i
EndProcedure
Procedure DisplayGhost()
For i = 0 To 9
If Z.SP(i)\Dir = 0
Z.SP(i)\X + Z.SP(i)\S
If Z.SP(i)\X > 1920 + 170
Z.SP(i)\X = - Random (300,170)
EndIf
Else
Z.SP(i)\X - Z.SP(i)\S
If Z.SP(i)\X < -170
Z.SP(i)\X = Random (2060,1920)
EndIf
EndIf
DisplayTransparentSprite(Z.SP(i)\ID, Z.SP(i)\X, Z.SP(i)\Y, Random(180,140) )
Next
EndProcedure
Macro UpdateLAZ()
If LAZ\ID = #LAZR
LAZ\X = P\X -17
LAZ\Y = P\Y -4
Else
LAZ\X = P\X -12
LAZ\Y = P\Y - 4
EndIf
EndMacro
InitGhost()
OpenWindow(0, 0, 0, 1920, 1080, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 1920, 1080)
; Music & sound
LoadSound(#Zik, "HALLOWEEN_SONG2018.ogg")
LoadSound(#eua, "eua.ogg")
; BackGround
LoadImage(#bg,"Assets/bg.jpg")
;Sprites
LoadSprite(#ZR, "Assets/zl.png", #PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
LoadSprite(#ZL, "Assets/zl.png", #PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
LoadSprite(#PL, "Assets/spg.png", #PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
LoadSprite(#PR, "Assets/spr.png", #PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
LoadSprite(#LAZR, "Assets/lazr.png", #PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
LoadSprite(#LAZL, "Assets/lazl.png", #PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
ClipSprite(#ZL,0,0,170,170)
ClipSprite(#ZR,170,0,170,170)
PlaySound(#zik, #PB_Sound_Loop, 40)
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event=0
ClearScreen(0)
ExamineKeyboard()
; Position Laser
UpdateLAZ()
; MOUVEMENTS CITROUILLE
If KeyboardPushed(#PB_Key_Left)
P\ID = #PL
LAZ\ID = #LAZL
P\X - 4
ElseIf KeyboardPushed(#PB_Key_Right)
P\ID = #PR
LAZ\ID = #LAZR
P\X + 4
ElseIf KeyboardPushed(#PB_Key_Up)
P\v = -4
P\Y+P\V
ElseIf KeyboardPushed(#PB_Key_Down)
P\v = 4
P\Y+P\V
ElseIf KeyboardReleased(#PB_Key_Space)
If shoot = #True
shoot = #False
Else
shoot=#True
EndIf
Debug "EtatShoot" + shoot
EndIf
; BG
StartDrawing(ScreenOutput())
DrawImage(ImageID(#bg),0,0)
StopDrawing()
; Affichage des sprites
DisplayTransparentSprite(P\ID, P\X, P\Y ,255)
DisplayGhost()
If shoot = #True
DisplayTransparentSprite(LAZ\ID, LAZ\X, LAZ\Y ,255)
For i = 0 To 9
coliL = SpriteCollision(LAZ\ID, LAZ\X, LAZ\Y, Z.SP(i)\ID, Z.SP(i)\X, Z.SP(i)\Y)
If coliL <> 0
PlaySound(#eua, #PB_Sound_MultiChannel, 40)
If Z.SP(i)\ID = #ZR
Z.SP(i)\X = -180
Z.SP(i)\s = Random (3,1)
Else
Z.SP(i)\ID = #ZL
Z.SP(i)\X = 1860
Z.SP(i)\s = Random (3,1)
EndIf
Score + 1
Debug "score : "+ score
EndIf
Next i
; shoot = #False
EndIf
For g = 0 To 9
coli = SpriteCollision(P\ID, P\X, P\Y, Z.SP(g)\ID, Z.SP(g)\X, Z.SP(g)\Y)
If coli <> 0
If Z.SP(g)\ID = #ZR
Z.SP(g)\X = -180
Z.SP(g)\s = Random (3,1)
Else
Z.SP(g)\ID = #ZL
Z.SP(g)\X = 1860
Z.SP(g)\s = Random (3,1)
EndIf
Score - 1
Debug "boom"
Debug "score : "+ score
EndIf
Next g
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)