Code: Select all
Procedure Init()
If Not InitEngine3D()
Debug "Could not initialise 3D engine"
MessageRequester("Error", "Could not initialize 3D engine",0)
ProcedureReturn 0
EndIf
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
DesktopW = DesktopWidth(0)
DesktopH = DesktopHeight(0)
If Not OpenWindow(0, 0, 0, DesktopW/2, DesktopH/2, "Description", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
Debug "Could not initialise window"
MessageRequester("Error", "Could not initialize window",0)
ProcedureReturn 0
EndIf
If Not OpenWindowedScreen(WindowID(0), 0, 0, DesktopW/2, DesktopH/2, #True, 0, 0, #PB_Screen_SmartSynchronization)
Debug "Could not initialise windowed screen"
MessageRequester("Error", "Could not initialise windowed screen",0)
ProcedureReturn 0
EndIf
ProcedureReturn 1
EndProcedure
Procedure Main()
Quit = 0
Repeat ; main loop
Repeat ; process all events
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Event = 0
If MouseControl ; only check mouse if the player is controlling with it
If ExamineMouse()
; do mouse
EndIf
EndIf
If ExamineKeyboard()
; Do keyboard
EndIf
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndProcedure
If Init()
Main()
EndIf