author | unc0rr |
Sun, 26 Nov 2006 20:33:46 +0000 | |
changeset 279 | 5df0ab96b60a |
parent 244 | b37ca2295b73 |
child 281 | 5b483aa9f2ab |
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); |
60 |
cScreenEdgesDist:= Min(cScreenWidth div 4, cScreenHeight div 4); |
|
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 |
162 | 173 |
MoveCamera; |
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 |
||
95 | 210 |
if CurrentTeam <> nil then |
211 |
begin |
|
212 |
team:= TeamsList; |
|
213 |
while team<>nil do |
|
4 | 214 |
begin |
215 |
for i:= 0 to 7 do |
|
216 |
with team.Hedgehogs[i] do |
|
217 |
if Gear<>nil then |
|
218 |
if Gear.State = 0 then |
|
5 | 219 |
begin |
95 | 220 |
t:= round(Gear.Y) - cHHRadius - 10 + WorldDy; |
221 |
dec(t, HealthTag.h + 2); |
|
222 |
DrawCentered(round(Gear.X) + WorldDx, t, HealthTag, Surface); |
|
223 |
dec(t, NameTag.h + 2); |
|
224 |
DrawCentered(round(Gear.X) + WorldDx, t, NameTag, Surface); |
|
225 |
dec(t, Team.NameTag.h + 2); |
|
226 |
DrawCentered(round(Gear.X) + WorldDx, t, Team.NameTag, Surface) |
|
5 | 227 |
end else // Current hedgehog |
4 | 228 |
begin |
176 | 229 |
if bShowFinger |
230 |
and ((Gear.State and gstHHDriven) <> 0) then DrawSprite(sprFinger, round(Gear.X) - 16 + WorldDx, round(Gear.Y) - 64 + WorldDy, RealTicks div 32 mod 16, Surface); |
|
69 | 231 |
if (Gear.State and (gstMoving or gstDrowning or gstFalling)) = 0 then |
4 | 232 |
if (Gear.State and gstHHThinking) <> 0 then |
198 | 233 |
DrawGear(sQuestion, Round(Gear.X) - 10 + WorldDx, Round(Gear.Y) - cHHRadius - 34 + WorldDy, Surface) |
4 | 234 |
else |
69 | 235 |
if ShowCrosshair and ((Gear.State and gstAttacked) = 0) then |
244 | 236 |
DrawSurfSprite(Round(Gear.X + hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx - 11, |
198 | 237 |
Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 12, |
203 | 238 |
24, (18 + hwSign(Gear.dX) * integer(((Gear.Angle * 72 div cMaxAngle) + 1) div 2) mod 18) mod 18, |
198 | 239 |
Team.CrosshairSurf, Surface); |
4 | 240 |
end; |
241 |
team:= team.Next |
|
242 |
end; |
|
95 | 243 |
end; |
244 |
||
4 | 245 |
|
5 | 246 |
// Waves |
4 | 247 |
{$WARNINGS OFF} |
56 | 248 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) + 64) and $FF), cWaterLine + WorldDy - 32, 0, Surface); |
249 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface); |
|
250 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) ) and $FF), cWaterLine + WorldDy , 0, Surface); |
|
4 | 251 |
{$WARNINGS ON} |
252 |
||
79 | 253 |
// Turn time |
4 | 254 |
if TurnTimeLeft <> 0 then |
255 |
begin |
|
256 |
i:= Succ(Pred(TurnTimeLeft) div 1000); |
|
257 |
if i>99 then t:= 112 |
|
258 |
else if i>9 then t:= 96 |
|
259 |
else t:= 80; |
|
260 |
DrawSprite(sprFrame, t, cScreenHeight - 48, 1, Surface); |
|
261 |
while i > 0 do |
|
262 |
begin |
|
263 |
dec(t, 32); |
|
264 |
DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10, Surface); |
|
265 |
i:= i div 10 |
|
266 |
end; |
|
267 |
DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0, Surface); |
|
268 |
end; |
|
79 | 269 |
|
270 |
// Attack bar |
|
4 | 271 |
if CurrentTeam <> nil then |
272 |
case AttackBar of |
|
273 |
1: begin |
|
274 |
r:= StuffPoz[sPowerBar]; |
|
275 |
{$WARNINGS OFF} |
|
276 |
r.w:= (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear.Power * 256) div cPowerDivisor; |
|
277 |
{$WARNINGS ON} |
|
278 |
DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); |
|
279 |
end; |
|
74 | 280 |
2: with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
281 |
begin |
|
108 | 282 |
tdx:= hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle); |
74 | 283 |
tdy:= - Cos(Gear.Angle*pi/cMaxAngle); |
284 |
for i:= (Gear.Power * 24) div cPowerDivisor downto 0 do |
|
75 | 285 |
DrawSprite(sprPower, round(Gear.X + WorldDx + tdx * (24 + i * 2)) - 16, |
286 |
round(Gear.Y + WorldDy + tdy * (24 + i * 2)) - 12, |
|
74 | 287 |
i, Surface) |
288 |
end |
|
4 | 289 |
end; |
290 |
||
5 | 291 |
// Target |
4 | 292 |
if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface); |
293 |
||
294 |
// Captions |
|
175 | 295 |
i:= 8; |
296 |
for grp:= Low(TCapGroup) to High(TCapGroup) do |
|
297 |
with Captions[grp] do |
|
83 | 298 |
if EndTime > 0 then |
175 | 299 |
begin |
300 |
DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface); |
|
301 |
inc(i, Surf.h + 2); |
|
302 |
if EndTime <= RealTicks then |
|
303 |
begin |
|
304 |
SDL_FreeSurface(Surf); |
|
305 |
Surf:= nil; |
|
306 |
EndTime:= 0 |
|
307 |
end |
|
308 |
end; |
|
4 | 309 |
|
47 | 310 |
// Teams Healths |
311 |
team:= TeamsList; |
|
312 |
while team <> nil do |
|
313 |
begin |
|
95 | 314 |
r.x:= cScreenWidth div 2 - team.NameTag.w - 3; |
315 |
r.y:= team.DrawHealthY; |
|
316 |
r.w:= team.NameTag.w; |
|
317 |
r.h:= team.NameTag.h; |
|
318 |
SDL_UpperBlit(team.NameTag, nil, Surface, @r); |
|
47 | 319 |
r:= team.HealthRect; |
146 | 320 |
r.w:= 2 + team.TeamHealthBarWidth; |
49 | 321 |
DrawFromStoreRect(cScreenWidth div 2, |
322 |
Team.DrawHealthY, |
|
47 | 323 |
@r, Surface); |
83 | 324 |
inc(r.x, cTeamHealthWidth + 2); |
325 |
r.w:= 3; |
|
146 | 326 |
DrawFromStoreRect(cScreenWidth div 2 + team.TeamHealthBarWidth + 2, |
49 | 327 |
Team.DrawHealthY, |
47 | 328 |
@r, Surface); |
329 |
team:= team.Next |
|
330 |
end; |
|
331 |
||
5 | 332 |
// Lag alert |
4 | 333 |
if isInLag then DrawSprite(sprLag, 32, 32 + cConsoleYAdd, (RealTicks shr 7) mod 7, Surface); |
334 |
||
5 | 335 |
// Wind bar |
336 |
DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface); |
|
6 | 337 |
if WindBarWidth > 0 then |
5 | 338 |
begin |
339 |
with StuffPoz[sWindR] do |
|
340 |
begin |
|
6 | 341 |
{$WARNINGS OFF} |
5 | 342 |
r.x:= x + 8 - (RealTicks shr 6) mod 8; |
6 | 343 |
{$WARNINGS ON} |
5 | 344 |
r.y:= y; |
6 | 345 |
r.w:= WindBarWidth; |
5 | 346 |
r.h:= 13; |
347 |
end; |
|
348 |
DrawSpriteFromRect(r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface); |
|
349 |
end else |
|
6 | 350 |
if WindBarWidth < 0 then |
5 | 351 |
begin |
352 |
with StuffPoz[sWindL] do |
|
353 |
begin |
|
6 | 354 |
{$WARNINGS OFF} |
355 |
r.x:= x + (WindBarWidth + RealTicks shr 6) mod 8; |
|
356 |
{$WARNINGS ON} |
|
5 | 357 |
r.y:= y; |
6 | 358 |
r.w:= - WindBarWidth; |
5 | 359 |
r.h:= 13; |
360 |
end; |
|
6 | 361 |
DrawSpriteFromRect(r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface); |
5 | 362 |
end; |
363 |
||
161 | 364 |
// AmmoMenu |
365 |
if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface); |
|
366 |
||
5 | 367 |
// Cursor |
4 | 368 |
if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface); |
369 |
||
370 |
{$IFDEF COUNTTICKS} |
|
371 |
DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface); |
|
372 |
{$ENDIF} |
|
373 |
||
374 |
inc(Frames); |
|
375 |
inc(CountTicks, Lag); |
|
376 |
if CountTicks >= 1000 then |
|
377 |
begin |
|
378 |
FPS:= Frames; |
|
379 |
Frames:= 0; |
|
380 |
CountTicks:= 0; |
|
381 |
end; |
|
174 | 382 |
if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface); |
383 |
||
384 |
inc(SoundTimerTicks, Lag); |
|
385 |
if SoundTimerTicks >= 50 then |
|
386 |
begin |
|
387 |
SoundTimerTicks:= 0; |
|
388 |
if cVolumeDelta <> 0 then |
|
389 |
begin |
|
390 |
str(ChangeVolume(cVolumeDelta), s); |
|
175 | 391 |
AddCaption(Format(trmsg[sidVolume], s), $FFFFFF, capgrpVolume) |
174 | 392 |
end |
393 |
end |
|
4 | 394 |
end; |
395 |
||
108 | 396 |
procedure AddCaption(s: string; Color: Longword; Group: TCapGroup); |
4 | 397 |
begin |
83 | 398 |
if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s); |
175 | 399 |
if Captions[Group].Surf <> nil then SDL_FreeSurface(Captions[Group].Surf); |
4 | 400 |
|
175 | 401 |
Captions[Group].Surf:= RenderString(s, Color, fntBig); |
402 |
Captions[Group].EndTime:= RealTicks + 1200 |
|
4 | 403 |
end; |
404 |
||
79 | 405 |
procedure MoveCamera; |
4 | 406 |
const PrevSentPointTime: LongWord = 0; |
407 |
begin |
|
408 |
if not (CurrentTeam.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
|
409 |
if (FollowGear <> nil) then |
|
57 | 410 |
if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
4 | 411 |
begin |
412 |
FollowGear:= nil; |
|
413 |
exit |
|
414 |
end |
|
415 |
else begin |
|
108 | 416 |
CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + hwSign(FollowGear.dX) * 100) + WorldDx)) div 8; |
71 | 417 |
CursorPoint.y:= (CursorPoint.y * 7 + (round(FollowGear.Y) + WorldDy)) div 8 |
4 | 418 |
end; |
419 |
||
420 |
if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit; |
|
421 |
||
162 | 422 |
if AMxCurr < cScreenWidth then |
423 |
begin |
|
424 |
if CursorPoint.X < AMxCurr + 35 then CursorPoint.X:= AMxCurr + 35; |
|
425 |
if CursorPoint.X > AMxCurr + 200 then CursorPoint.X:= AMxCurr + 200; |
|
426 |
if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33; |
|
427 |
if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76; |
|
428 |
prevPoint:= CursorPoint; |
|
429 |
SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
|
430 |
exit |
|
431 |
end; |
|
432 |
||
4 | 433 |
if isCursorVisible then |
434 |
begin |
|
435 |
if (not CurrentTeam.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
|
436 |
begin |
|
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
146
diff
changeset
|
437 |
SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy); |
4 | 438 |
PrevSentPointTime:= GameTicks |
439 |
end; |
|
440 |
end; |
|
441 |
if isCursorVisible or (FollowGear <> nil) then |
|
442 |
begin |
|
443 |
if CursorPoint.X < cScreenEdgesDist then |
|
444 |
begin |
|
445 |
WorldDx:= WorldDx - CursorPoint.X + cScreenEdgesDist; |
|
446 |
CursorPoint.X:= cScreenEdgesDist |
|
447 |
end else |
|
448 |
if CursorPoint.X > cScreenWidth - cScreenEdgesDist then |
|
449 |
begin |
|
450 |
WorldDx:= WorldDx - CursorPoint.X + cScreenWidth - cScreenEdgesDist; |
|
451 |
CursorPoint.X:= cScreenWidth - cScreenEdgesDist |
|
452 |
end; |
|
453 |
if CursorPoint.Y < cScreenEdgesDist then |
|
454 |
begin |
|
455 |
WorldDy:= WorldDy - CursorPoint.Y + cScreenEdgesDist; |
|
456 |
CursorPoint.Y:= cScreenEdgesDist |
|
457 |
end else |
|
458 |
if CursorPoint.Y > cScreenHeight - cScreenEdgesDist then |
|
459 |
begin |
|
460 |
WorldDy:= WorldDy - CursorPoint.Y + cScreenHeight - cScreenEdgesDist; |
|
461 |
CursorPoint.Y:= cScreenHeight - cScreenEdgesDist |
|
462 |
end; |
|
463 |
end else |
|
464 |
begin |
|
70 | 465 |
WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; |
466 |
WorldDy:= WorldDy - CursorPoint.Y + prevPoint.Y; |
|
4 | 467 |
CursorPoint.X:= (cScreenWidth shr 1); |
468 |
CursorPoint.Y:= (cScreenHeight shr 1); |
|
469 |
end; |
|
470 |
SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
|
471 |
prevPoint:= CursorPoint; |
|
75 | 472 |
if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater; |
4 | 473 |
if WorldDy > 2048 then WorldDy:= 2048; |
474 |
if WorldDx < -2048 then WorldDx:= -2048; |
|
475 |
if WorldDx > cScreenWidth then WorldDx:= cScreenWidth; |
|
476 |
end; |
|
477 |
||
478 |
initialization |
|
479 |
FillChar(Captions, sizeof(Captions), 0) |
|
480 |
||
481 |
end. |