hedgewars/GSHandlers.inc
changeset 4611 445d382cd401
parent 4602 ec84fb564bab
child 4613 f58ff1827763
equal deleted inserted replaced
4609:e78287f80074 4611:445d382cd401
   556         particle:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust);
   556         particle:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust);
   557         if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480)
   557         if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480)
   558         end
   558         end
   559 end;
   559 end;
   560 
   560 
       
   561 procedure doStepSnowflake(Gear: PGear);
       
   562 var xx, yy, px, py: LongInt;
       
   563     move: Boolean;
       
   564     s: PSDL_Surface;
       
   565     p: PLongwordArray;
       
   566 begin
       
   567 if GameTicks and $7 = 0 then
       
   568     begin
       
   569     with Gear^ do
       
   570         begin
       
   571         X:= X + cWindSpeed * 1600 + dX;
       
   572         Y:= Y + dY + cGravity * vobFallSpeed * 8;  // using same value as flakes to try and get similar results
       
   573         xx:= hwRound(X);
       
   574         yy:= hwRound(Y);
       
   575         if vobVelocity <> 0 then
       
   576             begin
       
   577             DirAngle := DirAngle + (Angle / 12500000);
       
   578             if DirAngle < 0 then DirAngle := DirAngle + 360
       
   579             else if 360 < DirAngle then DirAngle := DirAngle - 360;
       
   580             end;
       
   581 
       
   582         inc(Health, 8);
       
   583         if Health > vobFrameTicks then
       
   584             begin
       
   585             dec(Health, vobFrameTicks);
       
   586             inc(Timer);
       
   587             if Timer = vobFramesCount then Timer:= 0
       
   588             end;
       
   589 
       
   590         move:= false;
       
   591     // move back to cloud layer
       
   592         if yy > cWaterLine then move:= true
       
   593         else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] > 255) then
       
   594             begin
       
   595             // we've collided with land. draw some stuff and get back into the clouds
       
   596             move:= true;
       
   597 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
       
   598             Land[yy, xx]:= Land[yy, xx] or lfBasic;
       
   599             if yy > 1 then
       
   600                 begin 
       
   601                 Land[yy-1, xx]:= Land[yy-1, xx] or lfBasic;
       
   602                 if (cWindSpeed * 1600 + dX < _0) and (xx > 1) then
       
   603                     begin
       
   604                     Land[yy-1, xx-1]:= Land[yy-1, xx-1] or lfBasic;
       
   605                     Land[yy, xx-1]:= Land[yy, xx-1] or lfBasic
       
   606                     end
       
   607                 else if xx < LAND_WIDTH then
       
   608                     begin
       
   609                     Land[yy-1, xx+1]:= Land[yy-1, xx+1] or lfBasic;
       
   610                     Land[yy, xx+1]:= Land[yy, xx+1] or lfBasic
       
   611                     end
       
   612                 end;
       
   613             dec(yy,4);
       
   614             dec(xx,2);
       
   615             if (((cReducedQuality and rqBlurryLand) = 0) and 
       
   616                     (xx >= 0) and (xx < LAND_WIDTH-2) and (yy >= 0) and (yy < LAND_HEIGHT)) or
       
   617                (((cReducedQuality and rqBlurryLand) <> 0) and
       
   618                     (xx >= 0) and (xx < (LAND_WIDTH div 2)-2) and (yy >= 0) and (yy < LAND_HEIGHT div 2)) then
       
   619                 begin
       
   620                 s:= SpritesData[sprSnow].Surface;
       
   621                 p:= s^.pixels;
       
   622 
       
   623                 for py:= 0 to Pred(s^.h) do
       
   624                     begin
       
   625                     for px:= 0 to Pred(s^.w) do
       
   626                         begin
       
   627                             if (cReducedQuality and rqBlurryLand) = 0 then
       
   628                                 begin
       
   629                                 if LandPixels[yy + py, xx + py] = 0 then
       
   630                                     LandPixels[yy + py, xx + px]:= p^[px];
       
   631                                 end
       
   632                             else
       
   633                                 if LandPixels[(yy + py) div 2, (xx + px) div 2] = 0 then
       
   634                                     LandPixels[(yy + py) div 2, (xx + px) div 2]:= p^[px];
       
   635 
       
   636                         end;
       
   637                     p:= @(p^[s^.pitch shr 2])
       
   638                     end;
       
   639                 UpdateLandTexture(xx, 4, yy, 4)
       
   640                 end
       
   641 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
       
   642             end;
       
   643         if move then
       
   644             begin
       
   645             X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512);
       
   646             Y:= int2hwFloat(1000+(GetRandom(25)-50))
       
   647             end
       
   648         end
       
   649     end
       
   650 end;
       
   651 
   561 ////////////////////////////////////////////////////////////////////////////////
   652 ////////////////////////////////////////////////////////////////////////////////
   562 procedure doStepGrave(Gear: PGear);
   653 procedure doStepGrave(Gear: PGear);
   563 begin
   654 begin
   564     AllInactive := false;
   655     AllInactive := false;
   565     if Gear^.dY.isNegative then
   656     if Gear^.dY.isNegative then