Add game stats and start up form menu structs

This commit is contained in:
Aaron Mueller 2011-01-15 17:45:37 +01:00
parent e01046e2a0
commit 7d1714c88b
5 changed files with 89 additions and 21 deletions

14
pongr/draw.pb Normal file
View file

@ -0,0 +1,14 @@
; Here we drad stuff on screen
Procedure draw_main_nenu()
Box(0, 0, 200, 200, RGB(255, 0 ,0))
EndProcedure
; IDE Options = PureBasic 4.51 (Linux - x64)
; CursorPosition = 5
; Folding = -
; EnableUnicode
; EnableThread
; EnableXP
; EnableCompileCount = 0
; EnableBuildCount = 0

16
pongr/events.pb Normal file
View file

@ -0,0 +1,16 @@
; In this file, we handle alle the events
Procedure handle_event_main_menu()
If KeyboardReleased(#PB_Key_U)
Debug "U pressed"
EndIf
EndProcedure
; IDE Options = PureBasic 4.51 (Linux - x64)
; CursorPosition = 4
; Folding = -
; EnableUnicode
; EnableThread
; EnableXP
; EnableCompileCount = 0
; EnableBuildCount = 0

View file

@ -3,20 +3,20 @@
; 2011 - Ruben Mueller, Aaron Mueller ; 2011 - Ruben Mueller, Aaron Mueller
XIncludeFile "structs.pb" XIncludeFile "structs.pb"
XIncludeFile "draw.pb"
XIncludeFile "events.pb"
; Global variables
fullscreen = 0 fullscreen = 0
title.s = "Pongr - Build " + Str(#PB_Editor_BuildCount) title.s = "Pongr - Build " + Str(#PB_Editor_BuildCount)
screen.ScreenDimension\width = 800 screen.ScreenDimension\width = 800
screen.ScreenDimension\height = 600 screen.ScreenDimension\height = 600
Procedure DrawOnScreen() NewMap game_states.GameState()
CreateSprite(0, 20, 20) game_states("MAIN_MENU")\draw_fun = @draw_main_nenu()
If StartDrawing(SpriteOutput(0)) game_states("MAIN_MENU")\handle_event_fun = @handle_event_main_menu()
Box(0, 0, 20, 20, RGB(255, 0, 155)) current_state.s = "MAIN_MENU"
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
EndProcedure
; Initialize subsystems ; Initialize subsystems
If InitSprite() = 0 Or InitKeyboard() = 0 If InitSprite() = 0 Or InitKeyboard() = 0
@ -24,6 +24,7 @@ If InitSprite() = 0 Or InitKeyboard() = 0
End End
EndIf EndIf
; Start the main loop which will create the window, wait for events and draw things ; 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. ; 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 OpenWindow(0, 0, 0, screen\width, screen\height, title, #PB_Window_ScreenCentered)
@ -36,7 +37,7 @@ If OpenWindow(0, 0, 0, screen\width, screen\height, title, #PB_Window_ScreenCent
event = WindowEvent() event = WindowEvent()
Until event = 0 Until event = 0
; Handle input ; Handle global events
ExamineKeyboard() ExamineKeyboard()
If KeyboardReleased(#PB_Key_F) If KeyboardReleased(#PB_Key_F)
CloseScreen() CloseScreen()
@ -49,17 +50,23 @@ If OpenWindow(0, 0, 0, screen\width, screen\height, title, #PB_Window_ScreenCent
EndIf EndIf
EndIf EndIf
; Handle the events for the current state
game_states(current_state)\handle_event_fun()
; Draw the stuff on the screen ; Draw the stuff on the screen
FlipBuffers() FlipBuffers()
ClearScreen(RGB(0, 200, 0)) ClearScreen(RGB(0, 0, 0))
DrawOnScreen() If StartDrawing(ScreenOutput())
game_states(current_state)\draw_fun()
StopDrawing()
EndIf
Delay(1) Delay(1)
Until KeyboardPushed(#PB_Key_Escape) Until KeyboardPushed(#PB_Key_Escape)
EndIf EndIf
; IDE Options = PureBasic 4.51 (Linux - x64) ; IDE Options = PureBasic 4.51 (Linux - x64)
; CursorPosition = 23 ; CursorPosition = 57
; FirstLine = 12 ; FirstLine = 23
; Folding = -
; EnableXP ; EnableXP
; EnableCompileCount = 0 ; EnableCompileCount = 0
; EnableBuildCount = 0 ; EnableBuildCount = 0

View file

@ -10,12 +10,24 @@
<section name="data"> <section name="data">
<explorer view="../../../" pattern="0"/> <explorer view="../../../" pattern="0"/>
<log show="1"/> <log show="1"/>
<lastopen date="2011-01-13 23:43" user="aaron" host="deskFu"/> <lastopen date="2011-01-15 17:39" user="aaron" host="deskFu"/>
</section> </section>
<section name="files"> <section name="files">
<file name="pong.pb"> <file name="pong.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
<fingerprint md5="2dc43b582138ebdc5da153593cc44acd"/> <fingerprint md5="2d2a96e4447872844b4c2183e257eebc"/>
</file>
<file name="structs.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="85e0553420e8dcaef5cd8c0aa2fd7840"/>
</file>
<file name="draw.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="0e64513b04987abbba636b341997cad8"/>
</file>
<file name="events.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="5a5949b45c8ae14dd9585575b5f78e02"/>
</file> </file>
</section> </section>
<section name="targets"> <section name="targets">
@ -23,9 +35,9 @@
<inputfile value="pong.pb"/> <inputfile value="pong.pb"/>
<outputfile value="build/pongr"/> <outputfile value="build/pongr"/>
<executable value="build/pongr"/> <executable value="build/pongr"/>
<options unicode="1" thread="1" xpskin="1" debug="1"/> <options thread="1" xpskin="1" debug="1"/>
<compilecount enable="1" value="25"/> <compilecount enable="1" value="39"/>
<buildcount enable="1" value="3"/> <buildcount enable="1" value="4"/>
</target> </target>
</section> </section>
</project> </project>

View file

@ -6,10 +6,29 @@ Structure ScreenDimension
height.i height.i
EndStructure EndStructure
Prototype DRAW()
Prototype HANDLE_EVENTS()
Structure GameState
draw_fun.DRAW
handle_event_fun.HANDLE_EVENTS
EndStructure
Structure GameMenuItem
label.s
target_state.GameState
EndStructure
Structure GameMenu
title.s
List entries.GameMenuItem()
EndStructure
; IDE Options = PureBasic 4.51 (Linux - x64) ; IDE Options = PureBasic 4.51 (Linux - x64)
; CursorPosition = 7 ; CursorPosition = 16
; EnableUnicode ; EnableUnicode
; EnableThread ; EnableThread
; EnableXP ; EnableXP
; EnableCompileCount = 0 ; EnableCompileCount = 1
; EnableBuildCount = 0 ; EnableBuildCount = 0