Ca parait tout con, comme ça, mais essayez de faire ça en un minimum de temps.
Si ça me prends, peut-être que je lui ferait un petit compte à rebours.
Code : Tout sélectionner
UsePNGImageDecoder()
#Window = 0
#Width = 600
#Height = 600
#Souris = 100
Structure Sprites
sprite.w
x.l
y.l
Vx.l
Vy.l
Color.l
EndStructure
NewList Spr.Sprites()
NbSprites = 10
Global flag, hwnd
Font1 = LoadFont(#PB_Any,"Comic Sans MS",52)
Procedure TimerProc(hnd.l, uMsg.l, idEvent.l, dwTime.l)
Select uMsg
Case #WM_TIMER
Select idEvent
Case 1
If flag = 1
flag = 0
EndIf
EndSelect
EndSelect
EndProcedure
;- Initialisation de DirectX
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Erreur", "Impossible d'initialiser DirectX", 0)
CloseWindow(#Window) : End
EndIf
InitMouse()
;- Ouverture de la fenêtre et de l'écran
hwnd = OpenWindow(#Window, 0, 0, #Width, #Height, #PB_Window_TitleBar | #PB_Window_ScreenCentered, "")
OpenWindowedScreen(hwnd, 0, 0, #Width, #Height, 0, 0, 0)
If CreateSprite(#Souris,40,40,0)
StartDrawing(SpriteOutput(#Souris)) : DrawingMode(4)
LineXY(5,20,35,20,RGB($FF,$FF,$80))
LineXY(20,0,20,40,RGB($FF,$FF,$80))
Circle(20,20,10,RGB($FF,$FF,$80))
Circle(20,20,20,RGB($80,$FF,$FF))
StopDrawing()
EndIf
*Addr = LoadSprite(0,"boule.png",#PB_Sprite_Texture)
For i = 0 To NbSprites
AddElement(Spr())
Spr()\sprite = i
Spr()\x = Random(#Width-20)
Spr()\y = Random(#Height-20)
Spr()\Vx = Random(4)+2
Spr()\Vy = Random(4)+2
Next
ExamineMouse()
x = MouseX()-10
y = MouseY()-10
flag = 1
Timer = SetTimer_(hwnd,1,100,@TimerProc())
;- début de la boucle
Repeat
Select WindowEvent()
Case #WM_LBUTTONDOWN
flag = 1
Case #WM_LBUTTONUP
flag = 0
EndSelect
ClearScreen(0, 0, 64) : ExamineKeyboard()
ExamineMouse()
x = MouseX()-10
y = MouseY()-10
ForEach Spr()
If Spr()\x <=0 Or Spr()\x + SpriteWidth(0) >= #Width : Spr()\Vx = -Spr()\Vx : EndIf
If Spr()\y <=0 Or Spr()\y + SpriteHeight(0)>= #Height : Spr()\Vy = -Spr()\Vy : EndIf
Spr()\x + Spr()\Vx : Spr()\y + Spr()\Vy
DisplayTransparentSprite(0,Spr()\x,Spr()\y)
If Spr()\x >= x And Spr()\x <= x+20 And Spr()\y >= y And Spr()\y <= y+20 And MouseButton(1) And flag = 0
SelectElement(Spr(),ListIndex(Spr()))
DeleteElement(Spr())
EndIf
Next
If CountList(Spr()) = 0
StartDrawing(ScreenOutput())
DrawingFont(UseFont(Font1))
DrawingMode(1)
FrontColor($C0,$C0,$C0) : Locate(37,147)
DrawText("Vous avez gagné")
FrontColor($80,$FF,$FF) : Locate(40,150)
DrawText("Vous avez gagné")
StopDrawing()
EndIf
DisplayTransparentSprite(#Souris,x,y)
FlipBuffers()
Delay(1)
If KeyboardPushed(#PB_Key_Escape) : quit = 1 : EndIf
Until quit = 1
