Changeset 6 for trunk/UCore.pas


Ignore:
Timestamp:
Mar 6, 2011, 7:31:53 PM (13 years ago)
Author:
george
Message:
  • Added: Fullscreen mode.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r4 r6  
    282282  end;
    283283
    284 
    285284  if Engine.KeyState[Ord(Keys.Shoot)] then
    286285    if Bullets.Count < MaxBulletCount then begin
    287286      NewBullet := TBullet.Create;
    288287      NewBullet.Player := Self;
    289       NewBullet.Position := Position;
     288      NewBullet.Position := Point(Position.X + DirectionToDelta[Direction].X * 4,
     289        Position.Y + DirectionToDelta[Direction].Y * 4);
    290290      NewBullet.Direction := Direction;
    291291      Bullets.Add(NewBullet);
     
    299299    Position.Y := Position.Y + DirectionToDelta[Direction].Y;
    300300
     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
    301307    with Engine.World.Surface do
    302308    if (Position.X >= Count.X) or (Position.X < 0) or
     
    304310      Bullets.Delete(I) else
    305311      Engine.World.Surface.ItemsXY[Position.Y, Position.X] := Byte(smBullet);
     312    Engine.Redraw;
    306313  end;
    307314end;
     
    313320begin
    314321  with Engine.FBitmapLower.Canvas do begin
    315     Rectangle(ScreenFrame);
    316322    Brush.Color := SurfaceMatterColors[smRock];
    317323    FillRect(ScreenFrame);
    318 
    319324
    320325    with Engine.World do
     
    326331          Pixels[X, Y] := SurfaceMatterColors[TSurfaceMatter(Surface.ItemsXY[YY, XX])];
    327332      end;
     333    Pen.Color := clBlack;
     334    Frame(ScreenFrame);
    328335
    329336    (*CopyRect(ScreenFrame, Engine.World.Surface.Canvas,
     
    333340      Position.X + (ScreenFrame.Right - ScreenFrame.Left) div 2,
    334341      Position.Y + (ScreenFrame.Bottom - ScreenFrame.Top) div 2));*)
    335     TextOut(ScreenFrame.Left, ScreenFrame.Top, Name);
     342    //TextOut(ScreenFrame.Left, ScreenFrame.Top, Name);
    336343    //ShowMessage(IntToStr(ScreenFrame.Right - ScreenFrame.Left) + ' ' +
    337344    //IntToStr(ScreenFrame.Bottom - ScreenFrame.Top));
     
    361368var
    362369  X, Y: Integer;
     370  XX, YY: Integer;
    363371begin
    364372  Result := smNothing;
    365373  with Engine.World, TTank(Tanks[NewDirection]) do
    366374  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;
    368378    if (Image.ItemsXY[Y, X] > 0) and
    369     (Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X] <> Byte(smNothing)) then
     379    (Surface.ItemsXY[YY, XX] <> Byte(smNothing)) then
    370380    begin
    371381      Result := smDirt1;
    372       if (Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X] <> Byte(smDirt1)) and
    373       (Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X] <> Byte(smDirt2)) then
     382      if (Surface.ItemsXY[YY, XX] <> Byte(smDirt1)) and
     383      (Surface.ItemsXY[YY, XX] <> Byte(smDirt2)) then
    374384      begin
    375         Result := TSurfaceMatter(Surface.ItemsXY[Y + NewPosition.Y, X + NewPosition.X]);
     385        Result := TSurfaceMatter(Surface.ItemsXY[YY, XX]);
    376386        Exit;
    377387      end;
    378388    end;
     389  end;
    379390end;
    380391
     
    387398begin
    388399  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);
    390402  end;
    391403end;
     
    399411begin
    400412  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);
    402415  end;
    403416end;
Note: See TracChangeset for help on using the changeset viewer.