58 prevPoint: TPoint = (X: 0; Y: 0); |
58 prevPoint: TPoint = (X: 0; Y: 0); |
59 |
59 |
60 type TCaptionStr = record |
60 type TCaptionStr = record |
61 Surf: PSDL_Surface; |
61 Surf: PSDL_Surface; |
62 StorePos: Longword; |
62 StorePos: Longword; |
63 Group: TCapGroup; |
|
64 EndTime: LongWord; |
63 EndTime: LongWord; |
65 end; |
64 end; |
66 |
65 |
67 var cWaterSprCount: integer; |
66 var cWaterSprCount: integer; |
68 Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr; |
67 Captions: array[TCapGroup] of TCaptionStr; |
69 |
68 |
70 procedure InitWorld; |
69 procedure InitWorld; |
71 begin |
70 begin |
72 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width); |
71 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width); |
73 cScreenEdgesDist:= Min(cScreenWidth div 4, cScreenHeight div 4); |
72 cScreenEdgesDist:= Min(cScreenWidth div 4, cScreenHeight div 4); |
130 SDL_FillRect(Surface, @r, cWaterColor) |
129 SDL_FillRect(Surface, @r, cWaterColor) |
131 end; |
130 end; |
132 |
131 |
133 DrawGears(Surface); |
132 DrawGears(Surface); |
134 |
133 |
135 team:= TeamsList; |
134 if CurrentTeam <> nil then |
136 while team<>nil do |
135 begin |
|
136 team:= TeamsList; |
|
137 while team<>nil do |
137 begin |
138 begin |
138 for i:= 0 to 7 do |
139 for i:= 0 to 7 do |
139 with team.Hedgehogs[i] do |
140 with team.Hedgehogs[i] do |
140 if Gear<>nil then |
141 if Gear<>nil then |
141 if Gear.State = 0 then |
142 if Gear.State = 0 then |
142 begin |
143 begin |
143 DrawCaption( round(Gear.X) + WorldDx, |
144 t:= round(Gear.Y) - cHHRadius - 10 + WorldDy; |
144 round(Gear.Y) - cHHRadius - 30 + WorldDy, |
145 dec(t, HealthTag.h + 2); |
145 HealthRect, Surface, true); |
146 DrawCentered(round(Gear.X) + WorldDx, t, HealthTag, Surface); |
146 DrawCaption( round(Gear.X) + WorldDx, |
147 dec(t, NameTag.h + 2); |
147 round(Gear.Y) - cHHRadius - 54 + WorldDy, |
148 DrawCentered(round(Gear.X) + WorldDx, t, NameTag, Surface); |
148 NameRect, Surface); |
149 dec(t, Team.NameTag.h + 2); |
149 // DrawCaption( round(Gear.X) + WorldDx, |
150 DrawCentered(round(Gear.X) + WorldDx, t, Team.NameTag, Surface) |
150 // round(Gear.Y) - Gear.Radius - 60 + WorldDy, |
|
151 // Team.NameRect, Surface); |
|
152 end else // Current hedgehog |
151 end else // Current hedgehog |
153 begin |
152 begin |
154 if (Gear.State and (gstMoving or gstDrowning or gstFalling)) = 0 then |
153 if (Gear.State and (gstMoving or gstDrowning or gstFalling)) = 0 then |
155 if (Gear.State and gstHHThinking) <> 0 then |
154 if (Gear.State and gstHHThinking) <> 0 then |
156 DrawGear(sQuestion, Round(Gear.X) - 10 + WorldDx, Round(Gear.Y) - cHHRadius - 34 + WorldDy, Surface) |
155 DrawGear(sQuestion, Round(Gear.X) - 10 + WorldDx, Round(Gear.Y) - cHHRadius - 34 + WorldDy, Surface) |
160 Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 4, |
159 Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 4, |
161 Team.CrossHairRect, Surface) |
160 Team.CrossHairRect, Surface) |
162 end; |
161 end; |
163 team:= team.Next |
162 team:= team.Next |
164 end; |
163 end; |
|
164 end; |
|
165 |
165 |
166 |
166 // Waves |
167 // Waves |
167 {$WARNINGS OFF} |
168 {$WARNINGS OFF} |
168 for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) + 64) and $FF), cWaterLine + WorldDy - 32, 0, Surface); |
169 for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) + 64) and $FF), cWaterLine + WorldDy - 32, 0, Surface); |
169 for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface); |
170 for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface); |
215 i:= 0; |
216 i:= 0; |
216 while (i < cMaxCaptions) do |
217 while (i < cMaxCaptions) do |
217 begin |
218 begin |
218 with Captions[i] do |
219 with Captions[i] do |
219 if EndTime > 0 then |
220 if EndTime > 0 then |
220 begin |
221 DrawCentered(cScreenWidth div 2, 8 + i * (Surf.h + 2) + cConsoleYAdd, Surf, Surface); |
221 r.x:= (cScreenWidth - Surf.w) div 2; |
|
222 r.y:= 8 + i * (Surf.h + 2) + cConsoleYAdd; |
|
223 r.w:= Surf.w; |
|
224 r.h:= Surf.h; |
|
225 SDL_UpperBlit(Surf, nil, Surface, @r) |
|
226 end; |
|
227 inc(i) |
222 inc(i) |
228 end; |
223 end; |
229 while (Captions[0].EndTime > 0) and (Captions[0].EndTime <= RealTicks) do |
224 while (Captions[0].EndTime > 0) and (Captions[0].EndTime <= RealTicks) do |
230 begin |
225 begin |
231 SDL_FreeSurface(Captions[0].Surf); |
226 SDL_FreeSurface(Captions[0].Surf); |
|
227 Captions[0].Surf:= nil; |
232 for i:= 1 to Pred(cMaxCaptions) do |
228 for i:= 1 to Pred(cMaxCaptions) do |
233 Captions[Pred(i)]:= Captions[i]; |
229 Captions[Pred(i)]:= Captions[i]; |
234 Captions[Pred(cMaxCaptions)].EndTime:= 0 |
230 Captions[Pred(cMaxCaptions)].EndTime:= 0 |
235 end; |
231 end; |
236 |
232 |
237 // Teams Healths |
233 // Teams Healths |
238 team:= TeamsList; |
234 team:= TeamsList; |
239 while team <> nil do |
235 while team <> nil do |
240 begin |
236 begin |
241 DrawFromStoreRect(cScreenWidth div 2 - team.NameRect.w - 3, |
237 r.x:= cScreenWidth div 2 - team.NameTag.w - 3; |
242 Team.DrawHealthY, |
238 r.y:= team.DrawHealthY; |
243 @team.NameRect, Surface); |
239 r.w:= team.NameTag.w; |
|
240 r.h:= team.NameTag.h; |
|
241 SDL_UpperBlit(team.NameTag, nil, Surface, @r); |
244 r:= team.HealthRect; |
242 r:= team.HealthRect; |
245 r.w:= 2 + team.TeamHealth; |
243 r.w:= 2 + team.TeamHealth; |
246 DrawFromStoreRect(cScreenWidth div 2, |
244 DrawFromStoreRect(cScreenWidth div 2, |
247 Team.DrawHealthY, |
245 Team.DrawHealthY, |
248 @r, Surface); |
246 @r, Surface); |
310 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s); |
308 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s); |
311 i:= 0; |
309 i:= 0; |
312 while (i < cMaxCaptions) and (Captions[i].Group <> Group) do inc(i); |
310 while (i < cMaxCaptions) and (Captions[i].Group <> Group) do inc(i); |
313 if i < cMaxCaptions then |
311 if i < cMaxCaptions then |
314 begin |
312 begin |
|
313 SDL_FreeSurface(Captions[i].Surf); |
315 while (i < Pred(cMaxCaptions)) do |
314 while (i < Pred(cMaxCaptions)) do |
316 begin |
315 begin |
317 Captions[i]:= Captions[Succ(i)]; |
316 Captions[i]:= Captions[Succ(i)]; |
318 inc(i) |
317 inc(i) |
319 end; |
318 end; |
320 Captions[Pred(cMaxCaptions)].EndTime:= 0 |
319 Captions[Pred(cMaxCaptions)].EndTime:= 0 |
321 end; |
320 end; |
322 |
321 |
323 if Captions[Pred(cMaxCaptions)].EndTime > 0 then |
322 if Captions[Pred(cMaxCaptions)].EndTime > 0 then |
324 begin |
323 begin |
|
324 SDL_FreeSurface(Captions[0].Surf); |
325 m:= Pred(cMaxCaptions); |
325 m:= Pred(cMaxCaptions); |
326 for i:= 1 to m do |
326 for i:= 1 to m do |
327 Captions[Pred(i)]:= Captions[i]; |
327 Captions[Pred(i)]:= Captions[i]; |
328 Captions[m].EndTime:= 0 |
328 Captions[m].EndTime:= 0 |
329 end else |
329 end else |
335 k:= 0; |
335 k:= 0; |
336 for i:= 0 to Pred(cMaxCaptions) do |
336 for i:= 0 to Pred(cMaxCaptions) do |
337 for t:= 0 to Pred(cMaxCaptions) do |
337 for t:= 0 to Pred(cMaxCaptions) do |
338 if (Captions[t].EndTime > 0) and (Captions[t].StorePos = k) then inc(k); |
338 if (Captions[t].EndTime > 0) and (Captions[t].StorePos = k) then inc(k); |
339 |
339 |
340 Captions[m].Surf:= RenderString(s, Color, k); |
340 Captions[m].Surf:= RenderString(s, Color, fntBig); |
341 Captions[m].StorePos:= k; |
341 Captions[m].StorePos:= k; |
342 Captions[m].Group:= Group; |
342 Captions[m].Group:= Group; |
343 Captions[m].EndTime:= RealTicks + 1200 |
343 Captions[m].EndTime:= RealTicks + 1200 |
344 end; |
344 end; |
345 |
345 |
365 begin |
365 begin |
366 if (not CurrentTeam.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
366 if (not CurrentTeam.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
367 begin |
367 begin |
368 s[0]:= #9; |
368 s[0]:= #9; |
369 s[1]:= 'P'; |
369 s[1]:= 'P'; |
370 PInteger(@s[2])^:= CursorPoint.X - WorldDx; |
370 PSmallInt(@s[2])^:= CursorPoint.X - WorldDx; |
371 PInteger(@s[6])^:= CursorPoint.Y - WorldDy; |
371 PSmallInt(@s[4])^:= CursorPoint.Y - WorldDy; |
372 SendIPC(s); |
372 SendIPC(s); |
373 PrevSentPointTime:= GameTicks |
373 PrevSentPointTime:= GameTicks |
374 end; |
374 end; |
375 end; |
375 end; |
376 if isCursorVisible or (FollowGear <> nil) then |
376 if isCursorVisible or (FollowGear <> nil) then |