Changeset 6
- Timestamp:
- Mar 6, 2011, 7:31:53 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r4 r6 282 282 end; 283 283 284 285 284 if Engine.KeyState[Ord(Keys.Shoot)] then 286 285 if Bullets.Count < MaxBulletCount then begin 287 286 NewBullet := TBullet.Create; 288 287 NewBullet.Player := Self; 289 NewBullet.Position := Position; 288 NewBullet.Position := Point(Position.X + DirectionToDelta[Direction].X * 4, 289 Position.Y + DirectionToDelta[Direction].Y * 4); 290 290 NewBullet.Direction := Direction; 291 291 Bullets.Add(NewBullet); … … 299 299 Position.Y := Position.Y + DirectionToDelta[Direction].Y; 300 300 301 if Engine.World.Surface.ItemsXY[Position.Y, Position.X] <> Byte(smNothing) then begin 302 if (Engine.World.Surface.ItemsXY[Position.Y, Position.X] = Byte(smDirt1)) or 303 (Engine.World.Surface.ItemsXY[Position.Y, Position.X] = Byte(smDirt2)) then 304 Engine.World.Surface.ItemsXY[Position.Y, Position.X] := Byte(smNothing); 305 Bullets.Delete(I); 306 end else 301 307 with Engine.World.Surface do 302 308 if (Position.X >= Count.X) or (Position.X < 0) or … … 304 310 Bullets.Delete(I) else 305 311 Engine.World.Surface.ItemsXY[Position.Y, Position.X] := Byte(smBullet); 312 Engine.Redraw; 306 313 end; 307 314 end; … … 313 320 begin 314 321 with Engine.FBitmapLower.Canvas do begin 315 Rectangle(ScreenFrame);316 322 Brush.Color := SurfaceMatterColors[smRock]; 317 323 FillRect(ScreenFrame); 318 319 324 320 325 with Engine.World do … … 326 331 Pixels[X, Y] := SurfaceMatterColors[TSurfaceMatter(Surface.ItemsXY[YY, XX])]; 327 332 end; 333 Pen.Color := clBlack; 334 Frame(ScreenFrame); 328 335 329 336 (*CopyRect(ScreenFrame, Engine.World.Surface.Canvas, … … 333 340 Position.X + (ScreenFrame.Right - ScreenFrame.Left) div 2, 334 341 Position.Y + (ScreenFrame.Bottom - ScreenFrame.Top) div 2));*) 335 TextOut(ScreenFrame.Left, ScreenFrame.Top, Name);342 //TextOut(ScreenFrame.Left, ScreenFrame.Top, Name); 336 343 //ShowMessage(IntToStr(ScreenFrame.Right - ScreenFrame.Left) + ' ' + 337 344 //IntToStr(ScreenFrame.Bottom - ScreenFrame.Top)); … … 361 368 var 362 369 X, Y: Integer; 370 XX, YY: Integer; 363 371 begin 364 372 Result := smNothing; 365 373 with Engine.World, TTank(Tanks[NewDirection]) do 366 374 for Y := 0 to Image.Count.Y - 1 do 367 for X := 0 to Image.Count.X - 1 do 375 for X := 0 to Image.Count.X - 1 do begin 376 XX := X + NewPosition.X - Image.Count.X div 2; 377 YY := Y + NewPosition.Y - Image.Count.Y div 2; 368 378 if (Image.ItemsXY[Y, X] > 0) and 369 (Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X] <> Byte(smNothing)) then379 (Surface.ItemsXY[YY, XX] <> Byte(smNothing)) then 370 380 begin 371 381 Result := smDirt1; 372 if (Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X] <> Byte(smDirt1)) and373 (Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X] <> Byte(smDirt2)) then382 if (Surface.ItemsXY[YY, XX] <> Byte(smDirt1)) and 383 (Surface.ItemsXY[YY, XX] <> Byte(smDirt2)) then 374 384 begin 375 Result := TSurfaceMatter(Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X]);385 Result := TSurfaceMatter(Surface.ItemsXY[YY, XX]); 376 386 Exit; 377 387 end; 378 388 end; 389 end; 379 390 end; 380 391 … … 387 398 begin 388 399 with Engine.World do begin 389 Surface.Merge(Surface.CreateIndex(Position.X, Position.Y), TTank(Tanks[Direction]).Image, ShowTankProc); 400 Surface.Merge(Surface.CreateIndex(Position.X - TTank(Tanks[Direction]).Image.Count.X div 2, 401 Position.Y - TTank(Tanks[Direction]).Image.Count.Y div 2), TTank(Tanks[Direction]).Image, ShowTankProc); 390 402 end; 391 403 end; … … 399 411 begin 400 412 with Engine.World do begin 401 Surface.Merge(Surface.CreateIndex(Position.X, Position.Y), TTank(Tanks[Direction]).Image, HideTankProc); 413 Surface.Merge(Surface.CreateIndex(Position.X - TTank(Tanks[Direction]).Image.Count.X div 2, 414 Position.Y - TTank(Tanks[Direction]).Image.Count.Y div 2), TTank(Tanks[Direction]).Image, HideTankProc); 402 415 end; 403 416 end; -
trunk/UMainForm.lfm
r4 r6 47 47 Caption = 'Game' 48 48 object MenuItem3: TMenuItem 49 Caption = 'New...' 50 OnClick = MenuItem3Click 51 end 52 object MenuItemShowMap: TMenuItem 53 Caption = 'Show map' 54 OnClick = MenuItemShowMapClick 49 Action = ANewGame 55 50 end 56 51 object MenuItem2: TMenuItem 57 Caption = 'Exit' 58 OnClick = MenuItem2Click 52 Action = AExit 53 end 54 end 55 object MenuItem4: TMenuItem 56 Caption = 'View' 57 object MenuItem5: TMenuItem 58 Action = AShowMap 59 end 60 object MenuItem6: TMenuItem 61 Action = AFullScreen 59 62 end 60 63 end … … 66 69 top = 104 67 70 end 71 object ActionList1: TActionList 72 left = 272 73 top = 24 74 object AFullScreen: TAction 75 Caption = 'Fullscreen mode' 76 OnExecute = AFullScreenExecute 77 ShortCut = 122 78 end 79 object AExit: TAction 80 Caption = 'Exit' 81 OnExecute = AExitExecute 82 end 83 object ANewGame: TAction 84 Caption = 'New game' 85 OnExecute = ANewGameExecute 86 ShortCut = 16462 87 end 88 object AShowMap: TAction 89 Caption = 'Show map' 90 OnExecute = AShowMapExecute 91 ShortCut = 123 92 end 93 end 68 94 end -
trunk/UMainForm.pas
r4 r6 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 ComCtrls, Menus, UCore;9 ComCtrls, Menus, ActnList, UCore; 10 10 11 11 type … … 14 14 15 15 TMainForm = class(TForm) 16 AShowMap: TAction; 17 ANewGame: TAction; 18 AExit: TAction; 19 AFullScreen: TAction; 20 ActionList1: TActionList; 16 21 Image1: TImage; 17 22 MainMenu1: TMainMenu; … … 19 24 MenuItem2: TMenuItem; 20 25 MenuItem3: TMenuItem; 21 MenuItemShowMap: TMenuItem; 26 MenuItem4: TMenuItem; 27 MenuItem5: TMenuItem; 28 MenuItem6: TMenuItem; 22 29 StatusBar1: TStatusBar; 23 30 TimerDraw: TTimer; 24 31 TimerEngineTick: TTimer; 32 procedure AExitExecute(Sender: TObject); 33 procedure AFullScreenExecute(Sender: TObject); 34 procedure ANewGameExecute(Sender: TObject); 35 procedure AShowMapExecute(Sender: TObject); 25 36 procedure FormCreate(Sender: TObject); 26 37 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); … … 28 39 procedure FormShow(Sender: TObject); 29 40 procedure Image1Resize(Sender: TObject); 30 procedure MenuItem2Click(Sender: TObject);31 procedure MenuItem3Click(Sender: TObject);32 procedure MenuItemShowMapClick(Sender: TObject);33 41 procedure TimerDrawTimer(Sender: TObject); 34 42 procedure TimerEngineTickTimer(Sender: TObject); 35 43 private 44 OriginalBounds: TRect; 45 OriginalWindowState: TWindowState; 46 ScreenBounds: TRect; 36 47 public 37 48 { public declarations } … … 106 117 end; 107 118 119 procedure TMainForm.AFullScreenExecute(Sender: TObject); 120 begin 121 if BorderStyle <> bsNone then begin 122 // To full screen 123 OriginalWindowState := WindowState; 124 OriginalBounds := BoundsRect; 125 126 BorderStyle := bsNone; 127 ScreenBounds := Screen.MonitorFromWindow(Handle).BoundsRect; 128 with ScreenBounds do 129 SetBounds(Left, Top, Right - Left, Bottom - Top) ; 130 end else begin 131 // From full screen 132 {$IFDEF MSWINDOWS} 133 BorderStyle := bsSizeable; 134 {$ENDIF} 135 if OriginalWindowState = wsMaximized then 136 WindowState := wsMaximized 137 else 138 with OriginalBounds do 139 SetBounds(Left, Top, Right - Left, Bottom - Top) ; 140 {$IFDEF LINUX} 141 BorderStyle := bsSizeable; 142 {$ENDIF} 143 end; 144 end; 145 146 procedure TMainForm.ANewGameExecute(Sender: TObject); 147 begin 148 Engine.NewGame; 149 end; 150 151 procedure TMainForm.AShowMapExecute(Sender: TObject); 152 begin 153 MapForm.Show; 154 end; 155 156 procedure TMainForm.AExitExecute(Sender: TObject); 157 begin 158 Close; 159 end; 160 108 161 procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; 109 162 Shift: TShiftState); … … 129 182 end; 130 183 131 procedure TMainForm.MenuItem2Click(Sender: TObject);132 begin133 Close;134 end;135 136 procedure TMainForm.MenuItem3Click(Sender: TObject);137 begin138 Engine.NewGame;139 end;140 141 procedure TMainForm.MenuItemShowMapClick(Sender: TObject);142 begin143 MapForm.Show;144 end;145 146 184 end. 147 185 -
trunk/tunneler.lpi
r4 r6 42 42 </Item3> 43 43 </RequiredPackages> 44 <Units Count="3 1">44 <Units Count="32"> 45 45 <Unit0> 46 46 <Filename Value="tunneler.lpr"/> … … 50 50 <TopLine Value="1"/> 51 51 <CursorPos X="14" Y="8"/> 52 <UsageCount Value=" 49"/>52 <UsageCount Value="51"/> 53 53 </Unit0> 54 54 <Unit1> … … 58 58 <ResourceBaseClass Value="Form"/> 59 59 <UnitName Value="UMainForm"/> 60 <EditorIndex Value=" 1"/>61 <WindowIndex Value="0"/> 62 <TopLine Value=" 12"/>63 <CursorPos X=" 20" Y="27"/>64 <UsageCount Value=" 49"/>60 <EditorIndex Value="3"/> 61 <WindowIndex Value="0"/> 62 <TopLine Value="24"/> 63 <CursorPos X="32" Y="32"/> 64 <UsageCount Value="51"/> 65 65 <Loaded Value="True"/> 66 66 <LoadedDesigner Value="True"/> … … 73 73 <EditorIndex Value="0"/> 74 74 <WindowIndex Value="0"/> 75 <TopLine Value=" 161"/>76 <CursorPos X=" 38" Y="177"/>77 <UsageCount Value=" 49"/>75 <TopLine Value="316"/> 76 <CursorPos X="7" Y="342"/> 77 <UsageCount Value="51"/> 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="252"/> 108 <CursorPos X="20" Y="271"/> 109 <UsageCount Value="9"/> 106 <EditorIndex Value="1"/> 107 <WindowIndex Value="0"/> 108 <TopLine Value="1769"/> 109 <CursorPos X="10" Y="1786"/> 110 <UsageCount Value="10"/> 111 <Loaded Value="True"/> 110 112 </Unit6> 111 113 <Unit7> … … 113 115 <UnitName Value="Graphics"/> 114 116 <WindowIndex Value="0"/> 115 <TopLine Value="1 281"/>116 <CursorPos X="15" Y="1 298"/>117 <TopLine Value="1089"/> 118 <CursorPos X="15" Y="1136"/> 117 119 <UsageCount Value="12"/> 118 120 </Unit7> … … 141 143 <Unit11> 142 144 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/> 143 <EditorIndex Value=" 3"/>145 <EditorIndex Value="4"/> 144 146 <WindowIndex Value="0"/> 145 147 <TopLine Value="149"/> 146 <CursorPos X=" 59" Y="172"/>148 <CursorPos X="1" Y="171"/> 147 149 <UsageCount Value="20"/> 148 150 <Loaded Value="True"/> … … 151 153 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Specialized/SpecializedMatrix.pas"/> 152 154 <UnitName Value="SpecializedMatrix"/> 153 <EditorIndex Value=" 4"/>155 <EditorIndex Value="5"/> 154 156 <WindowIndex Value="0"/> 155 157 <TopLine Value="69"/> 156 158 <CursorPos X="40" Y="98"/> 157 <UsageCount Value="1 7"/>159 <UsageCount Value="18"/> 158 160 <Loaded Value="True"/> 159 161 </Unit12> … … 175 177 <Unit15> 176 178 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 177 <EditorIndex Value=" 5"/>179 <EditorIndex Value="6"/> 178 180 <WindowIndex Value="0"/> 179 181 <TopLine Value="107"/> 180 182 <CursorPos X="1" Y="126"/> 181 <UsageCount Value="1 8"/>183 <UsageCount Value="19"/> 182 184 <Loaded Value="True"/> 183 185 </Unit15> … … 187 189 <TopLine Value="783"/> 188 190 <CursorPos X="3" Y="785"/> 189 <UsageCount Value=" 9"/>191 <UsageCount Value="8"/> 190 192 </Unit16> 191 193 <Unit17> … … 194 196 <TopLine Value="830"/> 195 197 <CursorPos X="11" Y="847"/> 196 <UsageCount Value=" 9"/>198 <UsageCount Value="8"/> 197 199 </Unit17> 198 200 <Unit18> … … 202 204 <TopLine Value="665"/> 203 205 <CursorPos X="27" Y="682"/> 204 <UsageCount Value="1 1"/>206 <UsageCount Value="10"/> 205 207 </Unit18> 206 208 <Unit19> … … 209 211 <TopLine Value="112"/> 210 212 <CursorPos X="10" Y="114"/> 211 <UsageCount Value="1 1"/>213 <UsageCount Value="10"/> 212 214 </Unit19> 213 215 <Unit20> … … 267 269 <ResourceBaseClass Value="Form"/> 268 270 <UnitName Value="UMapForm"/> 269 <EditorIndex Value="2"/>270 271 <WindowIndex Value="0"/> 271 272 <TopLine Value="15"/> 272 273 <CursorPos X="24" Y="39"/> 273 <UsageCount Value="28"/> 274 <Loaded Value="True"/> 274 <UsageCount Value="30"/> 275 275 </Unit27> 276 276 <Unit28> … … 295 295 <UsageCount Value="9"/> 296 296 </Unit30> 297 <Unit31> 298 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericListObject.inc"/> 299 <EditorIndex Value="2"/> 300 <WindowIndex Value="0"/> 301 <TopLine Value="60"/> 302 <CursorPos X="1" Y="77"/> 303 <UsageCount Value="10"/> 304 <Loaded Value="True"/> 305 </Unit31> 297 306 </Units> 298 307 <JumpHistory Count="30" HistoryIndex="28"> 299 308 <Position1> 300 309 <Filename Value="UCore.pas"/> 301 <Caret Line=" 245" Column="56" TopLine="214"/>310 <Caret Line="308" Column="1" TopLine="282"/> 302 311 </Position1> 303 312 <Position2> 304 313 <Filename Value="UCore.pas"/> 305 <Caret Line=" 202" Column="14" TopLine="192"/>314 <Caret Line="310" Column="1" TopLine="282"/> 306 315 </Position2> 307 316 <Position3> 308 <Filename Value=" UMainForm.pas"/>309 <Caret Line=" 65" Column="3" TopLine="47"/>317 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/> 318 <Caret Line="171" Column="1" TopLine="149"/> 310 319 </Position3> 311 320 <Position4> 312 321 <Filename Value="UCore.pas"/> 313 <Caret Line=" 234" Column="7" TopLine="207"/>322 <Caret Line="303" Column="21" TopLine="282"/> 314 323 </Position4> 315 324 <Position5> 316 <Filename Value="U MainForm.pas"/>317 <Caret Line=" 65" Column="3" TopLine="47"/>325 <Filename Value="UCore.pas"/> 326 <Caret Line="296" Column="7" TopLine="282"/> 318 327 </Position5> 319 328 <Position6> 320 <Filename Value="U MainForm.pas"/>321 <Caret Line=" 72" Column="3" TopLine="49"/>329 <Filename Value="UCore.pas"/> 330 <Caret Line="289" Column="1" TopLine="282"/> 322 331 </Position6> 323 332 <Position7> 324 <Filename Value="U MainForm.pas"/>325 <Caret Line=" 67" Column="15" TopLine="65"/>333 <Filename Value="UCore.pas"/> 334 <Caret Line="290" Column="1" TopLine="282"/> 326 335 </Position7> 327 336 <Position8> 328 <Filename Value="U MainForm.pas"/>329 <Caret Line=" 56" Column="9" TopLine="52"/>337 <Filename Value="UCore.pas"/> 338 <Caret Line="293" Column="1" TopLine="282"/> 330 339 </Position8> 331 340 <Position9> 332 341 <Filename Value="UCore.pas"/> 333 <Caret Line=" 124" Column="15" TopLine="107"/>342 <Caret Line="294" Column="1" TopLine="282"/> 334 343 </Position9> 335 344 <Position10> 336 345 <Filename Value="UCore.pas"/> 337 <Caret Line=" 109" Column="20" TopLine="85"/>346 <Caret Line="295" Column="1" TopLine="282"/> 338 347 </Position10> 339 348 <Position11> 340 349 <Filename Value="UCore.pas"/> 341 <Caret Line=" 553" Column="29" TopLine="541"/>350 <Caret Line="297" Column="1" TopLine="282"/> 342 351 </Position11> 343 352 <Position12> 344 353 <Filename Value="UCore.pas"/> 345 <Caret Line=" 562" Column="1" TopLine="550"/>354 <Caret Line="298" Column="1" TopLine="282"/> 346 355 </Position12> 347 356 <Position13> 348 357 <Filename Value="UCore.pas"/> 349 <Caret Line=" 557" Column="20" TopLine="537"/>358 <Caret Line="300" Column="1" TopLine="282"/> 350 359 </Position13> 351 360 <Position14> 352 361 <Filename Value="UCore.pas"/> 353 <Caret Line=" 554" Column="1" TopLine="537"/>362 <Caret Line="304" Column="1" TopLine="282"/> 354 363 </Position14> 355 364 <Position15> 356 365 <Filename Value="UCore.pas"/> 357 <Caret Line=" 555" Column="1" TopLine="537"/>366 <Caret Line="305" Column="1" TopLine="282"/> 358 367 </Position15> 359 368 <Position16> 360 369 <Filename Value="UCore.pas"/> 361 <Caret Line=" 556" Column="1" TopLine="537"/>370 <Caret Line="306" Column="1" TopLine="282"/> 362 371 </Position16> 363 372 <Position17> 364 373 <Filename Value="UCore.pas"/> 365 <Caret Line=" 557" Column="1" TopLine="537"/>374 <Caret Line="308" Column="1" TopLine="282"/> 366 375 </Position17> 367 376 <Position18> 368 377 <Filename Value="UCore.pas"/> 369 <Caret Line=" 494" Column="1" TopLine="488"/>378 <Caret Line="310" Column="1" TopLine="282"/> 370 379 </Position18> 371 380 <Position19> 372 381 <Filename Value="UCore.pas"/> 373 <Caret Line="2 35" Column="1" TopLine="215"/>382 <Caret Line="295" Column="1" TopLine="282"/> 374 383 </Position19> 375 384 <Position20> 376 385 <Filename Value="UCore.pas"/> 377 <Caret Line=" 495" Column="1" TopLine="478"/>386 <Caret Line="297" Column="1" TopLine="282"/> 378 387 </Position20> 379 388 <Position21> 380 389 <Filename Value="UCore.pas"/> 381 <Caret Line=" 583" Column="1" TopLine="562"/>390 <Caret Line="298" Column="1" TopLine="282"/> 382 391 </Position21> 383 392 <Position22> 384 393 <Filename Value="UCore.pas"/> 385 <Caret Line=" 558" Column="29" TopLine="541"/>394 <Caret Line="300" Column="1" TopLine="282"/> 386 395 </Position22> 387 396 <Position23> 388 397 <Filename Value="UCore.pas"/> 389 <Caret Line=" 547" Column="27" TopLine="541"/>398 <Caret Line="304" Column="1" TopLine="282"/> 390 399 </Position23> 391 400 <Position24> 392 401 <Filename Value="UCore.pas"/> 393 <Caret Line=" 171" Column="62" TopLine="157"/>402 <Caret Line="305" Column="1" TopLine="282"/> 394 403 </Position24> 395 404 <Position25> 396 <Filename Value="U MapForm.pas"/>397 <Caret Line="3 9" Column="24" TopLine="15"/>405 <Filename Value="UCore.pas"/> 406 <Caret Line="306" Column="1" TopLine="282"/> 398 407 </Position25> 399 408 <Position26> 400 409 <Filename Value="UCore.pas"/> 401 <Caret Line="2 10" Column="5" TopLine="197"/>410 <Caret Line="274" Column="25" TopLine="252"/> 402 411 </Position26> 403 412 <Position27> 404 413 <Filename Value="UCore.pas"/> 405 <Caret Line="2 02" Column="16" TopLine="193"/>414 <Caret Line="273" Column="10" TopLine="252"/> 406 415 </Position27> 407 416 <Position28> 408 417 <Filename Value="UCore.pas"/> 409 <Caret Line=" 177" Column="29" TopLine="157"/>418 <Caret Line="310" Column="36" TopLine="279"/> 410 419 </Position28> 411 420 <Position29> 412 421 <Filename Value="UCore.pas"/> 413 <Caret Line=" 188" Column="70" TopLine="161"/>422 <Caret Line="288" Column="33" TopLine="273"/> 414 423 </Position29> 415 424 <Position30> 416 <Filename Value=" ../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/>417 <Caret Line="17 2" Column="59" TopLine="149"/>425 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/objpas/classes/classesh.inc"/> 426 <Caret Line="1786" Column="10" TopLine="1769"/> 418 427 </Position30> 419 428 </JumpHistory>
Note:
See TracChangeset
for help on using the changeset viewer.