Changeset 13 for trunk/UCore.pas
- Timestamp:
- Mar 22, 2011, 5:24:11 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r12 r13 11 11 const 12 12 MaxBulletCount = 10; 13 EnergySteps = 40; 14 ShieldSteps = 40; 15 ExplosionBulletCount = 200; 16 ExplosionRange = 15; 13 EnergySteps = 400; 14 ShieldSteps = 400; 15 ExplosionBulletCount = 100; 16 ExplosionRange = 20; 17 ExplosionBulletMaxSpeed = 0.5; 18 ExplosionBulletMinSpeed = 0.2; 17 19 18 20 type … … 35 37 Shoot: Word; 36 38 end; 39 40 { TBullet } 37 41 38 42 TBullet = class … … 43 47 Distance: Real; 44 48 StopByDirt: Boolean; 49 constructor Create; 45 50 end; 46 51 … … 163 168 end; 164 169 170 { TBullet } 171 172 constructor TBullet.Create; 173 begin 174 MaxDistance := -1; 175 Distance := 0; 176 end; 177 165 178 { TTank } 166 179 … … 352 365 I: Integer; 353 366 Pos: TPoint; 354 begin 367 D: Real; 368 begin 369 // Check energy 370 if not Engine.IsInsideHouses(Position) then begin 371 Energy := Energy - 1 / EnergySteps; 372 if Energy <= 0 then begin 373 Energy := 0; 374 Explosion; 375 end; 376 end else begin 377 Energy := Energy + 5 * 1 / EnergySteps; 378 if Energy > 1 then Energy := 1; 379 end; 380 if LastEnergy <> Energy then begin 381 LastEnergy := Energy; 382 Engine.Redraw; 383 end; 384 385 // Bullet movement 355 386 for I := Bullets.Count - 1 downto 0 do 356 387 with TBullet(Bullets[I]) do begin … … 362 393 Distance := Distance + Sqrt(Sqr(Direction.X) + Sqr(Direction.Y)); 363 394 //ShowMessage(FloatToStr(Distance)); 364 if (Distance > MaxDistance) and (MaxDistance > 0) then begin395 if (Distance > MaxDistance) and (MaxDistance >= 0) then begin 365 396 Bullets.Delete(I); 397 Engine.Redraw; 366 398 Continue; 367 399 end; … … 369 401 Pos := Point(Trunc(Position.X), Trunc(Position.Y)); 370 402 371 if Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] <> Byte(smNothing) then begin 403 if (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] <> Byte(smNothing)) and 404 (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] <> Byte(smBullet)) then begin 372 405 if (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] = Byte(smDirt1)) or 373 406 (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] = Byte(smDirt2)) then begin … … 393 426 end; 394 427 Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] := Byte(smBullet); 395 Engine.Redraw;396 end;397 398 if not Engine.IsInsideHouses(Position) then begin399 Energy := Energy - 1 / EnergySteps;400 if Energy <= 0 then begin401 Energy := 0;402 Explosion;403 end;404 end else begin405 Energy := Energy + 5 * 1 / EnergySteps;406 if Energy > 1 then Energy := 1;407 end;408 if LastEnergy <> Energy then begin409 LastEnergy := Energy;410 428 Engine.Redraw; 411 429 end; … … 521 539 NewBullet: TBullet; 522 540 I: Integer; 523 const 524 BulletMaxSpeed = 1; 525 BulletMinSpeed = 0.5; 541 Speed: Real; 542 Angle: Real; 526 543 begin 527 544 if not Exploded then begin … … 531 548 NewBullet := TBullet.Create; 532 549 NewBullet.Player := Self; 533 NewBullet.Direction.X := (BulletMaxSpeed - BulletMinSpeed) * (Random - 0.5); 534 NewBullet.Direction.Y := (BulletMaxSpeed - BulletMinSpeed) * (Random - 0.5); 535 //NewBullet.Direction.X := NewBullet.Direction.X + BulletMinSpeed * Sign(NewBullet.Direction.X); 536 //NewBullet.Direction.Y := NewBullet.Direction.Y + BulletMinSpeed * Sign(NewBullet.Direction.Y); 537 NewBullet.Position.X := Position.X + NewBullet.Direction.X * 2; 538 NewBullet.Position.Y := Position.Y + NewBullet.Direction.Y * 2; 539 (* if NewBullet.Direction.X < (Speed / 10) then 540 NewBullet.Direction.X := Speed / 10; 541 if NewBullet.Direction.Y < (Speed / 10) then 542 NewBullet.Direction.Y := Speed / 10;*) 550 Speed := ExplosionBulletMinSpeed + (ExplosionBulletMaxSpeed - ExplosionBulletMinSpeed) * Random; 551 Angle := Random * 2 * Pi; 552 NewBullet.Direction.X := Sin(Angle) * Speed; 553 NewBullet.Direction.Y := Cos(Angle) * Speed; 554 NewBullet.Position.X := Position.X + NewBullet.Direction.X * 3; 555 NewBullet.Position.Y := Position.Y + NewBullet.Direction.Y * 3; 543 556 NewBullet.MaxDistance := Random(ExplosionRange); 544 557 Bullets.Add(NewBullet);
Note:
See TracChangeset
for help on using the changeset viewer.