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
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
Procedure DrawOnScreen()
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
EndProcedure
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
@ -24,6 +24,7 @@ If InitSprite() = 0 Or InitKeyboard() = 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)
@ -36,7 +37,7 @@ If OpenWindow(0, 0, 0, screen\width, screen\height, title, #PB_Window_ScreenCent
event = WindowEvent()
Until event = 0
; Handle input
; Handle global events
ExamineKeyboard()
If KeyboardReleased(#PB_Key_F)
CloseScreen()
@ -49,17 +50,23 @@ If OpenWindow(0, 0, 0, screen\width, screen\height, title, #PB_Window_ScreenCent
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, 200, 0))
DrawOnScreen()
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 = 23
; FirstLine = 12
; Folding = -
; CursorPosition = 57
; FirstLine = 23
; EnableXP
; EnableCompileCount = 0
; EnableBuildCount = 0

View File

@ -10,12 +10,24 @@
<section name="data">
<explorer view="../../../" pattern="0"/>
<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 name="files">
<file name="pong.pb">
<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>
</section>
<section name="targets">
@ -23,9 +35,9 @@
<inputfile value="pong.pb"/>
<outputfile value="build/pongr"/>
<executable value="build/pongr"/>
<options unicode="1" thread="1" xpskin="1" debug="1"/>
<compilecount enable="1" value="25"/>
<buildcount enable="1" value="3"/>
<options thread="1" xpskin="1" debug="1"/>
<compilecount enable="1" value="39"/>
<buildcount enable="1" value="4"/>
</target>
</section>
</project>

View File

@ -6,10 +6,29 @@ Structure ScreenDimension
height.i
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)
; CursorPosition = 7
; CursorPosition = 16
; EnableUnicode
; EnableThread
; EnableXP
; EnableCompileCount = 0
; EnableCompileCount = 1
; EnableBuildCount = 0