author | unc0rr |
Sat, 09 Dec 2006 18:10:43 +0000 | |
changeset 292 | 0ca921ca7557 |
parent 284 | 22ce72bd637f |
child 295 | 8834f3cb620e |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
47 | 3 |
* Copyright (c) 2004, 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
19 |
unit uWorld; |
|
20 |
interface |
|
83 | 21 |
uses SDLh, uGears, uConsts; |
4 | 22 |
{$INCLUDE options.inc} |
23 |
const WorldDx: integer = -512; |
|
24 |
WorldDy: integer = -256; |
|
25 |
||
26 |
procedure InitWorld; |
|
27 |
procedure DrawWorld(Lag: integer; Surface: PSDL_Surface); |
|
108 | 28 |
procedure AddCaption(s: string; Color: Longword; Group: TCapGroup); |
4 | 29 |
|
30 |
{$IFDEF COUNTTICKS} |
|
31 |
var cntTicks: LongWord; |
|
32 |
{$ENDIF} |
|
33 |
var FollowGear: PGear = nil; |
|
6 | 34 |
WindBarWidth: integer = 0; |
161 | 35 |
bShowAmmoMenu: boolean = false; |
162 | 36 |
bSelected: boolean = false; |
176 | 37 |
bShowFinger: boolean = false; |
191
a03c2d037e24
Bots are in the same thread as game. Fixes FreePascal issues.
unc0rr
parents:
183
diff
changeset
|
38 |
Frames: Longword = 0; |
4 | 39 |
|
40 |
implementation |
|
174 | 41 |
uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound; |
4 | 42 |
const RealTicks: Longword = 0; |
43 |
FPS: Longword = 0; |
|
44 |
CountTicks: Longword = 0; |
|
174 | 45 |
SoundTimerTicks: Longword = 0; |
4 | 46 |
prevPoint: TPoint = (X: 0; Y: 0); |
161 | 47 |
|
4 | 48 |
type TCaptionStr = record |
83 | 49 |
Surf: PSDL_Surface; |
4 | 50 |
EndTime: LongWord; |
51 |
end; |
|
52 |
||
53 |
var cWaterSprCount: integer; |
|
175 | 54 |
Captions: array[TCapGroup] of TCaptionStr; |
162 | 55 |
AMxLeft, AMxCurr, SlotsNum: integer; |
4 | 56 |
|
57 |
procedure InitWorld; |
|
58 |
begin |
|
74 | 59 |
cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width); |
284 | 60 |
cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50); |
74 | 61 |
SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
62 |
prevPoint.X:= cScreenWidth div 2; |
|
63 |
prevPoint.Y:= cScreenHeight div 2; |
|
64 |
WorldDx:= - 1024 + cScreenWidth div 2; |
|
161 | 65 |
WorldDy:= - 512 + cScreenHeight div 2; |
66 |
AMxLeft:= cScreenWidth - 210; |
|
67 |
AMxCurr:= cScreenWidth |
|
68 |
end; |
|
69 |
||
70 |
procedure ShowAmmoMenu(Surface: PSDL_Surface); |
|
71 |
const MENUSPEED = 15; |
|
72 |
var x, y, i, t: integer; |
|
162 | 73 |
Slot, Pos: integer; |
161 | 74 |
begin |
75 |
if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false; |
|
165 | 76 |
if bShowAmmoMenu then |
77 |
begin |
|
78 |
if AMxCurr = cScreenWidth then prevPoint.X:= 0; |
|
79 |
if AMxCurr > AMxLeft then dec(AMxCurr, MENUSPEED); |
|
80 |
end else |
|
81 |
begin |
|
82 |
if AMxCurr = AMxLeft then |
|
83 |
begin |
|
84 |
CursorPoint.X:= cScreenWidth div 2; |
|
85 |
CursorPoint.Y:= cScreenHeight div 2; |
|
86 |
prevPoint:= CursorPoint; |
|
87 |
SDL_WarpMouse(CursorPoint.X, CursorPoint.Y) |
|
88 |
end; |
|
89 |
if AMxCurr < cScreenWidth then inc(AMxCurr, MENUSPEED); |
|
90 |
end; |
|
161 | 91 |
|
92 |
if CurrentTeam = nil then exit; |
|
162 | 93 |
Slot:= 0; |
94 |
Pos:= -1; |
|
161 | 95 |
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
96 |
begin |
|
97 |
if Ammo = nil then exit; |
|
162 | 98 |
SlotsNum:= 0; |
161 | 99 |
x:= AMxCurr; |
100 |
y:= cScreenHeight - 40; |
|
101 |
dec(y); |
|
102 |
DrawSprite(sprAMBorders, x, y, 0, Surface); |
|
103 |
dec(y); |
|
104 |
DrawSprite(sprAMBorders, x, y, 1, Surface); |
|
105 |
dec(y, 33); |
|
106 |
DrawSprite(sprAMSlotName, x, y, 0, Surface); |
|
107 |
for i:= cMaxSlotIndex downto 0 do |
|
108 |
if Ammo[i, 0].Count > 0 then |
|
109 |
begin |
|
162 | 110 |
if (CursorPoint.Y >= y - 33) and (CursorPoint.Y < y) then Slot:= i; |
161 | 111 |
dec(y, 33); |
162 | 112 |
inc(SlotsNum); |
161 | 113 |
DrawSprite(sprAMSlot, x, y, 0, Surface); |
114 |
DrawSprite(sprAMSlotKeys, x + 2, y + 1, i, Surface); |
|
115 |
t:= 0; |
|
116 |
while (t <= cMaxSlotAmmoIndex) and (Ammo[i, t].Count > 0) do |
|
117 |
begin |
|
118 |
DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, integer(Ammo[i, t].AmmoType), Surface); |
|
162 | 119 |
if (Slot = i) and (CursorPoint.X >= x + t * 33 + 35) and (CursorPoint.X < x + t * 33 + 68) then |
120 |
begin |
|
121 |
DrawSprite(sprAMSelection, x + t * 33 + 35, y + 1, 0, Surface); |
|
122 |
Pos:= t; |
|
123 |
end; |
|
161 | 124 |
inc(t) |
125 |
end |
|
126 |
end; |
|
127 |
dec(y, 1); |
|
162 | 128 |
DrawSprite(sprAMBorders, x, y, 0, Surface); |
129 |
||
130 |
if (Pos >= 0) then |
|
131 |
if Ammo[Slot, Pos].Count > 0 then |
|
132 |
begin |
|
133 |
DXOutText(AMxCurr + 10, cScreenHeight - 68, fnt16, trAmmo[Ammoz[Ammo[Slot, Pos].AmmoType].NameId], Surface); |
|
134 |
if Ammo[Slot, Pos].Count < 10 then |
|
135 |
DXOutText(AMxCurr + 175, cScreenHeight - 68, fnt16, chr(Ammo[Slot, Pos].Count + 48) + 'x', Surface); |
|
136 |
if bSelected then |
|
137 |
begin |
|
165 | 138 |
bShowAmmoMenu:= false; |
139 |
SetWeapon(Ammo[Slot, Pos].AmmoType); |
|
140 |
bSelected:= false; |
|
141 |
exit |
|
162 | 142 |
end; |
143 |
end; |
|
144 |
end; |
|
145 |
||
146 |
bSelected:= false; |
|
165 | 147 |
if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface) |
4 | 148 |
end; |
149 |
||
162 | 150 |
procedure MoveCamera; forward; |
151 |
||
4 | 152 |
procedure DrawWorld(Lag: integer; Surface: PSDL_Surface); |
153 |
var i, t: integer; |
|
154 |
r: TSDL_Rect; |
|
155 |
team: PTeam; |
|
107 | 156 |
tdx, tdy: Double; |
175 | 157 |
grp: TCapGroup; |
174 | 158 |
s: string[15]; |
80 | 159 |
|
82 | 160 |
procedure DrawRepeated(spr: TSprite; Shift: integer); |
80 | 161 |
var i, w: integer; |
162 |
begin |
|
163 |
w:= SpritesData[spr].Width; |
|
82 | 164 |
i:= Shift mod w; |
80 | 165 |
if i > 0 then dec(i, w); |
166 |
repeat |
|
167 |
DrawSprite(spr, i, WorldDy + 1024 - SpritesData[spr].Height, 0, Surface); |
|
168 |
inc(i, w) |
|
169 |
until i > cScreenWidth |
|
170 |
end; |
|
171 |
||
4 | 172 |
begin |
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
173 |
if not isPaused then MoveCamera; |
162 | 174 |
|
5 | 175 |
// Sky |
4 | 176 |
inc(RealTicks, Lag); |
109 | 177 |
if WorldDy > 0 then |
4 | 178 |
begin |
109 | 179 |
if WorldDy > cScreenHeight then r.h:= cScreenHeight |
180 |
else r.h:= WorldDy; |
|
4 | 181 |
r.x:= 0; |
182 |
r.y:= 0; |
|
183 |
r.w:= cScreenWidth; |
|
184 |
SDL_FillRect(Surface, @r, cSkyColor) |
|
185 |
end; |
|
5 | 186 |
// background |
82 | 187 |
DrawRepeated(sprSky, WorldDx * 3 div 8); |
188 |
DrawRepeated(sprHorizont, WorldDx * 3 div 5); |
|
4 | 189 |
|
5 | 190 |
// Waves |
4 | 191 |
{$WARNINGS OFF} |
56 | 192 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) ) and $FF), cWaterLine + WorldDy - 64, 0, Surface); |
193 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface); |
|
4 | 194 |
{$WARNINGS ON} |
195 |
||
196 |
DrawLand(WorldDx, WorldDy, Surface); |
|
5 | 197 |
// Water |
4 | 198 |
r.y:= WorldDy + cWaterLine + 32; |
199 |
if r.y < cScreenHeight then |
|
200 |
begin |
|
23 | 201 |
if r.y < 0 then r.y:= 0; |
4 | 202 |
r.h:= cScreenHeight - r.y; |
203 |
r.x:= 0; |
|
204 |
r.w:= cScreenWidth; |
|
205 |
SDL_FillRect(Surface, @r, cWaterColor) |
|
206 |
end; |
|
207 |
||
208 |
DrawGears(Surface); |
|
209 |
||
5 | 210 |
// Waves |
4 | 211 |
{$WARNINGS OFF} |
56 | 212 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) + 64) and $FF), cWaterLine + WorldDy - 32, 0, Surface); |
213 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface); |
|
214 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) ) and $FF), cWaterLine + WorldDy , 0, Surface); |
|
4 | 215 |
{$WARNINGS ON} |
216 |
||
79 | 217 |
// Turn time |
4 | 218 |
if TurnTimeLeft <> 0 then |
219 |
begin |
|
220 |
i:= Succ(Pred(TurnTimeLeft) div 1000); |
|
221 |
if i>99 then t:= 112 |
|
222 |
else if i>9 then t:= 96 |
|
223 |
else t:= 80; |
|
224 |
DrawSprite(sprFrame, t, cScreenHeight - 48, 1, Surface); |
|
225 |
while i > 0 do |
|
226 |
begin |
|
227 |
dec(t, 32); |
|
228 |
DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10, Surface); |
|
229 |
i:= i div 10 |
|
230 |
end; |
|
231 |
DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0, Surface); |
|
232 |
end; |
|
79 | 233 |
|
234 |
// Attack bar |
|
4 | 235 |
if CurrentTeam <> nil then |
236 |
case AttackBar of |
|
237 |
1: begin |
|
238 |
r:= StuffPoz[sPowerBar]; |
|
239 |
{$WARNINGS OFF} |
|
240 |
r.w:= (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear.Power * 256) div cPowerDivisor; |
|
241 |
{$WARNINGS ON} |
|
242 |
DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); |
|
243 |
end; |
|
74 | 244 |
2: with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
245 |
begin |
|
108 | 246 |
tdx:= hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle); |
74 | 247 |
tdy:= - Cos(Gear.Angle*pi/cMaxAngle); |
248 |
for i:= (Gear.Power * 24) div cPowerDivisor downto 0 do |
|
75 | 249 |
DrawSprite(sprPower, round(Gear.X + WorldDx + tdx * (24 + i * 2)) - 16, |
250 |
round(Gear.Y + WorldDy + tdy * (24 + i * 2)) - 12, |
|
74 | 251 |
i, Surface) |
252 |
end |
|
4 | 253 |
end; |
254 |
||
5 | 255 |
// Target |
4 | 256 |
if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface); |
257 |
||
258 |
// Captions |
|
175 | 259 |
i:= 8; |
260 |
for grp:= Low(TCapGroup) to High(TCapGroup) do |
|
261 |
with Captions[grp] do |
|
83 | 262 |
if EndTime > 0 then |
175 | 263 |
begin |
264 |
DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface); |
|
265 |
inc(i, Surf.h + 2); |
|
266 |
if EndTime <= RealTicks then |
|
267 |
begin |
|
268 |
SDL_FreeSurface(Surf); |
|
269 |
Surf:= nil; |
|
270 |
EndTime:= 0 |
|
271 |
end |
|
272 |
end; |
|
4 | 273 |
|
47 | 274 |
// Teams Healths |
275 |
team:= TeamsList; |
|
276 |
while team <> nil do |
|
277 |
begin |
|
95 | 278 |
r.x:= cScreenWidth div 2 - team.NameTag.w - 3; |
279 |
r.y:= team.DrawHealthY; |
|
280 |
r.w:= team.NameTag.w; |
|
281 |
r.h:= team.NameTag.h; |
|
282 |
SDL_UpperBlit(team.NameTag, nil, Surface, @r); |
|
47 | 283 |
r:= team.HealthRect; |
146 | 284 |
r.w:= 2 + team.TeamHealthBarWidth; |
49 | 285 |
DrawFromStoreRect(cScreenWidth div 2, |
286 |
Team.DrawHealthY, |
|
47 | 287 |
@r, Surface); |
83 | 288 |
inc(r.x, cTeamHealthWidth + 2); |
289 |
r.w:= 3; |
|
146 | 290 |
DrawFromStoreRect(cScreenWidth div 2 + team.TeamHealthBarWidth + 2, |
49 | 291 |
Team.DrawHealthY, |
47 | 292 |
@r, Surface); |
293 |
team:= team.Next |
|
294 |
end; |
|
295 |
||
5 | 296 |
// Lag alert |
4 | 297 |
if isInLag then DrawSprite(sprLag, 32, 32 + cConsoleYAdd, (RealTicks shr 7) mod 7, Surface); |
298 |
||
5 | 299 |
// Wind bar |
300 |
DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface); |
|
6 | 301 |
if WindBarWidth > 0 then |
5 | 302 |
begin |
303 |
with StuffPoz[sWindR] do |
|
304 |
begin |
|
6 | 305 |
{$WARNINGS OFF} |
5 | 306 |
r.x:= x + 8 - (RealTicks shr 6) mod 8; |
6 | 307 |
{$WARNINGS ON} |
5 | 308 |
r.y:= y; |
6 | 309 |
r.w:= WindBarWidth; |
5 | 310 |
r.h:= 13; |
311 |
end; |
|
312 |
DrawSpriteFromRect(r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface); |
|
313 |
end else |
|
6 | 314 |
if WindBarWidth < 0 then |
5 | 315 |
begin |
316 |
with StuffPoz[sWindL] do |
|
317 |
begin |
|
6 | 318 |
{$WARNINGS OFF} |
319 |
r.x:= x + (WindBarWidth + RealTicks shr 6) mod 8; |
|
320 |
{$WARNINGS ON} |
|
5 | 321 |
r.y:= y; |
6 | 322 |
r.w:= - WindBarWidth; |
5 | 323 |
r.h:= 13; |
324 |
end; |
|
6 | 325 |
DrawSpriteFromRect(r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface); |
5 | 326 |
end; |
327 |
||
161 | 328 |
// AmmoMenu |
329 |
if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface); |
|
330 |
||
5 | 331 |
// Cursor |
4 | 332 |
if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface); |
333 |
||
334 |
{$IFDEF COUNTTICKS} |
|
335 |
DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface); |
|
336 |
{$ENDIF} |
|
337 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
338 |
if isPaused then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, PauseSurface, Surface); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
339 |
|
4 | 340 |
inc(Frames); |
341 |
inc(CountTicks, Lag); |
|
342 |
if CountTicks >= 1000 then |
|
343 |
begin |
|
344 |
FPS:= Frames; |
|
345 |
Frames:= 0; |
|
346 |
CountTicks:= 0; |
|
347 |
end; |
|
174 | 348 |
if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface); |
349 |
||
350 |
inc(SoundTimerTicks, Lag); |
|
351 |
if SoundTimerTicks >= 50 then |
|
352 |
begin |
|
353 |
SoundTimerTicks:= 0; |
|
354 |
if cVolumeDelta <> 0 then |
|
355 |
begin |
|
356 |
str(ChangeVolume(cVolumeDelta), s); |
|
175 | 357 |
AddCaption(Format(trmsg[sidVolume], s), $FFFFFF, capgrpVolume) |
174 | 358 |
end |
359 |
end |
|
4 | 360 |
end; |
361 |
||
108 | 362 |
procedure AddCaption(s: string; Color: Longword; Group: TCapGroup); |
4 | 363 |
begin |
83 | 364 |
if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s); |
175 | 365 |
if Captions[Group].Surf <> nil then SDL_FreeSurface(Captions[Group].Surf); |
4 | 366 |
|
175 | 367 |
Captions[Group].Surf:= RenderString(s, Color, fntBig); |
368 |
Captions[Group].EndTime:= RealTicks + 1200 |
|
4 | 369 |
end; |
370 |
||
79 | 371 |
procedure MoveCamera; |
4 | 372 |
const PrevSentPointTime: LongWord = 0; |
284 | 373 |
var EdgesDist: integer; |
4 | 374 |
begin |
375 |
if not (CurrentTeam.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
|
376 |
if (FollowGear <> nil) then |
|
57 | 377 |
if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
4 | 378 |
begin |
379 |
FollowGear:= nil; |
|
380 |
exit |
|
381 |
end |
|
382 |
else begin |
|
108 | 383 |
CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + hwSign(FollowGear.dX) * 100) + WorldDx)) div 8; |
71 | 384 |
CursorPoint.y:= (CursorPoint.y * 7 + (round(FollowGear.Y) + WorldDy)) div 8 |
4 | 385 |
end; |
386 |
||
387 |
if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit; |
|
388 |
||
162 | 389 |
if AMxCurr < cScreenWidth then |
390 |
begin |
|
391 |
if CursorPoint.X < AMxCurr + 35 then CursorPoint.X:= AMxCurr + 35; |
|
392 |
if CursorPoint.X > AMxCurr + 200 then CursorPoint.X:= AMxCurr + 200; |
|
393 |
if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33; |
|
394 |
if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76; |
|
395 |
prevPoint:= CursorPoint; |
|
396 |
SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
|
397 |
exit |
|
398 |
end; |
|
399 |
||
4 | 400 |
if isCursorVisible then |
401 |
begin |
|
402 |
if (not CurrentTeam.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
|
403 |
begin |
|
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
146
diff
changeset
|
404 |
SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy); |
4 | 405 |
PrevSentPointTime:= GameTicks |
406 |
end; |
|
407 |
end; |
|
284 | 408 |
|
4 | 409 |
if isCursorVisible or (FollowGear <> nil) then |
410 |
begin |
|
284 | 411 |
if isCursorVisible then EdgesDist:= cCursorEdgesDist |
412 |
else EdgesDist:= cGearScrEdgesDist; |
|
413 |
if CursorPoint.X < EdgesDist then |
|
4 | 414 |
begin |
284 | 415 |
WorldDx:= WorldDx - CursorPoint.X + EdgesDist; |
416 |
CursorPoint.X:= EdgesDist |
|
4 | 417 |
end else |
284 | 418 |
if CursorPoint.X > cScreenWidth - EdgesDist then |
4 | 419 |
begin |
284 | 420 |
WorldDx:= WorldDx - CursorPoint.X + cScreenWidth - EdgesDist; |
421 |
CursorPoint.X:= cScreenWidth - EdgesDist |
|
4 | 422 |
end; |
284 | 423 |
if CursorPoint.Y < EdgesDist then |
4 | 424 |
begin |
284 | 425 |
WorldDy:= WorldDy - CursorPoint.Y + EdgesDist; |
426 |
CursorPoint.Y:= EdgesDist |
|
4 | 427 |
end else |
284 | 428 |
if CursorPoint.Y > cScreenHeight - EdgesDist then |
4 | 429 |
begin |
284 | 430 |
WorldDy:= WorldDy - CursorPoint.Y + cScreenHeight - EdgesDist; |
431 |
CursorPoint.Y:= cScreenHeight - EdgesDist |
|
4 | 432 |
end; |
433 |
end else |
|
434 |
begin |
|
70 | 435 |
WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; |
436 |
WorldDy:= WorldDy - CursorPoint.Y + prevPoint.Y; |
|
4 | 437 |
CursorPoint.X:= (cScreenWidth shr 1); |
438 |
CursorPoint.Y:= (cScreenHeight shr 1); |
|
439 |
end; |
|
440 |
SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
|
441 |
prevPoint:= CursorPoint; |
|
75 | 442 |
if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater; |
4 | 443 |
if WorldDy > 2048 then WorldDy:= 2048; |
444 |
if WorldDx < -2048 then WorldDx:= -2048; |
|
445 |
if WorldDx > cScreenWidth then WorldDx:= cScreenWidth; |
|
446 |
end; |
|
447 |
||
448 |
initialization |
|
449 |
FillChar(Captions, sizeof(Captions), 0) |
|
450 |
||
451 |
end. |