-
Notifications
You must be signed in to change notification settings - Fork 0
/
EldarianOdyssey.pb
154 lines (125 loc) · 3.63 KB
/
EldarianOdyssey.pb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
EnableExplicit
#COMMANDINDICATOR = "> "
;- Image Plugins
UseJPEGImageDecoder()
UsePNGImageDecoder()
XIncludeFile "Globals.pbi"
XIncludeFile "Grayscale.pbi"
XIncludeFile "TextHelpers.pbi"
XIncludeFile "Resources.pbi"
XIncludeFile "Helpers.pbi"
XIncludeFile "GetCommand.pbi"
XIncludeFile "Initialize.pbi"
XIncludeFile "Messages.pbi"
XIncludeFile "LichEncounter.pbi"
XIncludeFile "AdventureCore.pbi"
XIncludeFile "Handlers.pbi"
XIncludeFile "TimerHandlers.pbi"
XIncludeFile "DoThings.pbi"
XIncludeFile "Dialogs.pbi"
XIncludeFile "Parser.pbi"
;keep app from hanging when screen saver turns on
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Prototype protoSetThreadExecutionState(esFlags.l)
Global SetThreadExecutionState.protoSetThreadExecutionState
Define kernel32.i
kernel32 = OpenLibrary(#PB_Any, "kernel32.dll")
If IsLibrary(kernel32)
SetThreadExecutionState = GetFunction(kernel32, "SetThreadExecutionState")
SetThreadExecutionState(#ES_SYSTEM_REQUIRED | #ES_DISPLAY_REQUIRED | #ES_AWAYMODE_REQUIRED | #ES_CONTINUOUS)
CloseLibrary(kernel32)
EndIf
CompilerEndIf
InitializeGame()
;
;main game loop
;
Define rc.i, Event.i, strEvent.s
While #True
Repeat
Event = WaitWindowEvent(1)
If Event = #PB_Event_CloseWindow
End
EndIf
Until Event = 0
;draw onto buffer image
ClearScreen(0)
StartDrawing(ImageOutput(#IMAGEBUFID))
;Draw background
DrawImage(ImageID(GU\imgBackground), 0, 0)
;Draw torch on or off
If GG\ptrTorch\iState & (#STATE4 | #STATE5) ;if torch is not lit
DrawAlphaImage(ImageID(GU\imgFlameOff), GU\iXFlame, GU\iYFlame)
Else
DrawAlphaImage(ImageID(GU\imgFlameOn), GU\iXFlame, GU\iYFlame)
EndIf
If GetCommand() = #GOTCOMMAND ;also draws current input
AddToOutput("^" + #COMMANDINDICATOR + GG\strCommand) ;add blank line + command to output buffer
ProcessCommand()
EndIf
;Draw available exits
PrintDirections()
;Add room description to output buffer
AddRoomDescription(#False)
TimerCommandHandler(TimerCommand())
;DrawText output buffer onto buffer image
PrintOutputBuffer()
;if grayscale set during save/load, gray screen
If GU\fGray
Grayscale::Grayscale(#IMAGEBUFID)
EndIf
ExamineKeyboard()
If GU\iDialog <> #DIALOG_NONE
DialogBox(#DIALOG_REFRESH)
If GU\iDialog = #DIALOG_QUESTION
If KeyboardReleased(#PB_Key_Y)
OkayToAct("Y")
ElseIf KeyboardReleased(#PB_Key_N) Or KeyboardReleased(#PB_Key_Escape)
OkayToAct("N")
EndIf
Else
;Credits, About, or Help
If KeyboardReleased(#PB_Key_Escape)
GU\fGray = #False
GU\iDialog = #DIALOG_NONE
ElseIf KeyboardReleased(#PB_Key_PageDown)
GU\iPageKey = #PB_Key_PageDown
ElseIf KeyboardReleased(#PB_Key_PageUp)
GU\iPageKey = #PB_Key_PageUp
EndIf
EndIf
EndIf
If GU\iDialog <> #DIALOG_QUESTION
If GU\iDialog <> #DIALOG_HELP
;if request for Dialog box
If KeyboardReleased(#PB_Key_F1)
DialogBox(#DIALOG_ABOUT)
ElseIf KeyboardReleased(#PB_Key_F2)
DialogBox(#DIALOG_CREDITS)
EndIf
EndIf
;change theme
If KeyboardReleased(#PB_Key_F5)
If GG\iTheme = #THEME2
SetTheme(#THEME1)
Else
SetTheme(#THEME2)
EndIf
EndIf
EndIf
;stop drawing on image
StopDrawing()
;now draw to screen output
StartDrawing(ScreenOutput())
DrawImage(ImageID(#IMAGEBUFID), 0, 0)
StopDrawing()
FlipBuffers()
Delay(1)
Wend
; IDE Options = PureBasic 5.70 LTS beta 1 (Windows - x64)
; CursorPosition = 14
; FirstLine = 10
; Folding = -
; Markers = 84
; EnableXP
; CompileSourceDirectory