I was experimenting with openwindow and openwindowedscreen trying to understand the system. I was getting some inconsistent results that I didn't understand so I went back to some previous code to look at what I had done before. It ran different than it had before.
I had opened a 1500 by 1500 window and then opened a 1500 by 1500 screen on it like this:
Code: Select all
InitSprite()
InitKeyboard()
#FLAGS = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#WINDOW_MAIN, 0, 0, ScrW, ScrH, "Windowed Screen", #FLAGS)
OpenWindowedScreen(WindowID(#WINDOW_MAIN), 0, 0, ScrW, ScrH, 0, 0, 0)
I copy and pasted the entire program into a new editor tab an ran it from there. It worked perfectly. What is this and how can it happen? The full code is:
Code: Select all
#WINDOW_MAIN = 1
#IMAGE_MAIN = 1
Global ScrW.l = 1500
Global ScrH.l = 1500
Global ScrD.l = 32
Global Quit.b = #False
Global Dim life.i(1, 100, 100)
Global flag.i = 0
Procedure.i invrt(x.i)
If x > 0
ProcedureReturn 0
Else
ProcedureReturn 1
EndIf
EndProcedure
For x = 0 To 99
For y = 0 To 99
life(flag, x, y) = Random(1,0)
Next y
Next x
InitSprite()
InitKeyboard()
#FLAGS = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#WINDOW_MAIN, 0, 0, ScrW, ScrH, "Windowed Screen", #FLAGS)
OpenWindowedScreen(WindowID(#WINDOW_MAIN), 0, 0, ScrW, ScrH, 0, 0, 0)
If CreateImage(#IMAGE_MAIN, 15, 15)
If StartDrawing(ImageOutput(#IMAGE_MAIN))
Box(0, 0, 15, 15, RGB(0, 0, 0))
StopDrawing()
EndIf
EndIf
SetFrameRate(5)
Repeat
Event.l = WindowEvent()
ClearScreen(RGB(225, 225, 225))
StartDrawing(ScreenOutput())
For x = 0 To 99
For y = 0 To 99
If life(flag, x, y) = 1
DrawImage(ImageID(#IMAGE_MAIN), 15*x, 15*y)
EndIf
Next y
Next x
StopDrawing()
FlipBuffers()
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
Quit = #True
EndIf
For x.i = 0 To 99
For y.i = 0 To 99
total.i = life(flag, ((x+99)%100), (y+99)%100) + life(flag, x, (y+99)%100) + life(flag, (x + 1)%100, (y+99)%100) + life(flag, (x+99)%100, y) + life(flag, (x+1)%100, y) + life(flag, (x+99)%100, (y+1)%100) + life(flag, x, (y+1)%100) + life(flag, (x+1)%100, (y+1)%100)
If total = 3
life(invrt(flag), x, y) = 1
ElseIf total = 2
life(invrt(flag), x, y) = life(flag, x, y)
Else
life(invrt(flag), x, y) = 0
EndIf
Next y
Next x
flag = invrt(flag)
Until Event = #PB_Event_CloseWindow Or Quit = #True