hedgewars/uVisualGears.pas
changeset 4806 48c1a395f0a7
parent 4792 68f9b331014a
child 4809 9c7d5f802618
equal deleted inserted replaced
4805:01332828b568 4806:48c1a395f0a7
    31 procedure DrawVisualGears(Layer: LongWord);
    31 procedure DrawVisualGears(Layer: LongWord);
    32 procedure DeleteVisualGear(Gear: PVisualGear);
    32 procedure DeleteVisualGear(Gear: PVisualGear);
    33 function  VisualGearByUID(uid : Longword) : PVisualGear;
    33 function  VisualGearByUID(uid : Longword) : PVisualGear;
    34 procedure AddClouds;
    34 procedure AddClouds;
    35 procedure ChangeToSDClouds;
    35 procedure ChangeToSDClouds;
       
    36 procedure AddFlakes;
       
    37 procedure ChangeToSDFlakes;
    36 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
    38 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
    37 
    39 
    38 implementation
    40 implementation
    39 uses uSound, uMobile, uVariables, uTextures, uRender, Math, uRenderUtils;
    41 uses uSound, uMobile, uVariables, uTextures, uRender, Math, uRenderUtils;
    40 
    42 
   142     case Kind of
   144     case Kind of
   143     vgtFlake: begin
   145     vgtFlake: begin
   144                 Timer:= 0;
   146                 Timer:= 0;
   145                 tdX:= 0;
   147                 tdX:= 0;
   146                 tdY:= 0;
   148                 tdY:= 0;
   147                 FrameTicks:= random(vobFrameTicks);
   149                 if SuddenDeathDmg then
   148                 Frame:= random(vobFramesCount);
   150                     begin
       
   151                     FrameTicks:= random(vobSDFrameTicks);
       
   152                     Frame:= random(vobSDFramesCount);
       
   153                     end
       
   154                 else
       
   155                     begin
       
   156                     FrameTicks:= random(vobFrameTicks);
       
   157                     Frame:= random(vobFramesCount);
       
   158                     end;
   149                 Angle:= random * 360;
   159                 Angle:= random * 360;
   150                 dx:= 0.0000038654705 * random(10000);
   160                 dx:= 0.0000038654705 * random(10000);
   151                 dy:= 0.000003506096 * random(7000);
   161                 dy:= 0.000003506096 * random(7000);
   152                 if random(2) = 0 then dx := -dx;
   162                 if random(2) = 0 then dx := -dx;
   153                 dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000
   163                 if SuddenDeathDmg then dAngle:= (random(2) * 2 - 1) * (1 + random) * vobSDVelocity / 1000
       
   164                 else dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000
   154                 end;
   165                 end;
   155     vgtCloud: begin
   166     vgtCloud: begin
   156                 Frame:= random(4);
   167                 Frame:= random(4);
   157                 dx:= 0.5 + 0.1 * random(5); // how much the cloud will be affected by wind
   168                 dx:= 0.5 + 0.1 * random(5); // how much the cloud will be affected by wind
   158                 timer:= random(4096);
   169                 timer:= random(4096);
   383 case Layer of
   394 case Layer of
   384     0: while Gear <> nil do
   395     0: while Gear <> nil do
   385         begin
   396         begin
   386         if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
   397         if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
   387         case Gear^.Kind of
   398         case Gear^.Kind of
   388             vgtFlake: if vobVelocity = 0 then
   399             vgtFlake: if SuddenDeathDmg then
   389                         if SuddenDeathDmg then
   400                         if vobSDVelocity = 0 then
   390                             DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   401                             DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   391                         else
   402                         else
       
   403                             DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
       
   404                       else
       
   405                         if vobVelocity = 0 then
   392                             DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   406                             DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   393                       else
       
   394                         if SuddenDeathDmg then
       
   395                             DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
       
   396                         else
   407                         else
   397                             DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   408                             DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   398             vgtCloud: if SuddenDeathDmg then
   409             vgtCloud: if SuddenDeathDmg then
   399                           DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   410                           DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   400                       else
   411                       else
   575     else vg:= vg^.NextGear;
   586     else vg:= vg^.NextGear;
   576 for i:= 0 to cSDCloudsNumber - 1 do
   587 for i:= 0 to cSDCloudsNumber - 1 do
   577     AddVisualGear(cLeftScreenBorder + i * cScreenSpace div (cSDCloudsNumber + 1), LAND_HEIGHT-1184, vgtCloud)
   588     AddVisualGear(cLeftScreenBorder + i * cScreenSpace div (cSDCloudsNumber + 1), LAND_HEIGHT-1184, vgtCloud)
   578 end;
   589 end;
   579 
   590 
       
   591 procedure AddFlakes;
       
   592 var i: LongInt;
       
   593 begin
       
   594 if (cReducedQuality and rqKillFlakes) <> 0 then exit;
       
   595 
       
   596 if ((GameFlags and gfBorder) <> 0) or ((Theme <> 'Snow') and (Theme <> 'Christmas')) then
       
   597     for i:= 0 to Pred(vobCount) do
       
   598         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake)
       
   599 else
       
   600     for i:= 0 to Pred(vobCount div 3) do
       
   601         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake);
       
   602 end;
       
   603 
       
   604 procedure ChangeToSDFlakes;
       
   605 var       i: LongInt;
       
   606     vg, tmp: PVisualGear;
       
   607 begin
       
   608 if (cReducedQuality and rqKillFlakes) <> 0 then exit;
       
   609 if vobCount = vobSDCount then exit;
       
   610 vg:= VisualGearsList;
       
   611 while vg <> nil do
       
   612     if vg^.Kind = vgtFlake then
       
   613         begin
       
   614         tmp:= vg^.NextGear;
       
   615         DeleteVisualGear(vg);
       
   616         vg:= tmp
       
   617         end
       
   618     else vg:= vg^.NextGear;
       
   619 if ((GameFlags and gfBorder) <> 0) or ((Theme <> 'Snow') and (Theme <> 'Christmas')) then
       
   620     for i:= 0 to Pred(vobSDCount) do
       
   621         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake)
       
   622 else
       
   623     for i:= 0 to Pred(vobSDCount div 3) do
       
   624         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake);
       
   625 end;
       
   626 
   580 procedure initModule;
   627 procedure initModule;
   581 begin
   628 begin
   582     VisualGearsList:= nil;
   629     VisualGearsList:= nil;
   583 end;
   630 end;
   584 
   631