hedgewars/uWorld.pas
changeset 564 17fb45c670c1
parent 547 b81a055f2d06
child 602 f7628ebfccde
equal deleted inserted replaced
563:5131c641073f 564:17fb45c670c1
    37     bShowFinger: boolean = false;
    37     bShowFinger: boolean = false;
    38     Frames: Longword = 0;
    38     Frames: Longword = 0;
    39 
    39 
    40 implementation
    40 implementation
    41 uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound;
    41 uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound;
    42 const hwFloatTicks: Longword = 0;
    42 const FPS: Longword = 0;
    43       FPS: Longword = 0;
       
    44       CountTicks: Longword = 0;
    43       CountTicks: Longword = 0;
    45       SoundTimerTicks: Longword = 0;
    44       SoundTimerTicks: Longword = 0;
    46       prevPoint: TPoint = (X: 0; Y: 0);
    45       prevPoint: TPoint = (X: 0; Y: 0);
    47 
    46 
    48 type TCaptionStr = record
    47 type TCaptionStr = record
   143               end;
   142               end;
   144            end;
   143            end;
   145      end;
   144      end;
   146 
   145 
   147 bSelected:= false;
   146 bSelected:= false;
   148 if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (hwFloatTicks shr 6) mod 8, Surface)
   147 if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface)
   149 end;
   148 end;
   150 
   149 
   151 procedure MoveCamera; forward;
   150 procedure MoveCamera; forward;
   152 
   151 
   153 procedure DrawWorld(Lag: LongInt; Surface: PSDL_Surface);
   152 procedure DrawWorld(Lag: LongInt; Surface: PSDL_Surface);
   171 
   170 
   172 begin
   171 begin
   173 if not isPaused then MoveCamera;
   172 if not isPaused then MoveCamera;
   174 
   173 
   175 // Sky
   174 // Sky
   176 inc(hwFloatTicks, Lag);
       
   177 if WorldDy > 0 then
   175 if WorldDy > 0 then
   178    begin
   176    begin
   179    if WorldDy > cScreenHeight then r.h:= cScreenHeight
   177    if WorldDy > cScreenHeight then r.h:= cScreenHeight
   180                               else r.h:= WorldDy;
   178                               else r.h:= WorldDy;
   181    r.x:= 0;
   179    r.x:= 0;
   187 DrawRepeated(sprSky, WorldDx * 3 div 8);
   185 DrawRepeated(sprSky, WorldDx * 3 div 8);
   188 DrawRepeated(sprHorizont, WorldDx * 3 div 5);
   186 DrawRepeated(sprHorizont, WorldDx * 3 div 5);
   189 
   187 
   190 // Waves
   188 // Waves
   191 {$WARNINGS OFF}
   189 {$WARNINGS OFF}
   192 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (hwFloatTicks shr 6)      ) and $FF), cWaterLine + WorldDy - 64, 0, Surface);
   190 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 - (hwFloatTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface);
   191 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface);
   194 {$WARNINGS ON}
   192 {$WARNINGS ON}
   195 
   193 
   196 DrawLand(WorldDx, WorldDy, Surface);
   194 DrawLand(WorldDx, WorldDy, Surface);
   197 // Water
   195 // Water
   198 r.y:= WorldDy + cWaterLine + 32;
   196 r.y:= WorldDy + cWaterLine + 32;
   207 
   205 
   208 DrawGears(Surface);
   206 DrawGears(Surface);
   209 
   207 
   210 // Waves
   208 // Waves
   211 {$WARNINGS OFF}
   209 {$WARNINGS OFF}
   212 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (hwFloatTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 32, 0, Surface);
   210 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 - (hwFloatTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface);
   211 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 + (hwFloatTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , 0, Surface);
   212 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , 0, Surface);
   215 {$WARNINGS ON}
   213 {$WARNINGS ON}
   216 
   214 
   217 // Turn time
   215 // Turn time
   218 if TurnTimeLeft <> 0 then
   216 if TurnTimeLeft <> 0 then
   219    begin
   217    begin
   261     with Captions[grp] do
   259     with Captions[grp] do
   262          if Surf <> nil then
   260          if Surf <> nil then
   263             begin
   261             begin
   264             DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface);
   262             DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface);
   265             inc(i, Surf^.h + 2);
   263             inc(i, Surf^.h + 2);
   266             if EndTime <= hwFloatTicks then
   264             if EndTime <= RealTicks then
   267                begin
   265                begin
   268                SDL_FreeSurface(Surf);
   266                SDL_FreeSurface(Surf);
   269                Surf:= nil;
   267                Surf:= nil;
   270                EndTime:= 0
   268                EndTime:= 0
   271                end
   269                end
   291                         DrawHealthY,
   289                         DrawHealthY,
   292                         @r, Surface);
   290                         @r, Surface);
   293       end;
   291       end;
   294 
   292 
   295 // Lag alert
   293 // Lag alert
   296 if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (hwFloatTicks shr 7) mod 12, Surface);
   294 if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (RealTicks shr 7) mod 12, Surface);
   297 
   295 
   298 // Wind bar
   296 // Wind bar
   299 DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface);
   297 DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface);
   300 if WindBarWidth > 0 then
   298 if WindBarWidth > 0 then
   301    begin
   299    begin
   302    with StuffPoz[sWindR] do
   300    with StuffPoz[sWindR] do
   303         begin
   301         begin
   304         {$WARNINGS OFF}
   302         {$WARNINGS OFF}
   305         r.x:= x + 8 - (hwFloatTicks shr 6) mod 8;
   303         r.x:= x + 8 - (RealTicks shr 6) mod 8;
   306         {$WARNINGS ON}
   304         {$WARNINGS ON}
   307         r.y:= y;
   305         r.y:= y;
   308         r.w:= WindBarWidth;
   306         r.w:= WindBarWidth;
   309         r.h:= 13;
   307         r.h:= 13;
   310         end;
   308         end;
   313  if WindBarWidth < 0 then
   311  if WindBarWidth < 0 then
   314    begin
   312    begin
   315    with StuffPoz[sWindL] do
   313    with StuffPoz[sWindL] do
   316         begin
   314         begin
   317         {$WARNINGS OFF}
   315         {$WARNINGS OFF}
   318         r.x:= x + (WindBarWidth + hwFloatTicks shr 6) mod 8;
   316         r.x:= x + (WindBarWidth + RealTicks shr 6) mod 8;
   319         {$WARNINGS ON}
   317         {$WARNINGS ON}
   320         r.y:= y;
   318         r.y:= y;
   321         r.w:= - WindBarWidth;
   319         r.w:= - WindBarWidth;
   322         r.h:= 13;
   320         r.h:= 13;
   323         end;
   321         end;
   339            if PosCount > 1 then
   337            if PosCount > 1 then
   340              DrawSprite(PosSprite, CursorPoint.X - SpritesData[PosSprite].Width div 2,
   338              DrawSprite(PosSprite, CursorPoint.X - SpritesData[PosSprite].Width div 2,
   341                                    CursorPoint.Y - SpritesData[PosSprite].Height div 2,
   339                                    CursorPoint.Y - SpritesData[PosSprite].Height div 2,
   342                                    i, Surface);
   340                                    i, Surface);
   343          end;
   341          end;
   344    DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (hwFloatTicks shr 6) mod 8, Surface)
   342    DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface)
   345    end;
   343    end;
   346 
   344 
   347 {$IFDEF COUNTTICKS}
   345 {$IFDEF COUNTTICKS}
   348 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
   346 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
   349 {$ENDIF}
   347 {$ENDIF}
   384 begin
   382 begin
   385 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   383 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   386 if Captions[Group].Surf <> nil then SDL_FreeSurface(Captions[Group].Surf);
   384 if Captions[Group].Surf <> nil then SDL_FreeSurface(Captions[Group].Surf);
   387 
   385 
   388 Captions[Group].Surf:= RenderString(s, Color, fntBig);
   386 Captions[Group].Surf:= RenderString(s, Color, fntBig);
   389 Captions[Group].EndTime:= hwFloatTicks + 1500
   387 Captions[Group].EndTime:= RealTicks + 1500
   390 end;
   388 end;
   391 
   389 
   392 procedure MoveCamera;
   390 procedure MoveCamera;
   393 const PrevSentPointTime: LongWord = 0;
   391 const PrevSentPointTime: LongWord = 0;
   394 var EdgesDist: LongInt;
   392 var EdgesDist: LongInt;