initial data and stuff
This commit is contained in:
parent
5ad8a0fb96
commit
9b069db5cd
11 changed files with 393 additions and 3 deletions
4
README
4
README
|
@ -1,3 +1 @@
|
|||
good, you´ve read me! :)
|
||||
|
||||
Test!
|
||||
Aaron and Ruben Müller for the LD21
|
8
data/menu.data
Normal file
8
data/menu.data
Normal file
|
@ -0,0 +1,8 @@
|
|||
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
|
||||
|
69
doc/LICENSE.pcre.txt
Normal file
69
doc/LICENSE.pcre.txt
Normal file
|
@ -0,0 +1,69 @@
|
|||
PCRE LICENCE
|
||||
------------
|
||||
|
||||
PCRE is a library of functions to support regular expressions whose syntax
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Release 7 of PCRE is distributed under the terms of the "BSD" licence, as
|
||||
specified below. The documentation for PCRE, supplied in the "doc"
|
||||
directory, is distributed under the same terms as the software itself.
|
||||
|
||||
The basic library functions are written in C and are freestanding. Also
|
||||
included in the distribution is a set of C++ wrapper functions.
|
||||
|
||||
|
||||
THE BASIC LIBRARY FUNCTIONS
|
||||
---------------------------
|
||||
|
||||
Written by: Philip Hazel
|
||||
Email local part: ph10
|
||||
Email domain: cam.ac.uk
|
||||
|
||||
University of Cambridge Computing Service,
|
||||
Cambridge, England.
|
||||
|
||||
Copyright (c) 1997-2007 University of Cambridge
|
||||
All rights reserved.
|
||||
|
||||
|
||||
THE C++ WRAPPER FUNCTIONS
|
||||
-------------------------
|
||||
|
||||
Contributed by: Google Inc.
|
||||
|
||||
Copyright (c) 2007, Google Inc.
|
||||
All rights reserved.
|
||||
|
||||
|
||||
THE "BSD" LICENCE
|
||||
-----------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the University of Cambridge nor the name of Google
|
||||
Inc. nor the names of their contributors may be used to endorse or
|
||||
promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
End
|
||||
|
48
escape.pbp
Normal file
48
escape.pbp
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 4.51 (MacOS X - x86)">
|
||||
<section name="config">
|
||||
<options closefiles="1" openmode="0" name="ESCape"/>
|
||||
<comment>
|
||||
LD21 with Aaron and Ruben
|
||||
</comment>
|
||||
</section>
|
||||
<section name="data">
|
||||
<explorer view="../../../" pattern="0"/>
|
||||
<log show="1"/>
|
||||
<lastopen date="2011-08-20 14:40" user="rubenmueller" host="localhost"/>
|
||||
</section>
|
||||
<section name="files">
|
||||
<file name="src/Main.pb">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="417507aea66f78905c4df97a3320154c"/>
|
||||
</file>
|
||||
<file name="src/Draw.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="d6d3ec279f01ec471b40d898bdd3bfea"/>
|
||||
</file>
|
||||
<file name="src/Events.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="0b1b012875300d8e87bdd60b48eff043"/>
|
||||
</file>
|
||||
<file name="src/Functions.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="ca68ea8da1167d8ec714cca0cc2c3c7e"/>
|
||||
</file>
|
||||
<file name="src/Globals.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="3f1597a2d80a28427556491483d43bef"/>
|
||||
</file>
|
||||
<file name="src/Structs.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
|
||||
<fingerprint md5="f1ad13f0d40ae11665f9bfbf6b359b22"/>
|
||||
</file>
|
||||
</section>
|
||||
<section name="targets">
|
||||
<target name="Default Target" enabled="1" default="1">
|
||||
<inputfile value=""/>
|
||||
<outputfile value=""/>
|
||||
<options xpskin="1" debug="1"/>
|
||||
</target>
|
||||
</section>
|
||||
</project>
|
BIN
shots/ESCape-01.jpg
Normal file
BIN
shots/ESCape-01.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
43
src/Draw.pbi
Normal file
43
src/Draw.pbi
Normal file
|
@ -0,0 +1,43 @@
|
|||
; Here we draw stuff on screen. These are the dispatch
|
||||
; functions which will be called from the state dispatch
|
||||
; process.
|
||||
|
||||
|
||||
; Draw the current activated menu. This will be set from
|
||||
; the dispatcher. The events are controlled by the
|
||||
; HandleEventMenu() function.
|
||||
Procedure DrawMenu()
|
||||
Define Black = RGB(0, 0, 0)
|
||||
Define White = RGB(255, 255, 255)
|
||||
Define ActiveMenuItemColor = RGB(255, 0, 0)
|
||||
|
||||
DrawingFont(Font_H1)
|
||||
DrawText(50, 50, *ActiveMenu\Title, white, black)
|
||||
|
||||
Define Offset = 0
|
||||
Define FontColor = White
|
||||
ForEach *ActiveMenu\Entries()
|
||||
If *ActiveMenu\Entries()\Selected
|
||||
FontColor = ActiveMenuItemColor
|
||||
Else
|
||||
FontColor = White
|
||||
EndIf
|
||||
|
||||
DrawingFont(Font_H2)
|
||||
DrawText(50, 300+(Offset*30), *ActiveMenu\Entries()\Label, FontColor, Black)
|
||||
Offset = Offset+1
|
||||
Next
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure DrawRunningGame()
|
||||
Box(0, 0, 200, 200, RGB(0, 255, 0))
|
||||
EndProcedure
|
||||
; IDE Options = PureBasic 4.51 (MacOS X - x86)
|
||||
; CursorPosition = 26
|
||||
; Folding = -
|
||||
; EnableUnicode
|
||||
; EnableThread
|
||||
; EnableXP
|
||||
; EnableCompileCount = 0
|
||||
; EnableBuildCount = 0
|
46
src/Events.pbi
Normal file
46
src/Events.pbi
Normal file
|
@ -0,0 +1,46 @@
|
|||
; 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
|
||||
|
||||
If ListIndex(*ActiveMenu\Entries()) = 0
|
||||
LastElement(*ActiveMenu\Entries())
|
||||
Else
|
||||
PreviousElement(*ActiveMenu\Entries())
|
||||
EndIf
|
||||
|
||||
*ActiveMenu\Entries()\Selected = #True
|
||||
EndIf
|
||||
|
||||
If KeyboardReleased(#PB_Key_Down)
|
||||
Menu_GotoCurrent()
|
||||
*ActiveMenu\Entries()\Selected = #False
|
||||
|
||||
If ListIndex(*ActiveMenu\Entries()) = (ListSize(*ActiveMenu\Entries())-1)
|
||||
FirstElement(*ActiveMenu\Entries())
|
||||
Else
|
||||
NextElement(*ActiveMenu\Entries())
|
||||
EndIf
|
||||
|
||||
*ActiveMenu\Entries()\Selected = #True
|
||||
EndIf
|
||||
|
||||
If KeyboardReleased(#PB_Key_Return)
|
||||
Debug "Return!"
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
Procedure HandleEventRunningGame()
|
||||
EndProcedure
|
||||
; IDE Options = PureBasic 4.51 (MacOS X - x86)
|
||||
; CursorPosition = 32
|
||||
; Folding = -
|
||||
; EnableUnicode
|
||||
; EnableThread
|
||||
; EnableXP
|
||||
; EnableCompileCount = 0
|
||||
; EnableBuildCount = 0
|
1
src/Functions.pbi
Normal file
1
src/Functions.pbi
Normal file
|
@ -0,0 +1 @@
|
|||
; This file holds all the functions If it gets too big,
; we can split it in categories
; *****************************************************************************
; * 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
; *****************************************************************************
; IDE Options = PureBasic 4.51 (MacOS X - x86)
; CursorPosition = 13
; Folding = -
; EnableXP
|
20
src/Globals.pbi
Normal file
20
src/Globals.pbi
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
; Global variables
|
||||
Global Fullscreen = 0
|
||||
Global Title.s = "Pongr - Build " + Str(#PB_Editor_BuildCount)
|
||||
Global Screen.ScreenDimension\width = 800
|
||||
Screen.ScreenDimension\height = 600
|
||||
|
||||
NewMap GameStates.GameState()
|
||||
Global NewMap Menus.GameMenu()
|
||||
Global CurrentState.s = "MAIN_MENU"
|
||||
Global *ActiveMenu.GameMenu
|
||||
|
||||
; Fonts
|
||||
Global Font_H1 = LoadFont(1, "Courier", 40, #PB_Font_Bold)
|
||||
Global Font_H2 = LoadFont(2, "Verdana", 18)
|
||||
; IDE Options = PureBasic 4.51 (MacOS X - x86)
|
||||
; CursorPosition = 13
|
||||
; EnableXP
|
||||
; EnableCompileCount = 0
|
||||
; EnableBuildCount = 0
|
117
src/Main.pb
Normal file
117
src/Main.pb
Normal file
|
@ -0,0 +1,117 @@
|
|||
; ESCape
|
||||
; LD21 entry
|
||||
; 2011 - Ruben Mueller, Aaron Mueller
|
||||
|
||||
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
|
||||
|
||||
; 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)
|
||||
|
||||
Repeat
|
||||
; Event loop
|
||||
Repeat
|
||||
Define 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
|
||||
GameStates(CurrentState)\HandleEventFun()
|
||||
|
||||
; Draw the stuff on the screen
|
||||
FlipBuffers()
|
||||
ClearScreen(RGB(0, 0, 0))
|
||||
If StartDrawing(ScreenOutput())
|
||||
GameStates(CurrentState)\DrawFun()
|
||||
StopDrawing()
|
||||
EndIf
|
||||
|
||||
Delay(1)
|
||||
Until KeyboardPushed(#PB_Key_Escape)
|
||||
EndIf
|
||||
; IDE Options = PureBasic 4.51 (MacOS X - x86)
|
||||
; CursorPosition = 59
|
||||
; FirstLine = 26
|
||||
; EnableXP
|
||||
; EnableCompileCount = 0
|
||||
; EnableBuildCount = 0
|
40
src/Structs.pbi
Normal file
40
src/Structs.pbi
Normal file
|
@ -0,0 +1,40 @@
|
|||
; This file holds all structs so we can include it in every
|
||||
; file we need it.
|
||||
|
||||
Structure ScreenDimension
|
||||
Width.i
|
||||
Height.i
|
||||
EndStructure
|
||||
|
||||
Prototype DRAW()
|
||||
Prototype HANDLE_EVENTS()
|
||||
|
||||
Structure GameState
|
||||
DrawFun.DRAW
|
||||
HandleEventFun.HANDLE_EVENTS
|
||||
EndStructure
|
||||
|
||||
|
||||
Structure GameMenuItem
|
||||
Label.s
|
||||
TargetState.GameState
|
||||
Selected.b
|
||||
EndStructure
|
||||
|
||||
Structure GameOptionItem
|
||||
List Options.s()
|
||||
CurrentPosition.i
|
||||
Selected.b
|
||||
EndStructure
|
||||
|
||||
Structure GameMenu
|
||||
Title.s
|
||||
List Entries.GameMenuItem()
|
||||
EndStructure
|
||||
; IDE Options = PureBasic 4.51 (MacOS X - x86)
|
||||
; CursorPosition = 32
|
||||
; EnableUnicode
|
||||
; EnableThread
|
||||
; EnableXP
|
||||
; EnableCompileCount = 1
|
||||
; EnableBuildCount = 0
|
Loading…
Reference in a new issue