voici un code banal pour faire des cercles concentriques :
Code : Tout sélectionner
;
; ------------------------------------------------------------
;
; PureBasic - Windowed Screen example file
;
; (c) Fantaisie Software
;
; ------------------------------------------------------------
;
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester("Error", "Can't open the sprite system", 0)
End
EndIf
If OpenWindow(0, 0, 0, 600, 600, "Cercle",#PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 10, 10, 580, 580, 0, 0, 0)
TempsDepart.q = ElapsedMilliseconds() ; Récupère la valeur actuelle
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Outlined)
For r= 10 To 260 Step 10
Circle(290,290,r)
Next
StopDrawing()
FlipBuffers() ; Inverse the buffers (the back become the front (visible)... and we can do the rendering on the back
TempsEcoule.q = ElapsedMilliseconds()-TempsDepart
MessageRequester("timer",Str(TempsEcoule))
Repeat
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
EndIf
EndIf
Mais, sauriez vous faire la meme chose sans l'innstruction "circle" ?
Mon code :
Code : Tout sélectionner
;
;
; ------------------------------------------------------------
;
; PureBasic - Windowed Screen example file
;
; (c) Fantaisie Software
;
; ------------------------------------------------------------
;
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester("Error", "Can't open the sprite system", 0)
End
EndIf
If OpenWindow(0, 0, 0, 600, 600, "Cercle",#PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 10, 10, 580, 580, 0, 0, 0)
TempsDepart.q = ElapsedMilliseconds() ; Récupère la valeur actuelle
StartDrawing(ScreenOutput())
For r= 10 To 260 Step 10
;r=260
rr.f=2*r*3.14159535
;z.f=360*8/rr
z.f=360/rr
u.f=0
ok=0
Repeat
u+z
If u>=360
ok=1
EndIf
x.f=Cos(Radian(u))*r
y.f=Sin(Radian(u))*r
;LineXY(290+x,290+y,290+x2,290+y2,RGB(88,88,88))
Plot(290+x,290+y,RGB(255,0,0))
Until ok=1
Next
StopDrawing()
FlipBuffers() ; Inverse the buffers (the back become the front (visible)... and we can do the rendering on the back
TempsEcoule.q = ElapsedMilliseconds()-TempsDepart
MessageRequester("timer",Str(TempsEcoule))
Repeat
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
EndIf
EndIf