Changeset 28 for trunk/UCore.pas
- Timestamp:
- Oct 3, 2011, 8:17:16 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r27 r28 103 103 Engine: TEngine; 104 104 Position: TPoint; 105 Score: Integer; 105 106 Direction: Integer; 106 107 ScreenFrame: TRectangle; … … 189 190 FBitmap: TBitmap; 190 191 FBitmapLock: TCriticalSection; 192 FOnGameEnd: TNotifyEvent; 191 193 FRedrawPending: Boolean; 192 194 FBitmapLower: TBitmapTColor; … … 209 211 DigMasks: TListObject; // TListObject<TMatrixByte> 210 212 Lock: TCriticalSection; 213 CurrentRound: Integer; 214 MaxRound: Integer; 215 procedure CheckGameEnd; 211 216 constructor Create; 212 217 destructor Destroy; override; … … 215 220 procedure Draw(Thread: TVirtualThread); 216 221 procedure NewGame; 222 procedure NewRound; 217 223 property Bitmap: TBitmap read FBitmap write SetBitmap; 218 224 property Active: Boolean read FActive write SetActive; 225 property OnGameEnd: TNotifyEvent read FOnGameEnd write FOnGameEnd; 219 226 end; 220 227 … … 938 945 ItemsXY[ScreenFrame.Left + I, ScreenFrame.Bottom - 1] := clBlack 939 946 else ItemsXY[ScreenFrame.Left + I, ScreenFrame.Bottom - 1] := clAqua; 947 948 for I := ScreenFrame.Left to ScreenFrame.Right - 1 do 949 ItemsXY[I, 0] := $010101 * I; 940 950 end; 941 951 end; … … 994 1004 Energy := 0; 995 1005 Shield := 0; 1006 //Synchronize(Engine.CheckGameEnd); 996 1007 end; 997 1008 … … 1226 1237 BytePerRow: Integer; 1227 1238 RawImage: TRawImage; 1228 Color: Int eger;1239 Color: Int64; 1229 1240 Shift: TPoint; 1230 1241 XDiv, XMod, XAcc: Integer; … … 1237 1248 if Assigned(FBitmap) then 1238 1249 try 1250 Lock.Acquire; 1239 1251 Bitmap.BeginUpdate; 1240 1252 RawImage := Bitmap.RawImage; … … 1283 1295 Inc(SubPixelSizeX); 1284 1296 end; 1285 1286 Color := SwapBRComponent(FBitmapLower.Pixels[X, Y]); 1297 Color := FBitmapLower.Pixels[X, Y] and $ffffff; 1298 1299 Color := SwapBRComponent(Color); 1287 1300 1288 1301 // Draw large pixel … … 1302 1315 finally 1303 1316 FBitmap.EndUpdate; 1317 Lock.Release; 1304 1318 end; 1305 1319 end; … … 1464 1478 InitTanks; 1465 1479 Name := SPlayer + ' ' + IntToStr(I + 1); 1466 Enabled := True; 1480 if I < 8 then Enabled := True; 1481 end; 1482 end; 1483 1484 procedure TEngine.CheckGameEnd; 1485 var 1486 AliveCount: Integer; 1487 I: Integer; 1488 begin 1489 AliveCount := 0; 1490 for I := 0 to Players.Count - 1 do 1491 with TPlayer(Players[I]) do 1492 if not Exploded then Inc(AliveCount); 1493 if AliveCount <= 1 then begin 1494 for I := 0 to Players.Count - 1 do 1495 with TPlayer(Players[I]) do 1496 if not Exploded then Inc(Score); 1497 if CurrentRound < MaxRound then 1498 NewRound else 1499 if Assigned(FOnGameEnd) then 1500 FOnGameEnd(Self); 1467 1501 end; 1468 1502 end; … … 1513 1547 InitDigMasks; 1514 1548 Redraw; 1549 MaxRound := 3; 1515 1550 end; 1516 1551 … … 1574 1609 for I := 0 to PlayerPool.Count - 1 do 1575 1610 with TPlayer(PlayerPool[I]) do 1576 if Enabled then 1611 if Enabled then begin 1577 1612 Players.Add(PlayerPool[I]); 1613 Score := 0; 1614 end; 1578 1615 ResizePlayerFrames; 1579 1616 CurrentRound := 0; 1617 NewRound; 1618 1619 Active := True; 1620 end; 1621 1622 procedure TEngine.NewRound; 1623 var 1624 I: Integer; 1625 begin 1626 Active := False; 1580 1627 World.Generate; 1581 1628 1582 1629 for I := 0 to Players.Count - 1 do 1583 with TPlayer(Players[I]) do 1630 with TPlayer(Players[I]) do begin 1584 1631 Init; 1632 end; 1585 1633 ClearBackground := True; 1586 1634 Redraw;
Note:
See TracChangeset
for help on using the changeset viewer.