PureOoze
Code: Select all
; ------------------------------------------------------------
;
; PureOoze - Simple Game
;
; (c) PureOoze
;
; ------------------------------------------------------------
; if the sprite subsystem fails to initalize
If InitSprite() = 0
; display an error message
MessageRequester("Error", "Failed to open the sprite system", 0)
;and terminate
End
EndIf
; if the mouse subsystem fails to initalize
If InitMouse() = 0
; display an error message
MessageRequester("Error", "Failed to open the mouse system", 0)
;and terminate
End
EndIf
; if the keyboard subsystem fails to initalize
If InitKeyboard() = 0
; display an error message
MessageRequester("Error", "Failed to open the keyboard system", 0)
;and terminate
End
EndIf
; open the game window
If OpenWindow(0, 0, 0, 320, 200, "PureOoze", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;if the game window was opened, open a screen inside the window for double buffering
If OpenWindowedScreen(WindowID(0), 0, 0, 320, 200, 0, 0, 0) = 0
; the window couldn't be opened so display an error message
MessageRequester("Error", "Failed to open double buffered windowed!", 0)
; and terminate
End
EndIf
Else
; the game window couldn't be opened so display an error message
MessageRequester("Error", "Failed to open game window!", 0)
; and terminate
End
EndIf
; main game loop
Repeat
; event loop
Repeat
; Always process all the events to flush the queue at every frame
Event = WindowEvent()
; determine which event occured
Select Event
; the user closed the window
Case #PB_Event_CloseWindow
; set quit to true
Quit = 1
Case #PB_Event_ActivateWindow
ReleaseMouse(#False)
InputReleased = 0
EndSelect
; Quit the event loop only when no more events are available
Until Event = 0
; if the mouse hasn't been released
If InputReleased = 0
; check for mouse input
ExamineMouse()
; check for keyboard input
ExamineKeyboard()
; if the user pressed F12
If KeyboardPushed(#PB_Key_F12)
; release the mouse
ReleaseMouse(#True)
; and set InputReleased to true
InputReleased = 1
EndIf
EndIf
; Clear the screen and draw
ClearScreen(RGB(192,192,192))
; Inverse the buffers
FlipBuffers()
Until Quit Or KeyboardPushed(#PB_Key_Escape)
; IDE Options = PureBasic 4.51 (Windows - x86)
; EnableXP
; SubSystem = DirectX7