Pseudo-code:
Code: Select all
OpenWindow
For x = 1 To 100
StartDrawing
plot x-1 , x-1 , black
plot x , x , white
StopDrawing
Repeat: Until WindowEvent() = 0 ;or #PB_Event_CloseWindow
wait 1 ; wait 1 second for each plot
Next x
The result of all drawing within a single StartDrawing()/EndDrawing() is only committed to the output when the EndDrawing() is reached. The window is redrawn in the event loop. If you don't read the window events in-between the plots you will only seen the end result in a quick series (faster than can be seen) when you finally do retrieve all the events.
Actual code:
Code: Select all
OpenWindow (0, 0, 0, 101, 101, "Draw Test", #PB_Window_SystemMenu)
For x = 1 To 100
StartDrawing(WindowOutput(0))
Plot( x-1 , x-1 , #Black)
Plot( x , x , #White)
StopDrawing ()
Repeat
event = WindowEvent()
If event = #PB_Event_CloseWindow
Break 2
EndIf
Until event = 0
Delay(1000) ; wait 1 second for each plot
Next
Repeat:event = WaitWindowEvent(10): Until event = #PB_Event_CloseWindow
And one more code sample just for fun demonstrating the use of a window timer instead of a For/Next loop:
Code: Select all
OpenWindow (0, 0, 0, 101, 101, "Draw Test with timer", #PB_Window_SystemMenu)
AddWindowTimer(0, 1, 10) ;1/100 second, so we don't fall asleep ;)
Repeat
Repeat
event = WindowEvent()
Select event
Case #PB_Event_CloseWindow
quit = #True
event = 0
Case #PB_Event_Timer
If EventTimer() = 1
StartDrawing(WindowOutput(0))
Plot( x-1, x-1, c)
Plot( x, x, RGB(255, 255, 255))
StopDrawing()
x + 1
If x > 100
x = 0
c = RGB(Random(255), Random(255), Random(255))
EndIf
EndIf
EndSelect
Until event = 0
Until quit