; Pongr ; Very simple game to get started with PureBasic and the game development. ; 2011 - Ruben Mueller, Aaron Mueller XIncludeFile "structs.pb" XIncludeFile "draw.pb" XIncludeFile "events.pb" ; Global variables fullscreen = 0 title.s = "Pongr - Build " + Str(#PB_Editor_BuildCount) screen.ScreenDimension\width = 800 screen.ScreenDimension\height = 600 NewMap game_states.GameState() game_states("MAIN_MENU")\draw_fun = @draw_main_nenu() game_states("MAIN_MENU")\handle_event_fun = @handle_event_main_menu() current_state.s = "MAIN_MENU" ; Initialize subsystems If InitSprite() = 0 Or InitKeyboard() = 0 MessageRequester("Error", "Sorry, can't boot up.", 0) End EndIf ; Start the main loop which will create the window, wait for events and draw things ; on the screen. To escape from this loop, press ESC or close the window. If OpenWindow(0, 0, 0, screen\width, screen\height, title, #PB_Window_ScreenCentered) If OpenWindowedScreen(WindowID(0), 0, 0, screen\width, screen\height, 0, 0, 0) EndIf Repeat ; Event loop Repeat event = WindowEvent() Until event = 0 ; Handle global events ExamineKeyboard() If KeyboardReleased(#PB_Key_F) CloseScreen() If fullscreen = 0 OpenScreen(800, 600, 32, title) fullscreen = 1 Else OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0) fullscreen = 0 EndIf EndIf ; Handle the events for the current state game_states(current_state)\handle_event_fun() ; Draw the stuff on the screen FlipBuffers() ClearScreen(RGB(0, 0, 0)) If StartDrawing(ScreenOutput()) game_states(current_state)\draw_fun() StopDrawing() EndIf Delay(1) Until KeyboardPushed(#PB_Key_Escape) EndIf ; IDE Options = PureBasic 4.51 (Linux - x64) ; CursorPosition = 57 ; FirstLine = 23 ; EnableXP ; EnableCompileCount = 0 ; EnableBuildCount = 0