Changeset 12
- Timestamp:
- Mar 21, 2011, 10:13:45 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r11 r12 11 11 const 12 12 MaxBulletCount = 10; 13 EnergySteps = 40 00;13 EnergySteps = 40; 14 14 ShieldSteps = 40; 15 ExplosionBulletCount = 200; 16 ExplosionRange = 15; 15 17 16 18 type … … 21 23 smPlayer1H, smPlayer1L, smPlayer2H, smPlayer2L, 22 24 smPlayer3H, smPlayer3L, smPlayer4H, smPlayer4L); 25 26 TRealPoint = record 27 X, Y: Real; 28 end; 23 29 24 30 TPlayerKeys = record … … 32 38 TBullet = class 33 39 Player: TPlayer; 34 Position: TPoint; 35 Direction: Integer; 40 Position: TRealPoint; 41 Direction: TRealPoint; 42 MaxDistance: Integer; 43 Distance: Real; 44 StopByDirt: Boolean; 36 45 end; 37 46 … … 68 77 Shield: Real; 69 78 House: TRectangle; 70 procedure BlowUp; 79 Exploded: Boolean; 80 procedure Init; 81 procedure Explosion; 71 82 procedure Control; 83 procedure Tick; 72 84 procedure Paint; 73 85 procedure PlaceHouse; … … 287 299 NewBullet: TBullet; 288 300 I: Integer; 289 begin 301 Pos: TPoint; 302 begin 303 if Exploded then Exit; 304 290 305 Delta.X := 0; 291 306 Delta.Y := 0; … … 324 339 NewBullet := TBullet.Create; 325 340 NewBullet.Player := Self; 326 NewBullet.Position := Point(Position.X + DirectionToDelta[Direction].X * 4, 327 Position.Y + DirectionToDelta[Direction].Y * 4); 328 NewBullet.Direction := Direction; 341 NewBullet.Position.X := Position.X + DirectionToDelta[Direction].X * 4; 342 NewBullet.Position.Y := Position.Y + DirectionToDelta[Direction].Y * 4; 343 NewBullet.Direction.X := DirectionToDelta[Direction].X; 344 NewBullet.Direction.Y := DirectionToDelta[Direction].Y; 345 NewBullet.StopByDirt := True; 329 346 Bullets.Add(NewBullet); 330 347 end; 331 348 end; 349 350 procedure TPlayer.Tick; 351 var 352 I: Integer; 353 Pos: TPoint; 354 begin 332 355 for I := Bullets.Count - 1 downto 0 do 333 356 with TBullet(Bullets[I]) do begin 334 Engine.World.Surface.ItemsXY[Position.X, Position.Y] := Byte(smNothing); 335 336 Position.X := Position.X + DirectionToDelta[Direction].X; 337 Position.Y := Position.Y + DirectionToDelta[Direction].Y; 338 339 if Engine.World.Surface.ItemsXY[Position.X, Position.Y] <> Byte(smNothing) then begin 340 if (Engine.World.Surface.ItemsXY[Position.X, Position.Y] = Byte(smDirt1)) or 341 (Engine.World.Surface.ItemsXY[Position.X, Position.Y] = Byte(smDirt2)) then 342 Engine.World.Surface.ItemsXY[Position.X, Position.Y] := Byte(smNothing); 357 Pos := Point(Trunc(Position.X), Trunc(Position.Y)); 358 Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] := Byte(smNothing); 359 360 Position.X := Position.X + Direction.X; 361 Position.Y := Position.Y + Direction.Y; 362 Distance := Distance + Sqrt(Sqr(Direction.X) + Sqr(Direction.Y)); 363 //ShowMessage(FloatToStr(Distance)); 364 if (Distance > MaxDistance) and (MaxDistance > 0) then begin 343 365 Bullets.Delete(I); 344 end else 366 Continue; 367 end; 368 369 Pos := Point(Trunc(Position.X), Trunc(Position.Y)); 370 371 if Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] <> Byte(smNothing) then begin 372 if (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] = Byte(smDirt1)) or 373 (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] = Byte(smDirt2)) then begin 374 Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] := Byte(smNothing); 375 if StopByDirt then begin 376 Bullets.Delete(I); 377 Engine.Redraw; 378 Continue; 379 end; 380 end else begin 381 Bullets.Delete(I); 382 Engine.Redraw; 383 Continue; 384 end; 385 end; 386 345 387 with Engine.World.Surface do 346 if (Position.X >= Count.X) or (Position.X < 0) or 347 (Position.Y >= Count.Y) or (Position.Y < 0) then 348 Bullets.Delete(I) else 349 Engine.World.Surface.ItemsXY[Position.X, Position.Y] := Byte(smBullet); 388 if (Pos.X >= Count.X) or (Pos.X < 0) or 389 (Pos.Y >= Count.Y) or (Pos.Y < 0) then begin 390 Bullets.Delete(I); 391 Engine.Redraw; 392 Continue; 393 end; 394 Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] := Byte(smBullet); 350 395 Engine.Redraw; 351 396 end; … … 355 400 if Energy <= 0 then begin 356 401 Energy := 0; 357 BlowUp;402 Explosion; 358 403 end; 359 404 end else begin … … 460 505 end; 461 506 462 procedure TPlayer.BlowUp; 463 begin 464 507 procedure TPlayer.Init; 508 begin 509 with Engine do 510 Position := Point(Round(World.Surface.Count.X * 0.2) + Random(Round(World.Surface.Count.X * 0.6)), 511 Round(World.Surface.Count.Y * 0.2) + Random(Round(World.Surface.Count.Y * 0.6))); 512 Exploded := False; 513 Bullets.Clear; 514 Energy := 1; 515 Shield := 1; 516 PlaceHouse; 517 end; 518 519 procedure TPlayer.Explosion; 520 var 521 NewBullet: TBullet; 522 I: Integer; 523 const 524 BulletMaxSpeed = 1; 525 BulletMinSpeed = 0.5; 526 begin 527 if not Exploded then begin 528 Exploded := True; 529 HideTank; 530 for I := 0 to ExplosionBulletCount - 1 do begin 531 NewBullet := TBullet.Create; 532 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;*) 543 NewBullet.MaxDistance := Random(ExplosionRange); 544 Bullets.Add(NewBullet); 545 end; 546 end; 465 547 end; 466 548 … … 681 763 for I := 0 to Players.Count - 1 do begin 682 764 TPlayer(Players[I]).Control; 765 TPlayer(Players[I]).Tick; 683 766 end; 684 767 end; … … 788 871 for I := 0 to Players.Count - 1 do 789 872 with TPlayer(Players[I]) do 790 begin 791 // Reset position 792 Position := Point(Round(World.Surface.Count.X * 0.2) + Random(Round(World.Surface.Count.X * 0.6)), 793 Round(World.Surface.Count.Y * 0.2) + Random(Round(World.Surface.Count.Y * 0.6))); 794 795 Energy := 1; 796 Shield := 1; 797 PlaceHouse; 798 end; 873 Init; 799 874 Redraw; 800 875 end; -
trunk/tunneler.lpi
r11 r12 49 49 <WindowIndex Value="0"/> 50 50 <TopLine Value="1"/> 51 <CursorPos X=" 62" Y="19"/>52 <UsageCount Value="7 7"/>51 <CursorPos X="15" Y="4"/> 52 <UsageCount Value="78"/> 53 53 </Unit0> 54 54 <Unit1> … … 58 58 <ResourceBaseClass Value="Form"/> 59 59 <UnitName Value="UMainForm"/> 60 <EditorIndex Value=" 6"/>60 <EditorIndex Value="8"/> 61 61 <WindowIndex Value="0"/> 62 62 <TopLine Value="96"/> 63 63 <CursorPos X="6" Y="101"/> 64 <UsageCount Value="7 7"/>64 <UsageCount Value="78"/> 65 65 <Loaded Value="True"/> 66 66 <LoadedDesigner Value="True"/> … … 73 73 <EditorIndex Value="0"/> 74 74 <WindowIndex Value="0"/> 75 <TopLine Value=" 1"/>76 <CursorPos X=" 19" Y="13"/>77 <UsageCount Value="7 7"/>75 <TopLine Value="518"/> 76 <CursorPos X="9" Y="535"/> 77 <UsageCount Value="78"/> 78 78 <Loaded Value="True"/> 79 79 </Unit2> … … 104 104 <Unit6> 105 105 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/objpas/classes/classesh.inc"/> 106 <WindowIndex Value="0"/> 107 <TopLine Value="1769"/> 108 <CursorPos X="10" Y="1786"/> 109 <UsageCount Value="10"/> 106 <EditorIndex Value="2"/> 107 <WindowIndex Value="0"/> 108 <TopLine Value="19"/> 109 <CursorPos X="4" Y="36"/> 110 <UsageCount Value="11"/> 111 <Loaded Value="True"/> 110 112 </Unit6> 111 113 <Unit7> … … 141 143 <Unit11> 142 144 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/> 143 <WindowIndex Value="0"/> 144 <TopLine Value="141"/> 145 <CursorPos X="1" Y="158"/> 145 <EditorIndex Value="1"/> 146 <WindowIndex Value="0"/> 147 <TopLine Value="157"/> 148 <CursorPos X="44" Y="171"/> 146 149 <UsageCount Value="31"/> 150 <Loaded Value="True"/> 147 151 </Unit11> 148 152 <Unit12> … … 261 265 <ResourceBaseClass Value="Form"/> 262 266 <UnitName Value="UMapForm"/> 263 <EditorIndex Value=" 5"/>267 <EditorIndex Value="7"/> 264 268 <WindowIndex Value="0"/> 265 269 <TopLine Value="1"/> 266 270 <CursorPos X="20" Y="39"/> 267 <UsageCount Value="5 6"/>271 <UsageCount Value="57"/> 268 272 <Loaded Value="True"/> 269 273 </Unit27> … … 299 303 <Filename Value="../../../lazarus/lcl/intfgraphics.pas"/> 300 304 <UnitName Value="IntfGraphics"/> 301 <EditorIndex Value=" 4"/>305 <EditorIndex Value="6"/> 302 306 <WindowIndex Value="0"/> 303 307 <TopLine Value="3131"/> 304 308 <CursorPos X="42" Y="3148"/> 305 <UsageCount Value="1 3"/>309 <UsageCount Value="14"/> 306 310 <Loaded Value="True"/> 307 311 </Unit32> … … 331 335 <Unit36> 332 336 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericBitmap.inc"/> 333 <EditorIndex Value=" 2"/>337 <EditorIndex Value="4"/> 334 338 <WindowIndex Value="0"/> 335 339 <TopLine Value="25"/> 336 340 <CursorPos X="14" Y="25"/> 337 <UsageCount Value="1 7"/>341 <UsageCount Value="18"/> 338 342 <Loaded Value="True"/> 339 343 </Unit36> … … 396 400 <IsPartOfProject Value="True"/> 397 401 <UnitName Value="UPlatform"/> 398 <UsageCount Value="3 6"/>402 <UsageCount Value="37"/> 399 403 </Unit44> 400 404 <Unit45> … … 424 428 <Unit48> 425 429 <Filename Value="../../../lazarus/lcl/include/custombitmap.inc"/> 426 <EditorIndex Value=" 3"/>430 <EditorIndex Value="5"/> 427 431 <WindowIndex Value="0"/> 428 432 <TopLine Value="330"/> 429 433 <CursorPos X="35" Y="338"/> 430 <UsageCount Value="1 3"/>434 <UsageCount Value="14"/> 431 435 <Loaded Value="True"/> 432 436 </Unit48> … … 443 447 <IsPartOfProject Value="True"/> 444 448 <UnitName Value="URectangle"/> 445 <EditorIndex Value=" 1"/>449 <EditorIndex Value="3"/> 446 450 <WindowIndex Value="0"/> 447 451 <TopLine Value="120"/> 448 452 <CursorPos X="44" Y="150"/> 449 <UsageCount Value="2 1"/>453 <UsageCount Value="22"/> 450 454 <Loaded Value="True"/> 451 455 </Unit50> 452 456 </Units> 453 <JumpHistory Count="30" HistoryIndex="2 9">457 <JumpHistory Count="30" HistoryIndex="28"> 454 458 <Position1> 455 459 <Filename Value="UCore.pas"/> 456 <Caret Line=" 466" Column="1" TopLine="452"/>460 <Caret Line="348" Column="1" TopLine="331"/> 457 461 </Position1> 458 462 <Position2> 459 463 <Filename Value="UCore.pas"/> 460 <Caret Line="3 73" Column="19" TopLine="361"/>464 <Caret Line="349" Column="1" TopLine="331"/> 461 465 </Position2> 462 466 <Position3> 463 467 <Filename Value="UCore.pas"/> 464 <Caret Line=" 561" Column="19" TopLine="551"/>468 <Caret Line="336" Column="35" TopLine="321"/> 465 469 </Position3> 466 470 <Position4> 467 471 <Filename Value="UCore.pas"/> 468 <Caret Line="3 85" Column="82" TopLine="364"/>472 <Caret Line="334" Column="1" TopLine="321"/> 469 473 </Position4> 470 474 <Position5> 471 475 <Filename Value="UCore.pas"/> 472 <Caret Line="3 86" Column="1" TopLine="371"/>476 <Caret Line="335" Column="1" TopLine="321"/> 473 477 </Position5> 474 478 <Position6> 475 479 <Filename Value="UCore.pas"/> 476 <Caret Line="3 46" Column="38" TopLine="331"/>480 <Caret Line="336" Column="1" TopLine="321"/> 477 481 </Position6> 478 482 <Position7> 479 483 <Filename Value="UCore.pas"/> 480 <Caret Line="3 52" Column="1" TopLine="331"/>484 <Caret Line="337" Column="1" TopLine="321"/> 481 485 </Position7> 482 486 <Position8> 483 487 <Filename Value="UCore.pas"/> 484 <Caret Line="3 56" Column="1" TopLine="331"/>488 <Caret Line="338" Column="1" TopLine="321"/> 485 489 </Position8> 486 490 <Position9> 487 491 <Filename Value="UCore.pas"/> 488 <Caret Line="3 52" Column="1" TopLine="331"/>492 <Caret Line="339" Column="1" TopLine="321"/> 489 493 </Position9> 490 494 <Position10> 491 495 <Filename Value="UCore.pas"/> 492 <Caret Line=" 616" Column="1" TopLine="599"/>496 <Caret Line="340" Column="1" TopLine="321"/> 493 497 </Position10> 494 498 <Position11> 495 499 <Filename Value="UCore.pas"/> 496 <Caret Line=" 617" Column="1" TopLine="599"/>500 <Caret Line="343" Column="1" TopLine="321"/> 497 501 </Position11> 498 502 <Position12> 499 503 <Filename Value="UCore.pas"/> 500 <Caret Line=" 620" Column="1" TopLine="599"/>504 <Caret Line="344" Column="1" TopLine="321"/> 501 505 </Position12> 502 506 <Position13> 503 507 <Filename Value="UCore.pas"/> 504 <Caret Line="3 52" Column="10" TopLine="335"/>508 <Caret Line="345" Column="1" TopLine="321"/> 505 509 </Position13> 506 510 <Position14> 507 511 <Filename Value="UCore.pas"/> 508 <Caret Line="3 53" Column="14" TopLine="336"/>512 <Caret Line="346" Column="1" TopLine="321"/> 509 513 </Position14> 510 514 <Position15> 511 515 <Filename Value="UCore.pas"/> 512 <Caret Line="3 56" Column="17" TopLine="339"/>516 <Caret Line="348" Column="1" TopLine="321"/> 513 517 </Position15> 514 518 <Position16> 515 519 <Filename Value="UCore.pas"/> 516 <Caret Line="3 59" Column="22" TopLine="339"/>520 <Caret Line="349" Column="1" TopLine="321"/> 517 521 </Position16> 518 522 <Position17> 519 523 <Filename Value="UCore.pas"/> 520 <Caret Line="35 8" Column="1" TopLine="333"/>524 <Caret Line="350" Column="1" TopLine="322"/> 521 525 </Position17> 522 526 <Position18> 523 527 <Filename Value="UCore.pas"/> 524 <Caret Line="35 4" Column="1" TopLine="333"/>528 <Caret Line="351" Column="39" TopLine="324"/> 525 529 </Position18> 526 530 <Position19> 527 531 <Filename Value="UCore.pas"/> 528 <Caret Line="3 55" Column="1" TopLine="333"/>532 <Caret Line="334" Column="1" TopLine="324"/> 529 533 </Position19> 530 534 <Position20> 531 535 <Filename Value="UCore.pas"/> 532 <Caret Line="3 56" Column="1" TopLine="333"/>536 <Caret Line="378" Column="9" TopLine="364"/> 533 537 </Position20> 534 538 <Position21> 535 539 <Filename Value="UCore.pas"/> 536 <Caret Line=" 357" Column="1" TopLine="333"/>540 <Caret Line="81" Column="20" TopLine="63"/> 537 541 </Position21> 538 542 <Position22> 539 543 <Filename Value="UCore.pas"/> 540 <Caret Line="3 63" Column="1" TopLine="335"/>544 <Caret Line="394" Column="1" TopLine="362"/> 541 545 </Position22> 542 546 <Position23> 543 547 <Filename Value="UCore.pas"/> 544 <Caret Line="3 53" Column="3" TopLine="343"/>548 <Caret Line="349" Column="14" TopLine="332"/> 545 549 </Position23> 546 550 <Position24> 547 551 <Filename Value="UCore.pas"/> 548 <Caret Line=" 354" Column="1" TopLine="343"/>552 <Caret Line="741" Column="27" TopLine="735"/> 549 553 </Position24> 550 554 <Position25> 551 555 <Filename Value="UCore.pas"/> 552 <Caret Line=" 355" Column="1" TopLine="343"/>556 <Caret Line="514" Column="32" TopLine="504"/> 553 557 </Position25> 554 558 <Position26> 555 559 <Filename Value="UCore.pas"/> 556 <Caret Line="3 63" Column="1" TopLine="343"/>560 <Caret Line="344" Column="18" TopLine="328"/> 557 561 </Position26> 558 562 <Position27> 559 563 <Filename Value="UCore.pas"/> 560 <Caret Line="3 64" Column="1" TopLine="343"/>564 <Caret Line="376" Column="22" TopLine="360"/> 561 565 </Position27> 562 566 <Position28> 563 567 <Filename Value="UCore.pas"/> 564 <Caret Line=" 365" Column="1" TopLine="343"/>568 <Caret Line="528" Column="31" TopLine="518"/> 565 569 </Position28> 566 570 <Position29> 567 571 <Filename Value="UCore.pas"/> 568 <Caret Line=" 382" Column="29" TopLine="333"/>572 <Caret Line="530" Column="26" TopLine="518"/> 569 573 </Position29> 570 574 <Position30> 571 575 <Filename Value="UCore.pas"/> 572 <Caret Line=" 390" Column="1" TopLine="373"/>576 <Caret Line="15" Column="27" TopLine="1"/> 573 577 </Position30> 574 578 </JumpHistory>
Note:
See TracChangeset
for help on using the changeset viewer.