hedgewars/uWorld.pas
changeset 108 08f1fe6f21f8
parent 107 b08ce0293a51
child 109 ab0340f580c2
equal deleted inserted replaced
107:b08ce0293a51 108:08f1fe6f21f8
    38 const WorldDx: integer = -512;
    38 const WorldDx: integer = -512;
    39       WorldDy: integer = -256;
    39       WorldDy: integer = -256;
    40 
    40 
    41 procedure InitWorld;
    41 procedure InitWorld;
    42 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    42 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    43 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
    43 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
    44 procedure MoveCamera;
    44 procedure MoveCamera;
    45 
    45 
    46 {$IFDEF COUNTTICKS}
    46 {$IFDEF COUNTTICKS}
    47 var cntTicks: LongWord;
    47 var cntTicks: LongWord;
    48 {$ENDIF}
    48 {$ENDIF}
   154                      if (Gear.State and (gstMoving or gstDrowning or gstFalling)) = 0 then
   154                      if (Gear.State and (gstMoving or gstDrowning or gstFalling)) = 0 then
   155                         if (Gear.State and gstHHThinking) <> 0 then
   155                         if (Gear.State and gstHHThinking) <> 0 then
   156                            DrawGear(sQuestion, Round(Gear.X)  - 10 + WorldDx, Round(Gear.Y) - cHHRadius - 34 + WorldDy, Surface)
   156                            DrawGear(sQuestion, Round(Gear.X)  - 10 + WorldDx, Round(Gear.Y) - cHHRadius - 34 + WorldDy, Surface)
   157                         else
   157                         else
   158                         if ShowCrosshair and ((Gear.State and gstAttacked) = 0) then
   158                         if ShowCrosshair and ((Gear.State and gstAttacked) = 0) then
   159                            DrawCaption(Round(Gear.X + Sign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx,
   159                            DrawCaption(Round(Gear.X + hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx,
   160                                        Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 4,
   160                                        Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 4,
   161                                        Team.CrossHairRect, Surface)
   161                                        Team.CrossHairRect, Surface)
   162                      end;
   162                      end;
   163       team:= team.Next
   163       team:= team.Next
   164       end;
   164       end;
   199            {$WARNINGS ON}
   199            {$WARNINGS ON}
   200            DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
   200            DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
   201            end;
   201            end;
   202         2: with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
   202         2: with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
   203                 begin
   203                 begin
   204                 tdx:= Sign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle);
   204                 tdx:= hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle);
   205                 tdy:= - Cos(Gear.Angle*pi/cMaxAngle);
   205                 tdy:= - Cos(Gear.Angle*pi/cMaxAngle);
   206                 for i:= (Gear.Power * 24) div cPowerDivisor downto 0 do
   206                 for i:= (Gear.Power * 24) div cPowerDivisor downto 0 do
   207                     DrawSprite(sprPower, round(Gear.X + WorldDx + tdx * (24 + i * 2)) - 16,
   207                     DrawSprite(sprPower, round(Gear.X + WorldDx + tdx * (24 + i * 2)) - 16,
   208                                          round(Gear.Y + WorldDy + tdy * (24 + i * 2)) - 12,
   208                                          round(Gear.Y + WorldDy + tdy * (24 + i * 2)) - 12,
   209                                          i, Surface)
   209                                          i, Surface)
   301    CountTicks:= 0;
   301    CountTicks:= 0;
   302    end;
   302    end;
   303 if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface)
   303 if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface)
   304 end;
   304 end;
   305 
   305 
   306 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
   306 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
   307 var i, t, m, k: LongWord;
   307 var i, t, m, k: LongWord;
   308 begin
   308 begin
   309 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   309 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   310 i:= 0;
   310 i:= 0;
   311 while (i < cMaxCaptions) and (Captions[i].Group <> Group) do inc(i);
   311 while (i < cMaxCaptions) and (Captions[i].Group <> Group) do inc(i);
   354       begin
   354       begin
   355       FollowGear:= nil;
   355       FollowGear:= nil;
   356       exit
   356       exit
   357       end
   357       end
   358       else begin
   358       else begin
   359       CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + Sign(FollowGear.dX) * 100) + WorldDx)) div 8;
   359       CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + hwSign(FollowGear.dX) * 100) + WorldDx)) div 8;
   360       CursorPoint.y:= (CursorPoint.y * 7 + (round(FollowGear.Y) + WorldDy)) div 8
   360       CursorPoint.y:= (CursorPoint.y * 7 + (round(FollowGear.Y) + WorldDy)) div 8
   361       end;
   361       end;
   362 
   362 
   363 if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit;
   363 if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit;
   364 
   364