hedgewars/uWorld.pas
changeset 74 42257fee61ae
parent 71 5f56c6979496
child 75 d2b737858ff7
equal deleted inserted replaced
73:fe1c62875a19 74:42257fee61ae
    68     Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr;
    68     Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr;
    69 
    69 
    70 procedure InitWorld;
    70 procedure InitWorld;
    71 begin
    71 begin
    72 cLandYShift:= cWaterLine + 64;
    72 cLandYShift:= cWaterLine + 64;
    73 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width)
    73 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
       
    74 cScreenEdgesDist:= Min(cScreenWidth div 4, cScreenHeight div 4);
       
    75 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
       
    76 prevPoint.X:= cScreenWidth div 2;
       
    77 prevPoint.Y:= cScreenHeight div 2;
       
    78 WorldDx:=  - 1024 + cScreenWidth div 2;
       
    79 WorldDy:=  - 512 + cScreenHeight div 2
    74 end;
    80 end;
    75 
    81 
    76 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    82 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    77 var i, t: integer;
    83 var i, t: integer;
    78     r: TSDL_Rect;
    84     r: TSDL_Rect;
    79     team: PTeam;
    85     team: PTeam;
       
    86     tdx, tdy: real;
    80 begin
    87 begin
    81 // Sky
    88 // Sky
    82 inc(RealTicks, Lag);
    89 inc(RealTicks, Lag);
    83 r.h:= WorldDy;
    90 r.h:= WorldDy;
    84 if r.h > 0 then
    91 if r.h > 0 then
   176            {$WARNINGS OFF}
   183            {$WARNINGS OFF}
   177            r.w:= (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear.Power * 256) div cPowerDivisor;
   184            r.w:= (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear.Power * 256) div cPowerDivisor;
   178            {$WARNINGS ON}
   185            {$WARNINGS ON}
   179            DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
   186            DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
   180            end;
   187            end;
       
   188         2: with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
       
   189                 begin
       
   190                 tdx:= Sign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle);
       
   191                 tdy:= - Cos(Gear.Angle*pi/cMaxAngle);
       
   192                 for i:= (Gear.Power * 24) div cPowerDivisor downto 0 do
       
   193                     DrawSprite(sprPower, round(Gear.X + WorldDx + tdx * (32 + i * 2)) - 16,
       
   194                                          round(Gear.Y + WorldDy + tdy * (32 + i * 2)) - 12,
       
   195                                          i, Surface)
       
   196                 end
   181         end;
   197         end;
   182 
   198 
   183 // Target
   199 // Target
   184 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   200 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   185 
   201