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