hedgewars/uGears.pas
changeset 2204 526f8165acce
parent 2186 5ec3e4a03d51
child 2208 7d1a084d11ab
equal deleted inserted replaced
2203:6bd39d75e0dd 2204:526f8165acce
    27 	TGearStepProcedure = procedure (Gear: PGear);
    27 	TGearStepProcedure = procedure (Gear: PGear);
    28 	TGear = record
    28 	TGear = record
    29 			NextGear, PrevGear: PGear;
    29 			NextGear, PrevGear: PGear;
    30 			Active: Boolean;
    30 			Active: Boolean;
    31 			Invulnerable: Boolean;
    31 			Invulnerable: Boolean;
       
    32 			RenderTimer: Boolean;
    32 			Ammo : PAmmo;
    33 			Ammo : PAmmo;
    33 			State : Longword;
    34 			State : Longword;
    34 			X : hwFloat;
    35 			X : hwFloat;
    35 			Y : hwFloat;
    36 			Y : hwFloat;
    36 			dX: hwFloat;
    37 			dX: hwFloat;
   234    gtAmmo_Bomb,
   235    gtAmmo_Bomb,
   235  gtClusterBomb: begin
   236  gtClusterBomb: begin
   236                 Result^.Radius:= 4;
   237                 Result^.Radius:= 4;
   237                 Result^.Elasticity:= _0_6;
   238                 Result^.Elasticity:= _0_6;
   238                 Result^.Friction:= _0_96;
   239                 Result^.Friction:= _0_96;
       
   240                 Result^.RenderTimer:= true
   239                 end;
   241                 end;
   240   gtWatermelon: begin
   242   gtWatermelon: begin
   241                 Result^.Radius:= 4;
   243                 Result^.Radius:= 4;
   242                 Result^.Elasticity:= _0_8;
   244                 Result^.Elasticity:= _0_8;
   243                 Result^.Friction:= _0_995;
   245                 Result^.Friction:= _0_995;
       
   246                 Result^.RenderTimer:= true
   244                 end;
   247                 end;
   245     gtHedgehog: begin
   248     gtHedgehog: begin
   246                 Result^.Radius:= cHHRadius;
   249                 Result^.Radius:= cHHRadius;
   247                 Result^.Elasticity:= _0_35;
   250                 Result^.Elasticity:= _0_35;
   248                 Result^.Friction:= _0_999;
   251                 Result^.Friction:= _0_999;
   249                 Result^.Angle:= cMaxAngle div 2;
   252                 Result^.Angle:= cMaxAngle div 2;
   250                 Result^.Z:= cHHZ;
   253                 Result^.Z:= cHHZ;
   251                 end;
   254                 end;
   252 gtAmmo_Grenade: begin
   255 gtAmmo_Grenade: begin
   253                 Result^.Radius:= 4;
   256                 Result^.Radius:= 4;
       
   257                 Result^.RenderTimer:= true
   254                 end;
   258                 end;
   255    gtHealthTag: begin
   259    gtHealthTag: begin
   256                 Result^.Timer:= 1500;
   260                 Result^.Timer:= 1500;
   257                 Result^.Z:= 2002;
   261                 Result^.Z:= 2002;
   258                 end;
   262                 end;
   261                 Result^.Elasticity:= _0_6;
   265                 Result^.Elasticity:= _0_6;
   262                 end;
   266                 end;
   263          gtUFO: begin
   267          gtUFO: begin
   264                 Result^.Radius:= 5;
   268                 Result^.Radius:= 5;
   265                 Result^.Timer:= 500;
   269                 Result^.Timer:= 500;
       
   270                 Result^.RenderTimer:= true;
   266                 Result^.Elasticity:= _0_9
   271                 Result^.Elasticity:= _0_9
   267                 end;
   272                 end;
   268  gtShotgunShot: begin
   273  gtShotgunShot: begin
   269                 Result^.Timer:= 900;
   274                 Result^.Timer:= 900;
   270                 Result^.Radius:= 2
   275                 Result^.Radius:= 2
   315                 Result^.Radius:= 3;
   320                 Result^.Radius:= 3;
   316                 Result^.Elasticity:= _0_55;
   321                 Result^.Elasticity:= _0_55;
   317                 Result^.Friction:= _0_03;
   322                 Result^.Friction:= _0_03;
   318                 Result^.Timer:= 5000;
   323                 Result^.Timer:= 5000;
   319                 end;
   324                 end;
   320      gtCluster: Result^.Radius:= 2;
   325      gtCluster: begin
       
   326                 Result^.Radius:= 2;
       
   327                 Result^.RenderTimer:= true
       
   328                 end;
   321       gtShover: Result^.Radius:= 20;
   329       gtShover: Result^.Radius:= 20;
   322        gtFlame: begin
   330        gtFlame: begin
   323                 Result^.Tag:= Counter mod 32;
   331                 Result^.Tag:= Counter mod 32;
   324                 Result^.Radius:= 1;
   332                 Result^.Radius:= 1;
   325                 Result^.Health:= 5;
   333                 Result^.Health:= 5;
   337                 Result^.Radius:= 5;
   345                 Result^.Radius:= 5;
   338                 end;
   346                 end;
   339    gtBlowTorch: begin
   347    gtBlowTorch: begin
   340                 Result^.Radius:= cHHRadius + cBlowTorchC;
   348                 Result^.Radius:= cHHRadius + cBlowTorchC;
   341                 Result^.Timer:= 7500;
   349                 Result^.Timer:= 7500;
       
   350                 Result^.RenderTimer:= true
   342                 end;
   351                 end;
   343     gtSwitcher: begin
   352     gtSwitcher: begin
   344                 Result^.Z:= cCurrHHZ
   353                 Result^.Z:= cCurrHHZ
   345                 end;
   354                 end;
   346       gtTarget: begin
   355       gtTarget: begin
   359                 end;
   368                 end;
   360         gtCake: begin
   369         gtCake: begin
   361                 Result^.Health:= 2048;
   370                 Result^.Health:= 2048;
   362                 Result^.Radius:= 7;
   371                 Result^.Radius:= 7;
   363                 Result^.Z:= cOnHHZ;
   372                 Result^.Z:= cOnHHZ;
       
   373                 Result^.RenderTimer:= true;
   364                 if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3
   374                 if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3
   365                 end;
   375                 end;
   366  gtHellishBomb: begin
   376  gtHellishBomb: begin
   367                 Result^.Radius:= 4;
   377                 Result^.Radius:= 4;
   368                 Result^.Elasticity:= _0_5;
   378                 Result^.Elasticity:= _0_5;
   369                 Result^.Friction:= _0_96;
   379                 Result^.Friction:= _0_96;
       
   380                 Result^.RenderTimer:= true
   370                 end;
   381                 end;
   371        gtDrill: begin
   382        gtDrill: begin
   372                 Result^.Timer:= 5000;
   383                 Result^.Timer:= 5000;
   373                 Result^.Radius:= 4;
   384                 Result^.Radius:= 4;
       
   385                 Result^.RenderTimer:= true
   374                 end;
   386                 end;
   375         gtBall: begin
   387         gtBall: begin
   376                 Result^.Radius:= 5;
   388                 Result^.Radius:= 5;
   377                 Result^.Tag:= random(8);
   389                 Result^.Tag:= random(8);
   378                 Result^.Timer:= 5000;
   390                 Result^.Timer:= 5000;
   383                 Result^.Timer:= 5001;
   395                 Result^.Timer:= 5001;
   384                 end;
   396                 end;
   385      gtRCPlane: begin
   397      gtRCPlane: begin
   386                 Result^.Timer:= 15000;
   398                 Result^.Timer:= 15000;
   387                 Result^.Health:= 3;
   399                 Result^.Health:= 3;
   388                 Result^.Radius:= 8;
   400                 Result^.Radius:= 8
   389                 end;
   401                 end;
   390      gtJetpack: begin
   402      gtJetpack: begin
   391                 Result^.Health:= 2000;
   403                 Result^.Health:= 2000;
   392                 end;
   404                 end;
   393      end;
   405      end;
   513 t:= GearsList;
   525 t:= GearsList;
   514 while t <> nil do
   526 while t <> nil do
   515 	begin
   527 	begin
   516 	Gear:= t;
   528 	Gear:= t;
   517 	t:= Gear^.NextGear;
   529 	t:= Gear^.NextGear;
   518 	if Gear^.Active then Gear^.doStep(Gear);
   530 	if Gear^.Active then 
       
   531         begin
       
   532         if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then
       
   533             begin
       
   534             if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); 
       
   535             Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), $FFFFFFFF, fntSmall);
       
   536             end;
       
   537         Gear^.doStep(Gear);
       
   538         end
   519 	end;
   539 	end;
   520 
   540 
   521 if AllInactive then
   541 if AllInactive then
   522 case step of
   542 case step of
   523 	stDelay: begin
   543 	stDelay: begin
  1178             gtJetpack: begin
  1198             gtJetpack: begin
  1179 	                   DrawSprite(sprJetpack, sx-32, sy-32, 0);
  1199 	                   DrawSprite(sprJetpack, sx-32, sy-32, 0);
  1180 	                   if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1);
  1200 	                   if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1);
  1181 	                   if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2);
  1201 	                   if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2);
  1182 	                   if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3);
  1202 	                   if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3);
       
  1203                        if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex)
  1183                        end;
  1204                        end;
  1184             end;
  1205             end;
  1185         end
  1206         end
  1186     end;
  1207     end;
  1187 
  1208 
  1396       gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle);
  1417       gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle);
  1397       gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle);
  1418       gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle);
  1398      gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1419      gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1399       gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
  1420       gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
  1400          end;
  1421          end;
       
  1422       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(hwRound(Gear^.X) + 8 + WorldDx, hwRound(Gear^.Y) + 8 + WorldDy, Gear^.Tex);
  1401       Gear:= Gear^.NextGear
  1423       Gear:= Gear^.NextGear
  1402       end;
  1424       end;
  1403 end;
  1425 end;
  1404 
  1426 
  1405 procedure FreeGearsList;
  1427 procedure FreeGearsList;