Some mayor changes
This commit is contained in:
parent
30a48990e2
commit
2dba5ef64c
8 changed files with 134 additions and 102 deletions
|
@ -1,8 +0,0 @@
|
|||
MAIN_MENU {ESCape}
|
||||
BUTTON: {Escape now!} -> RUNNING_GAME
|
||||
BUTTON: {End game} -> RLY_QUIT
|
||||
|
||||
RLY_QUIT {You want to leave?}
|
||||
BUTTON: {Yes} -> EXIT
|
||||
BUTTON: {No} -> MAIN_MENU
|
||||
|
45
escape.pbp
45
escape.pbp
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 4.51 (MacOS X - x86)">
|
||||
<project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 4.51 (Windows - x86)">
|
||||
<section name="config">
|
||||
<options closefiles="1" openmode="0" name="ESCape"/>
|
||||
<comment>
|
||||
|
@ -8,42 +8,43 @@
|
|||
</comment>
|
||||
</section>
|
||||
<section name="data">
|
||||
<explorer view="../../../" pattern="0"/>
|
||||
<explorer view="..\..\..\" pattern="0"/>
|
||||
<log show="1"/>
|
||||
<lastopen date="2011-08-20 15:09" user="rubenmueller" host="localhost"/>
|
||||
<lastopen date="2011-08-20 17:42" user="Aaron" host="BERE-PC"/>
|
||||
</section>
|
||||
<section name="files">
|
||||
<file name="src/Main.pb">
|
||||
<file name="src\Main.pb">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
|
||||
<fingerprint md5="a038877b83fffe1dca24f4aecfae8d91"/>
|
||||
<fingerprint md5="ad2f5bd509147b23b258161ffa14e0eb"/>
|
||||
</file>
|
||||
<file name="src/Draw.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="d6d3ec279f01ec471b40d898bdd3bfea"/>
|
||||
<file name="src\Draw.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
|
||||
<fingerprint md5="a7844b55258bdd4a58b2d55e9593ebb0"/>
|
||||
</file>
|
||||
<file name="src/Events.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="0b1b012875300d8e87bdd60b48eff043"/>
|
||||
<file name="src\Events.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
|
||||
<fingerprint md5="9dd8da8cf277ac254b39db24257c65b5"/>
|
||||
</file>
|
||||
<file name="src/Functions.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="ca68ea8da1167d8ec714cca0cc2c3c7e"/>
|
||||
<file name="src\Functions.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
|
||||
<fingerprint md5="6a4e4dc75d9d6ab704b82092ed861d05"/>
|
||||
</file>
|
||||
<file name="src/Globals.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="3f1597a2d80a28427556491483d43bef"/>
|
||||
<file name="src\Globals.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
|
||||
<fingerprint md5="b7c0f56d905c931b4cab5569d2864c85"/>
|
||||
</file>
|
||||
<file name="src/Structs.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="f1ad13f0d40ae11665f9bfbf6b359b22"/>
|
||||
<file name="src\Structs.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
|
||||
<fingerprint md5="4cec4e716776207d73222c7134793c75"/>
|
||||
</file>
|
||||
</section>
|
||||
<section name="targets">
|
||||
<target name="Default Target" enabled="1" default="1">
|
||||
<inputfile value="src/Main.pb"/>
|
||||
<outputfile value="bin/escape.app"/>
|
||||
<outputfile value="bin/escape.exe"/>
|
||||
<executable value="bin\escape.exe"/>
|
||||
<options xpskin="1" debug="1"/>
|
||||
<buildcount enable="1" value="0"/>
|
||||
<buildcount enable="1" value="1"/>
|
||||
</target>
|
||||
</section>
|
||||
</project>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
; In this file, we handle alle the events
|
||||
|
||||
Procedure HandleEventMenu()
|
||||
Define ActiveMenu_Index.i = ListIndex(*ActiveMenu\Entries())
|
||||
|
||||
If KeyboardReleased(#PB_Key_Up)
|
||||
Menu_GotoCurrent()
|
||||
*ActiveMenu\Entries()\Selected = #False
|
||||
|
@ -29,10 +27,16 @@ Procedure HandleEventMenu()
|
|||
*ActiveMenu\Entries()\Selected = #True
|
||||
EndIf
|
||||
|
||||
; We go to the target game state
|
||||
If KeyboardReleased(#PB_Key_Return)
|
||||
Debug "Return!"
|
||||
Menu_GotoCurrent()
|
||||
CurrentState.s = *ActiveMenu\Entries()\TargetState
|
||||
*ActiveMenu.GameMenu = Menus(CurrentState)
|
||||
EndIf
|
||||
|
||||
;KeyboardPushed(#PB_Key_Escape) Or
|
||||
EndProcedure
|
||||
|
||||
Procedure HandleEventRunningGame()
|
||||
Debug "Game starts!!!"
|
||||
EndProcedure
|
|
@ -1 +1,31 @@
|
|||
; This file holds all the functions If it gets too big,
; we can split it in categories
; *****************************************************************************
; * Tileset
Procedure InitTileset()
CatchSprite(#Tile01, ?Gfx_Tileset)
;ClipSprite(0, 0, 0, 16, 16)
; test the sprite
;DisplaySprite(0, 20, 20)
EndProcedure
; *****************************************************************************
; *****************************************************************************
; * Menu
Procedure Menu_GotoCurrent()
If *ActiveMenu\Entries()\Selected <> #True
FirstElement(*ActiveMenu\Entries());
ForEach *ActiveMenu\Entries()
If *ActiveMenu\Entries()\Selected = #True
Break
EndIf
Next
EndIf
EndProcedure
; *****************************************************************************
|
||||
; This file holds all the functions If it gets too big,
|
||||
; we can split it in categories
|
||||
|
||||
; *****************************************************************************
|
||||
; * Tileset
|
||||
|
||||
Procedure InitTileset()
|
||||
CatchSprite(#Tile01, ?Gfx_Tileset)
|
||||
;ClipSprite(0, 0, 0, 16, 16)
|
||||
|
||||
; test the sprite
|
||||
;DisplaySprite(0, 20, 20)
|
||||
EndProcedure
|
||||
|
||||
; *****************************************************************************
|
||||
|
||||
|
||||
; *****************************************************************************
|
||||
; * Menu
|
||||
|
||||
Procedure Menu_GotoCurrent()
|
||||
If *ActiveMenu\Entries()\Selected <> #True
|
||||
FirstElement(*ActiveMenu\Entries());
|
||||
|
||||
ForEach *ActiveMenu\Entries()
|
||||
If *ActiveMenu\Entries()\Selected = #True
|
||||
Break
|
||||
EndIf
|
||||
Next
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
; Global variables
|
||||
Global Fullscreen = 0
|
||||
Global Title.s = "Pongr - Build " + Str(#PB_Editor_BuildCount)
|
||||
Global Title.s = "ESCape - Build " + Str(#PB_Editor_BuildCount)
|
||||
Global Screen.ScreenDimension\width = 800
|
||||
Screen.ScreenDimension\height = 600
|
||||
|
||||
|
|
131
src/Main.pb
131
src/Main.pb
|
@ -4,80 +4,81 @@
|
|||
|
||||
EnableExplicit
|
||||
|
||||
XIncludeFile "Structs.pbi"
|
||||
XIncludeFile "Globals.pbi"
|
||||
XIncludeFile "Draw.pbi"
|
||||
XIncludeFile "Functions.pbi"
|
||||
XIncludeFile "Events.pbi"
|
||||
|
||||
; Initialize all the variables and stuff. I think we refactor this
|
||||
; into a separate file if it gets messy.
|
||||
GameStates("MAIN_MENU")\DrawFun = @DrawMenu()
|
||||
GameStates("MAIN_MENU")\HandleEventFun = @HandleEventMenu()
|
||||
|
||||
GameStates("OPTION_MENU")\DrawFun = @DrawMenu()
|
||||
GameStates("OPTION_MENU")\HandleEventFun = @HandleEventMenu()
|
||||
|
||||
GameStates("RUNNING_GAME")\DrawFun = @DrawRunningGame()
|
||||
GameStates("RUNNING_GAME")\HandleEventFun = @HandleEventRunningGame()
|
||||
|
||||
; Read the complete game menus from the data/menu.data file.
|
||||
; TODO: IncludeBinary looks interesting!
|
||||
If ReadFile(0, "../data/menu.data")
|
||||
CreateRegularExpression(0, "^([A-Z_-]+) {(.*)}") ; Menu title
|
||||
CreateRegularExpression(1, "^ BUTTON: {(.+)} -> (.+)") ; A button
|
||||
CreateRegularExpression(2, "^ OPTION: (.*)") ; A option field (TODO: Thats not exactly right)
|
||||
|
||||
While Eof(0) = 0
|
||||
Dim Matches$(0)
|
||||
Define Line.s = ReadString(0)
|
||||
|
||||
; We found a new menu
|
||||
If MatchRegularExpression(0, Line)
|
||||
Define i
|
||||
For i=0 To ExtractRegularExpression(0, Line, Matches$())-1
|
||||
Debug Matches$(i) ; FIXME: Thats not what we want ...
|
||||
Next
|
||||
EndIf
|
||||
Wend
|
||||
|
||||
FreeRegularExpression(0)
|
||||
FreeRegularExpression(1)
|
||||
FreeRegularExpression(2)
|
||||
CloseFile(0)
|
||||
EndIf
|
||||
|
||||
Menus("MAIN_MENU")\Title = "ESCape"
|
||||
|
||||
Define Item.GameMenuItem
|
||||
Item.GameMenuItem\Label = "Escape now!"
|
||||
Item.GameMenuItem\Selected = #True
|
||||
Item.GameMenuItem\TargetState = GameStates("RUNNING_GAME")
|
||||
AddElement(Menus("MAIN_MENU")\Entries())
|
||||
menus("MAIN_MENU")\Entries() = Item
|
||||
|
||||
Define Item.GameMenuItem
|
||||
Item.GameMenuItem\Label = "End game"
|
||||
Item.GameMenuItem\Selected = #False
|
||||
Item.GameMenuItem\TargetState = GameStates("RLY_QUIT")
|
||||
AddElement(Menus("MAIN_MENU")\Entries())
|
||||
menus("MAIN_MENU")\Entries() = Item
|
||||
|
||||
*ActiveMenu.GameMenu = @Menus(CurrentState)
|
||||
|
||||
; Initialize subsystems
|
||||
If InitSprite() = 0 Or InitKeyboard() = 0
|
||||
MessageRequester("Error", "Sorry, can't keep up.", 0)
|
||||
End
|
||||
EndIf
|
||||
|
||||
InitTileset()
|
||||
|
||||
XIncludeFile "Structs.pbi"
|
||||
XIncludeFile "Globals.pbi"
|
||||
XIncludeFile "Draw.pbi"
|
||||
XIncludeFile "Functions.pbi"
|
||||
XIncludeFile "Events.pbi"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; Initialize all the variables and stuff. I think we refactor this
|
||||
; into a separate file if it gets messy.
|
||||
GameStates("MAIN_MENU")\DrawFun = @DrawMenu()
|
||||
GameStates("MAIN_MENU")\HandleEventFun = @HandleEventMenu()
|
||||
GameStates("RLY_QUIT")\DrawFun = @DrawMenu()
|
||||
GameStates("RLY_QUIT")\HandleEventFun = @HandleEventMenu()
|
||||
|
||||
GameStates("RUNNING_GAME")\DrawFun = @DrawRunningGame()
|
||||
GameStates("RUNNING_GAME")\HandleEventFun = @HandleEventRunningGame()
|
||||
|
||||
|
||||
|
||||
; Initialize the menus
|
||||
Menus("MAIN_MENU")\Title = "ESCape"
|
||||
|
||||
Define Item.GameMenuItem
|
||||
Item.GameMenuItem\Label = "Escape now!"
|
||||
Item.GameMenuItem\Selected = #True
|
||||
Item.GameMenuItem\TargetState = "RUNNING_GAME"
|
||||
AddElement(Menus("MAIN_MENU")\Entries())
|
||||
menus("MAIN_MENU")\Entries() = Item
|
||||
|
||||
Define Item.GameMenuItem
|
||||
Item.GameMenuItem\Label = "End game"
|
||||
Item.GameMenuItem\Selected = #False
|
||||
Item.GameMenuItem\TargetState = "RLY_QUIT"
|
||||
AddElement(Menus("MAIN_MENU")\Entries())
|
||||
menus("MAIN_MENU")\Entries() = Item
|
||||
|
||||
|
||||
Menus("RLY_QUIT")\Title = "Really quit?"
|
||||
|
||||
Define Item.GameMenuItem
|
||||
Item.GameMenuItem\Label = "Yes, let me go!"
|
||||
Item.GameMenuItem\Selected = #True
|
||||
Item.GameMenuItem\TargetState = "QUIT"
|
||||
AddElement(Menus("RLY_QUIT")\Entries())
|
||||
menus("RLY_QUIT")\Entries() = Item
|
||||
|
||||
Define Item.GameMenuItem
|
||||
Item.GameMenuItem\Label = "No way!"
|
||||
Item.GameMenuItem\Selected = #False
|
||||
Item.GameMenuItem\TargetState = "MAIN_MENU"
|
||||
AddElement(Menus("RLY_QUIT")\Entries())
|
||||
menus("RLY_QUIT")\Entries() = Item
|
||||
|
||||
|
||||
*ActiveMenu.GameMenu = @Menus(CurrentState)
|
||||
|
||||
|
||||
|
||||
; 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)
|
||||
OpenWindowedScreen(WindowID(0), 0, 0, Screen\Width, Screen\Height, 0, 0, 0)
|
||||
|
||||
InitTileset()
|
||||
|
||||
Repeat
|
||||
; Event loop
|
||||
Repeat
|
||||
|
@ -97,6 +98,8 @@ If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCent
|
|||
EndIf
|
||||
EndIf
|
||||
|
||||
Debug CurrentState
|
||||
|
||||
; Handle the events for the current state
|
||||
GameStates(CurrentState)\HandleEventFun()
|
||||
|
||||
|
@ -109,11 +112,13 @@ If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCent
|
|||
EndIf
|
||||
|
||||
Delay(1)
|
||||
Until KeyboardPushed(#PB_Key_Escape)
|
||||
Until CurrentState = "QUIT"
|
||||
EndIf
|
||||
|
||||
End
|
||||
|
||||
|
||||
|
||||
DataSection
|
||||
Gfx_Tileset:
|
||||
IncludeBinary "../data/gfx/tileset01.bmp"
|
|
@ -17,7 +17,7 @@ EndStructure
|
|||
|
||||
Structure GameMenuItem
|
||||
Label.s
|
||||
TargetState.GameState
|
||||
TargetState.s
|
||||
Selected.b
|
||||
EndStructure
|
||||
|
||||
|
|
Loading…
Reference in a new issue