hedgewars/uVisualGears.pas
changeset 2143 ad05f6b2d1c0
parent 2051 949fe7df09b6
child 2146 f70cd51704c1
equal deleted inserted replaced
2142:48ed98cfd119 2143:ad05f6b2d1c0
    57 var VisualGearsList: PVisualGear = nil;
    57 var VisualGearsList: PVisualGear = nil;
    58 	vobFrameTicks, vobFramesCount: Longword;
    58 	vobFrameTicks, vobFramesCount: Longword;
    59 	vobVelocity, vobFallSpeed: LongInt;
    59 	vobVelocity, vobFallSpeed: LongInt;
    60 
    60 
    61 implementation
    61 implementation
    62 uses uWorld, uMisc, uStore, uTeams;
    62 uses uWorld, uMisc, uStore, uTeams, uSound;
    63 const cExplFrameTicks = 110;
    63 const cExplFrameTicks = 110;
    64 
    64 
    65 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
    65 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
    66 var s: shortstring;
    66 var s: shortstring;
    67 	Gear: PVisualGear;
    67 	Gear: PVisualGear;
   138 		end
   138 		end
   139 	else dec(Gear^.FrameTicks, Steps)
   139 	else dec(Gear^.FrameTicks, Steps)
   140 end;
   140 end;
   141 
   141 
   142 procedure doStepFire(Gear: PVisualGear; Steps: Longword);
   142 procedure doStepFire(Gear: PVisualGear; Steps: Longword);
       
   143 var i: Integer;
   143 begin
   144 begin
   144 Gear^.X:= Gear^.X + Gear^.dX * Steps;
   145 Gear^.X:= Gear^.X + Gear^.dX * Steps;
   145 
   146 
   146 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravity * (Steps * Steps);
   147 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravity * (Steps * Steps);
   147 Gear^.dY:= Gear^.dY + cGravity * Steps;
   148 Gear^.dY:= Gear^.dY + cGravity * Steps;
       
   149 
       
   150 if (Gear^.FrameTicks <= Steps) or (hwRound(Gear^.Y) > cWaterLine) then
       
   151 	begin
       
   152 	if hwRound(Gear^.Y) > cWaterLine then for i:= 0 to 3 do
       
   153 		begin
       
   154 		AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam);
       
   155 		PlaySound(sndVaporize, false, nil);
       
   156 		end;
       
   157 	DeleteVisualGear(Gear);
       
   158 	end
       
   159 else
       
   160 	dec(Gear^.FrameTicks, Steps)
       
   161 end;
       
   162 
       
   163 procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword);
       
   164 begin
       
   165 Gear^.Y:= Gear^.Y - _0_02 * Steps;
   148 
   166 
   149 if Gear^.FrameTicks <= Steps then
   167 if Gear^.FrameTicks <= Steps then
   150 	DeleteVisualGear(Gear)
   168 	DeleteVisualGear(Gear)
   151 else
   169 else
   152 	dec(Gear^.FrameTicks, Steps)
   170 	dec(Gear^.FrameTicks, Steps)
   153 end;
   171 end;
   154 
   172 
   155 procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword);
   173 procedure doStepBubble(Gear: PVisualGear; Steps: Longword);
   156 begin
   174 begin
   157 Gear^.Y:= Gear^.Y - _0_02 * Steps;
   175 	Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps;
   158 
   176 	Gear^.Y:= Gear^.Y - cDrownSpeed * Steps;
   159 if Gear^.FrameTicks <= Steps then
   177 	
   160 	DeleteVisualGear(Gear)
   178 	if (Gear^.FrameTicks <= Steps) or (hwRound(Gear^.Y) < cWaterLine) then
   161 else
   179 		DeleteVisualGear(Gear)
   162 	dec(Gear^.FrameTicks, Steps)
   180 	else
       
   181 		dec(Gear^.FrameTicks, Steps)
       
   182 end;
       
   183 
       
   184 procedure doStepSteam(Gear: PVisualGear; Steps: Longword);
       
   185 begin
       
   186 	Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps;
       
   187 	Gear^.Y:= Gear^.Y - cDrownSpeed * Steps;
       
   188 
       
   189 	if Gear^.FrameTicks <= Steps then
       
   190 		if Gear^.Frame = 0 then DeleteVisualGear(Gear)
       
   191 		else
       
   192 			begin
       
   193 			if Random(2) = 0 then dec(Gear^.Frame);
       
   194 			Gear^.FrameTicks:= cExplFrameTicks
       
   195 			end
       
   196 		else dec(Gear^.FrameTicks, Steps)
   163 end;
   197 end;
   164 
   198 
   165 ////////////////////////////////////////////////////////////////////////////////
   199 ////////////////////////////////////////////////////////////////////////////////
   166 const cSorterWorkTime = 640;
   200 const cSorterWorkTime = 640;
   167 var thexchar: array[0..cMaxTeams] of
   201 var thexchar: array[0..cMaxTeams] of
   289 			@doStepExpl,
   323 			@doStepExpl,
   290 			@doStepExpl,
   324 			@doStepExpl,
   291 			@doStepFire,
   325 			@doStepFire,
   292 			@doStepSmallDamage,
   326 			@doStepSmallDamage,
   293 			@doStepTeamHealthSorter,
   327 			@doStepTeamHealthSorter,
   294 			@doStepSpeechBubble
   328 			@doStepSpeechBubble,
       
   329 			@doStepBubble,
       
   330 			@doStepSteam
   295 		);
   331 		);
   296 
   332 
   297 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   333 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   298 var Result: PVisualGear;
   334 var Result: PVisualGear;
   299 	t: Longword;
   335 	t: Longword;
   364 				Frame:= random(8)
   400 				Frame:= random(8)
   365 				end;
   401 				end;
   366 	vgtSmallDamageTag: begin
   402 	vgtSmallDamageTag: begin
   367 				Result^.FrameTicks:= 1100
   403 				Result^.FrameTicks:= 1100
   368 				end;
   404 				end;
       
   405 	vgtBubble: begin
       
   406 				t:= random(1024);
       
   407 				sp:= _0_001 * (random(85) + 95);
       
   408 				dx.isNegative:= random(2) = 0;
       
   409 				dx.QWordValue:= random(100000000);
       
   410 				dy:= sp;
       
   411 				dy.isNegative:= false;
       
   412 				FrameTicks:= 250 + random(1751);
       
   413 				Frame:= random(5)
       
   414 				end;
       
   415 	vgtSteam: begin
       
   416 				t:= random(1024);
       
   417 				sp:= _0_001 * (random(95) + 70);
       
   418 				dx.isNegative:= random(2) = 0;
       
   419 				dx.QWordValue:= random(100000000);
       
   420 				dy:= sp;
       
   421 				dy.isNegative:= false;
       
   422 				Frame:= 7 - random(3);
       
   423 				FrameTicks:= cExplFrameTicks * 2;
       
   424 				end;
   369 		end;
   425 		end;
   370 
   426 
   371 if VisualGearsList <> nil then
   427 if VisualGearsList <> nil then
   372 	begin
   428 	begin
   373 	VisualGearsList^.PrevGear:= Result;
   429 	VisualGearsList^.PrevGear:= Result;
   425         if not cReducedQuality then
   481         if not cReducedQuality then
   426             case Gear^.Kind of
   482             case Gear^.Kind of
   427                 vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
   483                 vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
   428                 vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
   484                 vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
   429                 vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
   485                 vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
       
   486 				vgtBubble: DrawSprite(sprBubbles, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
       
   487 				vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
   430             end;
   488             end;
   431         case Gear^.Kind of
   489         case Gear^.Kind of
   432             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   490             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   433             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   491             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   434         end;
   492         end;