j'ai repris un tuto de Crystal Noir:
http://www.purebasic.fr/french/viewtopic.php?t=882
j'ai simplement mis dans une fenêtre écran et j'ai dessiné les étoiles :
Code : Tout sélectionner
;**** Scrolling dans une fenetre jeux ****
;---Initilisation
EnableExplicit
If InitSprite()=0 Or InitKeyboard()=0
MessageRequester("Erreur", "Impossible d'initialiser le programme ")
End
EndIf
;---Constantes
Enumeration Windows
#Main_Form
EndEnumeration
Enumeration Sprites
#Star0
#Star1
EndEnumeration
;--- Structure star1
Structure Etoile
PosX.f
PosY.f
Vitesse.f
EndStructure
Global NewList Stars.Etoile()
;---Structure Star2
Structure Etoile2
PosX.f
PosY.f
Vitesse.f
EndStructure
Global NewList Stars2.Etoile2()
Global i ,gEvent,gW=800,gH=600
;--- Création de l'écran
;OpenScreen(800,600,32,"Test")
OpenWindow(#Main_Form,0,0,gW,gH,"Space Shooters ",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Main_Form),0,0,gW,gH)
SetFrameRate(60)
;---Création de l'etoile 1 blanche
CreateSprite(#Star0,2,2)
StartDrawing(SpriteOutput(#Star0))
Box(0, 0, 2, 2, $FFFFFF)
StopDrawing()
;---Création de l'etoile 2 Grise
CreateSprite(#Star1,2,2)
StartDrawing(SpriteOutput(#Star1))
Box(0, 0, 2, 2, $A9A9A9)
StopDrawing()
;---Procedure pour afficher les étoiles
Procedure DisplayEtoile()
;---Etoile 1
ResetList(Stars())
While NextElement(Stars())
If Stars()\PosY > 600
Stars()\PosY = -5
EndIf
DisplaySprite(#Star0,Stars()\PosX,Stars()\PosY)
Stars()\PosY + Stars()\Vitesse
Wend
;---Etoile2
ResetList(Stars2())
While NextElement(Stars2())
If Stars2()\PosY > 600
Stars2()\PosY = -5
EndIf
DisplaySprite(#Star1,Stars2()\PosX,Stars2()\PosY)
Stars2()\PosY + Stars2()\Vitesse
Wend
EndProcedure
Procedure toto()
For i = 1 To 150
AddElement(Stars())
AddElement(Stars2())
Stars()\PosX = Random(800)
Stars()\PosY = Random(600)
Stars()\Vitesse = 2
;---
Stars2()\PosX = Random(800)
Stars2()\PosY = Random(600)
Stars2()\Vitesse = 1
Next
EndProcedure
toto()
Repeat
Repeat
gEvent=WindowEvent()
Select gEvent
Case #PB_Event_CloseWindow
End
EndSelect
Until gEvent=0
ClearScreen(RGB(0,0,0))
DisplayEtoile()
ExamineKeyboard()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)