Changeset 14
- Timestamp:
- Mar 22, 2011, 6:35:54 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r13 r14 113 113 end; 114 114 115 { TKeyboard } 116 117 TKeyboard = class 118 KeyState: array[0..High(Word)] of Boolean; 119 procedure ClearAll; 120 end; 121 115 122 { TEngine } 116 123 … … 127 134 function IsInsideHouses(Pos: TPoint): Boolean; 128 135 public 129 Key State: array[0..High(Word)] of Boolean;136 Keyboard: TKeyboard; 130 137 World: TWorld; 131 138 Players: TObjectList; // <TPlayer> … … 166 173 TFastBitmapPixelComponents(Result).R := TFastBitmapPixelComponents(Value).B; 167 174 TFastBitmapPixelComponents(Result).B := TFastBitmapPixelComponents(Value).R; 175 end; 176 177 { TKeyboard } 178 179 procedure TKeyboard.ClearAll; 180 var 181 I: Integer; 182 begin 183 for I := 0 to High(KeyState) do 184 KeyState[I] := False; 168 185 end; 169 186 … … 318 335 Delta.X := 0; 319 336 Delta.Y := 0; 320 if Engine.Key State[Ord(Keys.Down)] then Delta.Y := Delta.Y + 1;321 if Engine.Key State[Ord(Keys.Up)] then Delta.Y := Delta.Y - 1;322 if Engine.Key State[Ord(Keys.Right)] then Delta.X := Delta.X + 1;323 if Engine.Key State[Ord(Keys.Left)] then Delta.X := Delta.X - 1;337 if Engine.KeyBoard.KeyState[Ord(Keys.Down)] then Delta.Y := Delta.Y + 1; 338 if Engine.KeyBoard.KeyState[Ord(Keys.Up)] then Delta.Y := Delta.Y - 1; 339 if Engine.KeyBoard.KeyState[Ord(Keys.Right)] then Delta.X := Delta.X + 1; 340 if Engine.KeyBoard.KeyState[Ord(Keys.Left)] then Delta.X := Delta.X - 1; 324 341 325 342 NewDirection := Direction; … … 348 365 end; 349 366 350 if Engine.Key State[Ord(Keys.Shoot)] then367 if Engine.KeyBoard.KeyState[Ord(Keys.Shoot)] then 351 368 if Bullets.Count < MaxBulletCount then begin 352 369 NewBullet := TBullet.Create; … … 533 550 Shield := 1; 534 551 PlaceHouse; 552 ShowTank; 535 553 end; 536 554 … … 756 774 IntfImage := TLazIntfImage.Create(1, 1); 757 775 Players := TObjectList.Create; 776 Keyboard := TKeyboard.Create; 758 777 World := TWorld.Create; 759 778 World.Engine := Self; … … 766 785 IntfImage.Free; 767 786 Players.Free; 787 Keyboard.Free; 768 788 World.Free; 769 789 inherited Destroy; -
trunk/UMainForm.lfm
r13 r14 9 9 Menu = MainMenu1 10 10 OnCreate = FormCreate 11 OnDeactivate = FormDeactivate 11 12 OnKeyDown = FormKeyDown 12 13 OnKeyUp = FormKeyUp -
trunk/UMainForm.pas
r13 r14 1 1 unit UMainForm; 2 2 3 {$mode objfpc}{$H+}3 {$mode Delphi}{$H+} 4 4 5 5 interface … … 35 35 procedure AShowMapExecute(Sender: TObject); 36 36 procedure FormCreate(Sender: TObject); 37 procedure FormDeactivate(Sender: TObject); 37 38 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 38 39 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); … … 90 91 procedure TMainForm.FormCreate(Sender: TObject); 91 92 begin 93 Application.OnDeactivate := FormDeactivate; 92 94 Randomize; 93 95 DoubleBuffered := True; … … 126 128 Engine.NewGame; 127 129 Image1Resize(Self); 130 end; 131 132 procedure TMainForm.FormDeactivate(Sender: TObject); 133 begin 134 Engine.KeyBoard.ClearAll; 128 135 end; 129 136 … … 173 180 Shift: TShiftState); 174 181 begin 175 Engine.Key State[Key] := True;182 Engine.KeyBoard.KeyState[Key] := True; 176 183 StatusBar1.Panels[0].Text := IntToStr(Key); 177 184 end; … … 180 187 ); 181 188 begin 182 Engine.Key State[Key] := False;189 Engine.KeyBoard.KeyState[Key] := False; 183 190 end; 184 191 -
trunk/tunneler.lpi
r13 r14 42 42 </Item3> 43 43 </RequiredPackages> 44 <Units Count="5 1">44 <Units Count="52"> 45 45 <Unit0> 46 46 <Filename Value="tunneler.lpr"/> … … 50 50 <TopLine Value="1"/> 51 51 <CursorPos X="15" Y="4"/> 52 <UsageCount Value=" 79"/>52 <UsageCount Value="82"/> 53 53 </Unit0> 54 54 <Unit1> … … 58 58 <ResourceBaseClass Value="Form"/> 59 59 <UnitName Value="UMainForm"/> 60 <EditorIndex Value="9"/> 61 <WindowIndex Value="0"/> 62 <TopLine Value="62"/> 63 <CursorPos X="25" Y="78"/> 64 <UsageCount Value="79"/> 60 <IsVisibleTab Value="True"/> 61 <EditorIndex Value="11"/> 62 <WindowIndex Value="0"/> 63 <TopLine Value="19"/> 64 <CursorPos X="1" Y="36"/> 65 <UsageCount Value="82"/> 65 66 <Loaded Value="True"/> 66 67 <LoadedDesigner Value="True"/> … … 70 71 <IsPartOfProject Value="True"/> 71 72 <UnitName Value="UCore"/> 72 <IsVisibleTab Value="True"/>73 73 <EditorIndex Value="0"/> 74 74 <WindowIndex Value="0"/> 75 <TopLine Value=" 1"/>76 <CursorPos X="2 0" Y="14"/>77 <UsageCount Value=" 79"/>75 <TopLine Value="350"/> 76 <CursorPos X="22" Y="367"/> 77 <UsageCount Value="82"/> 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 <EditorIndex Value=" 3"/>106 <EditorIndex Value="5"/> 107 107 <WindowIndex Value="0"/> 108 108 <TopLine Value="19"/> 109 109 <CursorPos X="4" Y="36"/> 110 <UsageCount Value="1 2"/>110 <UsageCount Value="13"/> 111 111 <Loaded Value="True"/> 112 112 </Unit6> … … 143 143 <Unit11> 144 144 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/> 145 <EditorIndex Value=" 2"/>145 <EditorIndex Value="4"/> 146 146 <WindowIndex Value="0"/> 147 147 <TopLine Value="152"/> 148 148 <CursorPos X="1" Y="158"/> 149 <UsageCount Value="3 2"/>149 <UsageCount Value="33"/> 150 150 <Loaded Value="True"/> 151 151 </Unit11> … … 175 175 <Unit15> 176 176 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 177 <WindowIndex Value="0"/> 178 <TopLine Value="473"/> 179 <CursorPos X="1" Y="60"/> 180 <UsageCount Value="21"/> 177 <EditorIndex Value="1"/> 178 <WindowIndex Value="0"/> 179 <TopLine Value="10"/> 180 <CursorPos X="21" Y="13"/> 181 <UsageCount Value="22"/> 182 <Loaded Value="True"/> 181 183 </Unit15> 182 184 <Unit16> … … 265 267 <ResourceBaseClass Value="Form"/> 266 268 <UnitName Value="UMapForm"/> 267 <EditorIndex Value=" 8"/>268 <WindowIndex Value="0"/> 269 <TopLine Value=" 1"/>269 <EditorIndex Value="10"/> 270 <WindowIndex Value="0"/> 271 <TopLine Value="6"/> 270 272 <CursorPos X="20" Y="39"/> 271 <UsageCount Value=" 58"/>273 <UsageCount Value="61"/> 272 274 <Loaded Value="True"/> 273 275 </Unit27> … … 288 290 <Unit30> 289 291 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/inc/mathh.inc"/> 290 <EditorIndex Value=" 1"/>292 <EditorIndex Value="3"/> 291 293 <WindowIndex Value="0"/> 292 294 <TopLine Value="58"/> 293 295 <CursorPos X="14" Y="75"/> 294 <UsageCount Value="1 4"/>296 <UsageCount Value="16"/> 295 297 <Loaded Value="True"/> 296 298 </Unit30> … … 305 307 <Filename Value="../../../lazarus/lcl/intfgraphics.pas"/> 306 308 <UnitName Value="IntfGraphics"/> 307 <EditorIndex Value=" 7"/>309 <EditorIndex Value="9"/> 308 310 <WindowIndex Value="0"/> 309 311 <TopLine Value="3131"/> 310 312 <CursorPos X="42" Y="3148"/> 311 <UsageCount Value="1 5"/>313 <UsageCount Value="16"/> 312 314 <Loaded Value="True"/> 313 315 </Unit32> … … 337 339 <Unit36> 338 340 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericBitmap.inc"/> 339 <EditorIndex Value=" 5"/>341 <EditorIndex Value="7"/> 340 342 <WindowIndex Value="0"/> 341 343 <TopLine Value="25"/> 342 344 <CursorPos X="14" Y="25"/> 343 <UsageCount Value=" 19"/>345 <UsageCount Value="20"/> 344 346 <Loaded Value="True"/> 345 347 </Unit36> … … 402 404 <IsPartOfProject Value="True"/> 403 405 <UnitName Value="UPlatform"/> 404 <UsageCount Value=" 38"/>406 <UsageCount Value="41"/> 405 407 </Unit44> 406 408 <Unit45> … … 430 432 <Unit48> 431 433 <Filename Value="../../../lazarus/lcl/include/custombitmap.inc"/> 432 <EditorIndex Value=" 6"/>434 <EditorIndex Value="8"/> 433 435 <WindowIndex Value="0"/> 434 436 <TopLine Value="330"/> 435 437 <CursorPos X="35" Y="338"/> 436 <UsageCount Value="1 5"/>438 <UsageCount Value="16"/> 437 439 <Loaded Value="True"/> 438 440 </Unit48> … … 449 451 <IsPartOfProject Value="True"/> 450 452 <UnitName Value="URectangle"/> 451 <EditorIndex Value=" 4"/>453 <EditorIndex Value="6"/> 452 454 <WindowIndex Value="0"/> 453 455 <TopLine Value="120"/> 454 456 <CursorPos X="44" Y="150"/> 455 <UsageCount Value="2 3"/>457 <UsageCount Value="26"/> 456 458 <Loaded Value="True"/> 457 459 </Unit50> 460 <Unit51> 461 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/objpas/sysutils/sysstrh.inc"/> 462 <EditorIndex Value="2"/> 463 <WindowIndex Value="0"/> 464 <TopLine Value="147"/> 465 <CursorPos X="10" Y="84"/> 466 <UsageCount Value="11"/> 467 <Loaded Value="True"/> 468 </Unit51> 458 469 </Units> 459 <JumpHistory Count="30" HistoryIndex="2 8">470 <JumpHistory Count="30" HistoryIndex="29"> 460 471 <Position1> 461 472 <Filename Value="UCore.pas"/> 462 <Caret Line="37 5" Column="1" TopLine="354"/>473 <Caret Line="376" Column="1" TopLine="354"/> 463 474 </Position1> 464 475 <Position2> 465 476 <Filename Value="UCore.pas"/> 466 <Caret Line="37 6" Column="1" TopLine="354"/>477 <Caret Line="377" Column="1" TopLine="354"/> 467 478 </Position2> 468 479 <Position3> 469 480 <Filename Value="UCore.pas"/> 470 <Caret Line="37 7" Column="1" TopLine="354"/>481 <Caret Line="379" Column="1" TopLine="354"/> 471 482 </Position3> 472 483 <Position4> 473 484 <Filename Value="UCore.pas"/> 474 <Caret Line="3 79" Column="1" TopLine="354"/>485 <Caret Line="385" Column="1" TopLine="357"/> 475 486 </Position4> 476 487 <Position5> 477 488 <Filename Value="UCore.pas"/> 478 <Caret Line="38 5" Column="1" TopLine="357"/>489 <Caret Line="387" Column="1" TopLine="359"/> 479 490 </Position5> 480 491 <Position6> 481 492 <Filename Value="UCore.pas"/> 482 <Caret Line=" 387" Column="1" TopLine="359"/>493 <Caret Line="403" Column="1" TopLine="386"/> 483 494 </Position6> 484 495 <Position7> 485 496 <Filename Value="UCore.pas"/> 486 <Caret Line="40 3" Column="1" TopLine="386"/>497 <Caret Line="404" Column="1" TopLine="386"/> 487 498 </Position7> 488 499 <Position8> 489 500 <Filename Value="UCore.pas"/> 490 <Caret Line=" 404" Column="1" TopLine="386"/>501 <Caret Line="377" Column="10" TopLine="366"/> 491 502 </Position8> 492 503 <Position9> 493 504 <Filename Value="UCore.pas"/> 494 <Caret Line=" 405" Column="1" TopLine="386"/>505 <Caret Line="175" Column="9" TopLine="158"/> 495 506 </Position9> 496 507 <Position10> 497 508 <Filename Value="UCore.pas"/> 498 <Caret Line=" 410" Column="1" TopLine="386"/>509 <Caret Line="555" Column="3" TopLine="537"/> 499 510 </Position10> 500 511 <Position11> 501 <Filename Value=" UCore.pas"/>502 <Caret Line=" 411" Column="1" TopLine="386"/>512 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/> 513 <Caret Line="158" Column="1" TopLine="152"/> 503 514 </Position11> 504 515 <Position12> 505 516 <Filename Value="UCore.pas"/> 506 <Caret Line="37 1" Column="1" TopLine="354"/>517 <Caret Line="374" Column="12" TopLine="363"/> 507 518 </Position12> 508 519 <Position13> 509 520 <Filename Value="UCore.pas"/> 510 <Caret Line=" 372" Column="1" TopLine="354"/>521 <Caret Line="545" Column="6" TopLine="536"/> 511 522 </Position13> 512 523 <Position14> 513 524 <Filename Value="UCore.pas"/> 514 <Caret Line=" 373" Column="1" TopLine="354"/>525 <Caret Line="565" Column="106" TopLine="561"/> 515 526 </Position14> 516 527 <Position15> 517 <Filename Value=" UCore.pas"/>518 <Caret Line=" 375" Column="1" TopLine="354"/>528 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 529 <Caret Line="56" Column="58" TopLine="34"/> 519 530 </Position15> 520 531 <Position16> 521 <Filename Value=" UCore.pas"/>522 <Caret Line=" 376" Column="1" TopLine="354"/>532 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 533 <Caret Line="214" Column="13" TopLine="188"/> 523 534 </Position16> 524 535 <Position17> 525 <Filename Value=" UCore.pas"/>526 <Caret Line=" 377" Column="1" TopLine="354"/>536 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 537 <Caret Line="51" Column="26" TopLine="34"/> 527 538 </Position17> 528 539 <Position18> 529 540 <Filename Value="UCore.pas"/> 530 <Caret Line=" 379" Column="1" TopLine="354"/>541 <Caret Line="886" Column="6" TopLine="866"/> 531 542 </Position18> 532 543 <Position19> 533 <Filename Value="U Core.pas"/>534 <Caret Line=" 385" Column="1" TopLine="357"/>544 <Filename Value="UMainForm.pas"/> 545 <Caret Line="49" Column="56" TopLine="34"/> 535 546 </Position19> 536 547 <Position20> 537 <Filename Value="U Core.pas"/>538 <Caret Line=" 387" Column="1" TopLine="359"/>548 <Filename Value="UMainForm.pas"/> 549 <Caret Line="146" Column="5" TopLine="132"/> 539 550 </Position20> 540 551 <Position21> 541 <Filename Value="U Core.pas"/>542 <Caret Line=" 403" Column="1" TopLine="386"/>552 <Filename Value="UMainForm.pas"/> 553 <Caret Line="176" Column="20" TopLine="174"/> 543 554 </Position21> 544 555 <Position22> 545 <Filename Value="U Core.pas"/>546 <Caret Line=" 404" Column="1" TopLine="386"/>556 <Filename Value="UMainForm.pas"/> 557 <Caret Line="94" Column="37" TopLine="92"/> 547 558 </Position22> 548 559 <Position23> 549 <Filename Value="U Core.pas"/>550 <Caret Line=" 377" Column="10" TopLine="366"/>560 <Filename Value="UMainForm.pas"/> 561 <Caret Line="135" Column="7" TopLine="133"/> 551 562 </Position23> 552 563 <Position24> 553 564 <Filename Value="UCore.pas"/> 554 <Caret Line="1 75" Column="9" TopLine="158"/>565 <Caret Line="156" Column="13" TopLine="139"/> 555 566 </Position24> 556 567 <Position25> 557 568 <Filename Value="UCore.pas"/> 558 <Caret Line=" 555" Column="3" TopLine="537"/>569 <Caret Line="119" Column="24" TopLine="110"/> 559 570 </Position25> 560 571 <Position26> 561 <Filename Value=" ../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/>562 <Caret Line=" 158" Column="1" TopLine="152"/>572 <Filename Value="UCore.pas"/> 573 <Caret Line="788" Column="15" TopLine="771"/> 563 574 </Position26> 564 575 <Position27> 565 576 <Filename Value="UCore.pas"/> 566 <Caret Line="3 74" Column="12" TopLine="363"/>577 <Caret Line="340" Column="22" TopLine="320"/> 567 578 </Position27> 568 579 <Position28> 569 <Filename Value="U Core.pas"/>570 <Caret Line=" 545" Column="6" TopLine="536"/>580 <Filename Value="UMainForm.pas"/> 581 <Caret Line="135" Column="27" TopLine="118"/> 571 582 </Position28> 572 583 <Position29> 573 <Filename Value="U Core.pas"/>574 <Caret Line=" 565" Column="106" TopLine="561"/>584 <Filename Value="UMainForm.pas"/> 585 <Caret Line="95" Column="1" TopLine="92"/> 575 586 </Position29> 576 587 <Position30> 577 <Filename Value="U Core.pas"/>578 <Caret Line=" 521" Column="3" TopLine="519"/>588 <Filename Value="UMainForm.pas"/> 589 <Caret Line="175" Column="1" TopLine="171"/> 579 590 </Position30> 580 591 </JumpHistory>
Note:
See TracChangeset
for help on using the changeset viewer.