je cherche à faire en sorte que mon vaisseau ne sorte pas de l'écran
j'avais pensé à mettre 2 sprites de à gauche et à droite en redécoupant un morceau du background .
mais c'est peux etre pas la solution
Assets :
https://www.dropbox.com/s/ryk6j62k6amil ... e.zip?dl=0
Code : Tout sélectionner
;--Initialisation
EnableExplicit
UseJPEGImageDecoder()
UsePNGImageDecoder()
InitSprite()
InitKeyboard()
InitMouse()
InitSound()
;--Constantes
Enumeration
#Form_Game
#Spr_Bg
#spr_Ship
EndEnumeration
;--Variables Globale
Global Event_Window,ShipX=350,ShipY=515
;--Création de la fenetre jeux
OpenWindow(#Form_Game,0,0,800,600,"SpaceShoot",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Form_Game),0,0,800,600)
LoadSprite(#Spr_Bg,"Fond.jpg",#PB_Sprite_AlphaBlending)
LoadSprite(#spr_Ship,"Ship1.png",#PB_Sprite_AlphaBlending)
Repeat
Repeat
Event_Window=WindowEvent()
Select Event_Window
Case #PB_Event_CloseWindow
End
EndSelect
Until Event_Window=0
DisplaySprite(#Spr_Bg, 0, 0)
;Affichage du vaisseau
DisplayTransparentSprite(#spr_Ship,ShipX,ShipY)
ExamineKeyboard()
;---Touche pour faire bouger de gauche à droite le vaisseau
If KeyboardPushed(#PB_Key_Left)
ShipX-5
EndIf
If KeyboardPushed(#PB_Key_Right)
ShipX+5
EndIf
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)