hedgewars/uVisualGears.pas
changeset 3032 9c190d3c165b
parent 2986 c0c91cd3f423
child 3038 4e48c276a468
equal deleted inserted replaced
3031:542444bfe37d 3032:9c190d3c165b
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uVisualGears;
    21 unit uVisualGears;
    22 interface
    22 interface
    23 uses SDLh, uConsts, uFloat,
    23 uses SDLh, uConsts, uFloat, Math,
    24 {$IFDEF GLES11}
    24 {$IFDEF GLES11}
    25     gles11;
    25     gles11;
    26 {$ELSE}
    26 {$ELSE}
    27     GL;
    27     GL;
    28 {$ENDIF}
    28 {$ENDIF}
   300     DeleteVisualGear(Gear);
   300     DeleteVisualGear(Gear);
   301     PlaySound(TSound(ord(sndDroplet1) + Random(3)));
   301     PlaySound(TSound(ord(sndDroplet1) + Random(3)));
   302     end;
   302     end;
   303 end;
   303 end;
   304 
   304 
       
   305 procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword);
       
   306 begin
       
   307 inc(Gear^.Timer, Steps);
       
   308 if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear)
       
   309 else
       
   310     begin
       
   311     Gear^.scale := 1.25 * (-power(2, -7 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4;
       
   312     Gear^.alpha := 1.0 * (power(2, -3 * (Gear^.Timer - 350)/350));
       
   313     end;
       
   314 end;
       
   315 
   305 ////////////////////////////////////////////////////////////////////////////////
   316 ////////////////////////////////////////////////////////////////////////////////
   306 const cSorterWorkTime = 640;
   317 const cSorterWorkTime = 640;
   307 var thexchar: array[0..cMaxTeams] of
   318 var thexchar: array[0..cMaxTeams] of
   308             record
   319             record
   309             dy, ny, dw: LongInt;
   320             dy, ny, dw: LongInt;
   439             @doStepSmoke,
   450             @doStepSmoke,
   440             @doStepHealth,
   451             @doStepHealth,
   441             @doStepShell,
   452             @doStepShell,
   442             @doStepDust,
   453             @doStepDust,
   443             @doStepSplash,
   454             @doStepSplash,
   444             @doStepDroplet
   455             @doStepDroplet,
       
   456             @doStepSmokeRing
   445         );
   457         );
   446 
   458 
   447 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   459 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   448 var gear: PVisualGear;
   460 var gear: PVisualGear;
   449     t: Longword;
   461     t: Longword;
   575                 dx.isNegative:= random(2) = 0;
   587                 dx.isNegative:= random(2) = 0;
   576                 dy:= _0_001 * (random(80) + 120);
   588                 dy:= _0_001 * (random(80) + 120);
   577                 dy.isNegative:= true;
   589                 dy.isNegative:= true;
   578                 FrameTicks:= 250 + random(1751);
   590                 FrameTicks:= 250 + random(1751);
   579                 Frame:= random(3)
   591                 Frame:= random(3)
       
   592                 end;
       
   593     vgtSmokeRing: begin
       
   594                 dx:= _0;
       
   595                 dx.isNegative:= false;
       
   596                 dy:= _0;
       
   597                 dy.isNegative:= false;
       
   598                 FrameTicks:= 600;
       
   599                 Timer:= 0;
       
   600                 Frame:= 0;
       
   601                 scale:= 0.6;
       
   602                 alpha:= 1;
       
   603                 angle:= random(360);
   580                 end;
   604                 end;
   581         end;
   605         end;
   582 
   606 
   583 if VisualGearsList <> nil then
   607 if VisualGearsList <> nil then
   584     begin
   608     begin
   697                             if Gear^.FrameTicks < 250 then
   721                             if Gear^.FrameTicks < 250 then
   698                                 glColor4f(1, 1, 1, 1);
   722                                 glColor4f(1, 1, 1, 1);
   699                             end;
   723                             end;
   700                 vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 64, hwRound(Gear^.Y) + WorldDy - 72, 19 - (Gear^.FrameTicks div 37));
   724                 vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 64, hwRound(Gear^.Y) + WorldDy - 72, 19 - (Gear^.FrameTicks div 37));
   701                 vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
   725                 vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
       
   726                 vgtSmokeRing: begin
       
   727                             glColor4f(1, 1, 1, Gear^.alpha);
       
   728                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
       
   729                             glColor4f(1, 1, 1, 1);
       
   730                             end;
   702             end;
   731             end;
   703         case Gear^.Kind of
   732         case Gear^.Kind of
   704             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   733             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   705             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   734             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   706         end;
   735         end;