author | unc0rr |
Mon, 22 Aug 2005 15:06:42 +0000 | |
changeset 2 | 4eeab397c3c6 |
parent 1 | 30f2d1037d5d |
child 4 | bcbd7adb4e4b |
permissions | -rw-r--r-- |
1 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 |
* |
|
5 |
* Distributed under the terms of the BSD-modified licence: |
|
6 |
* |
|
7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
* of this software and associated documentation files (the "Software"), to deal |
|
9 |
* with the Software without restriction, including without limitation the |
|
10 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
11 |
* sell copies of the Software, and to permit persons to whom the Software is |
|
12 |
* furnished to do so, subject to the following conditions: |
|
13 |
* |
|
14 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
15 |
* this list of conditions and the following disclaimer. |
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
17 |
* this list of conditions and the following disclaimer in the documentation |
|
18 |
* and/or other materials provided with the distribution. |
|
19 |
* 3. The name of the author may not be used to endorse or promote products |
|
20 |
* derived from this software without specific prior written permission. |
|
21 |
* |
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
25 |
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
28 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
29 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
30 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
31 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*) |
|
33 |
||
34 |
unit uMisc; |
|
35 |
interface |
|
36 |
uses uConsts, SDLh; |
|
37 |
{$INCLUDE options.inc} |
|
38 |
var isCursorVisible : boolean = false; |
|
39 |
isTerminated : boolean = false; |
|
40 |
isInLag : boolean = false; |
|
41 |
isSoundEnabled : boolean = true; |
|
42 |
isInMultiShoot : boolean = false; |
|
43 |
||
44 |
GameState : TGameState = gsLandGen; |
|
45 |
GameType : TGameType = gmtLocal; |
|
2
4eeab397c3c6
- Support for forts game mode option. Works for demos, frontend doesn't support it.
unc0rr
parents:
1
diff
changeset
|
46 |
GameFlags : Longword = 0; |
1 | 47 |
TurnTimeLeft : Longword = 0; |
48 |
cHedgehogTurnTime: Longword = 30000; |
|
49 |
||
50 |
cLandYShift : integer = 888; |
|
51 |
cCloudsNumber : integer = 9; |
|
52 |
cConsoleHeight : integer = 320; |
|
53 |
cConsoleYAdd : integer = 0; |
|
54 |
cTimerInterval : Cardinal = 15; |
|
55 |
cScreenWidth : integer = 1024; |
|
56 |
cScreenHeight : integer = 768; |
|
57 |
cBits : integer = 16; |
|
58 |
cWaterLine : integer = 1024; |
|
59 |
cVisibleWater : integer = 64; |
|
60 |
cScreenEdgesDist : integer = 240; |
|
61 |
||
62 |
GameTicks : LongWord = 0; |
|
63 |
||
64 |
cSkyColor : Cardinal = 0; |
|
65 |
cWaterColor : Cardinal = $32397A; |
|
66 |
cMapBackColor : Cardinal = $FFFFFF; |
|
67 |
cWhiteColor : Cardinal = $FFFFFF; |
|
68 |
cConsoleSplitterColor : Cardinal = $FF0000; |
|
69 |
cColorNearBlack : Cardinal = 16; |
|
70 |
cExplosionBorderColor : LongWord = $808080; |
|
71 |
||
72 |
cDrownSpeed : Real = 0.06; |
|
73 |
cMaxWindSpeed : Real = 0.0003; |
|
74 |
cWindSpeed : Real = 0.0001; |
|
75 |
cGravity : Real = 0.0005; |
|
76 |
||
77 |
cShowFPS : boolean = true; |
|
78 |
cFullScreen : boolean = true; |
|
79 |
||
80 |
const |
|
81 |
cMaxPower = 1500; |
|
82 |
cMaxAngle = 2048; |
|
83 |
cPowerDivisor = 1500; |
|
84 |
||
85 |
var |
|
86 |
cSendEmptyPacketTime : LongWord = 2000; |
|
87 |
cSendCursorPosTime : LongWord = 50; |
|
88 |
||
89 |
flagMakeCapture: boolean = false; |
|
90 |
||
91 |
AttackBar : integer = 0; // 0 - отсутствует, 1 - внизу, 2 - как в wwp |
|
92 |
||
93 |
function Sign(r: real): integer; |
|
94 |
function Min(a, b: integer): integer; |
|
95 |
function Max(a, b: integer): integer; |
|
96 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
97 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
98 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
99 |
function IntToStr(n: integer): shortstring; |
|
100 |
function FloatToStr(n: real): shortstring; |
|
101 |
function arctan(const Y, X: real): real; |
|
102 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
103 |
procedure AdjustColor(var Color: Longword); |
|
104 |
{$IFDEF DEBUGFILE} |
|
105 |
procedure AddFileLog(s: shortstring); |
|
106 |
{$ENDIF} |
|
107 |
||
108 |
var CursorPoint: TPoint; |
|
109 |
TargetPoint: TPoint = (X: NoPointX; Y: 0); |
|
110 |
||
111 |
implementation |
|
112 |
uses uConsole, uStore; |
|
113 |
{$IFDEF DEBUGFILE} |
|
114 |
var f: textfile; |
|
115 |
{$ENDIF} |
|
116 |
||
117 |
||
118 |
function Sign(r: real): integer; |
|
119 |
begin |
|
120 |
if r < 0 then Result:= -1 else Result:= 1 |
|
121 |
end; |
|
122 |
||
123 |
function Min(a, b: integer): integer; |
|
124 |
begin |
|
125 |
if a < b then Result:= a else Result:= b |
|
126 |
end; |
|
127 |
||
128 |
function Max(a, b: integer): integer; |
|
129 |
begin |
|
130 |
if a > b then Result:= a else Result:= b |
|
131 |
end; |
|
132 |
||
133 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
134 |
begin |
|
135 |
{$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
136 |
if isFatalError then |
|
137 |
begin |
|
138 |
WriteLn(Msg); |
|
139 |
SDL_Quit; |
|
140 |
Readln; |
|
141 |
halt(1) |
|
142 |
end else WriteLnToConsole(Msg) |
|
143 |
end; |
|
144 |
||
145 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
146 |
begin |
|
147 |
if not Assert then OutError(msg, isFatal) |
|
148 |
end; |
|
149 |
||
150 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
151 |
begin |
|
152 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
153 |
end; |
|
154 |
||
155 |
procedure AdjustColor(var Color: Cardinal); |
|
156 |
begin |
|
157 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
158 |
end; |
|
159 |
||
160 |
function IntToStr(n: integer): shortstring; |
|
161 |
begin |
|
162 |
str(n, Result) |
|
163 |
end; |
|
164 |
||
165 |
function FloatToStr(n: real): shortstring; |
|
166 |
begin |
|
167 |
str(n, Result) |
|
168 |
end; |
|
169 |
||
170 |
function arctan(const Y, X: real): real; |
|
171 |
asm |
|
172 |
fld Y |
|
173 |
fld X |
|
174 |
fpatan |
|
175 |
fwait |
|
176 |
end; |
|
177 |
||
178 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
179 |
const piDIV32: Extended = pi/32; |
|
180 |
asm |
|
181 |
fld _dY |
|
182 |
fld _dX |
|
183 |
fpatan |
|
184 |
fld piDIV32 |
|
185 |
fdiv |
|
186 |
sub esp, 4 |
|
187 |
fistp dword ptr [esp] |
|
188 |
pop eax |
|
189 |
shr eax, 1 |
|
190 |
and eax, $1F |
|
191 |
end; |
|
192 |
||
193 |
||
194 |
{$IFDEF DEBUGFILE} |
|
195 |
procedure AddFileLog(s: shortstring); |
|
196 |
begin |
|
197 |
writeln(f, GameTicks: 6, ': ', s); |
|
198 |
flush(f) |
|
199 |
end; |
|
200 |
||
201 |
initialization |
|
202 |
assignfile(f, 'debug.txt'); |
|
203 |
rewrite(f); |
|
204 |
finalization |
|
205 |
writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
|
206 |
Flush(f); |
|
207 |
closefile(f) |
|
208 |
{$ENDIF} |
|
209 |
||
210 |
end. |