Changeset 66 for trunk


Ignore:
Timestamp:
Jan 7, 2023, 11:06:35 PM (2 years ago)
Author:
chronos
Message:
  • Fixed: Home doors size.
  • Modified: Use movemenet energy decrease instead of dig energy decrease.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UEngine.pas

    r64 r66  
    66  Dialogs, Classes, SysUtils, Graphics, SpecializedMatrix, URegistry,
    77  IntfGraphics, FPImage, LCLType, SpecializedBitmap, GraphType, Math, URectangle,
    8   Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, XMLConf, DOM,
    9   Generics.Collections, UWorld, UMatter;
     8  Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, Generics.Collections,
     9  UWorld, UMatter;
    1010
    1111const
    1212  MaxBulletCount = 10;
    13   EnergySteps = 4000;
    14   EnergyDecreaseDig = 0.001;
    15   EnergyDecreaseShoot = 0.005;
     13  EnergyDecreaseDig = 0;
     14  EnergyDecreaseMove = 0.00025; // ~2.5 minutes of movement
     15  EnergyDecreaseShoot = 0.005; // ~20 seconds of shooting
     16  EnergyDecreaseOutside = 0.00003; // ~5 minutes of live
     17  EnergyIncreaseHome = 0.001;
    1618  ShieldSteps = 40;
    1719  ExplosionBulletCount = 100;
     
    2628  PlayerFrameWidth = 80;
    2729  PlayerFrameHeight = 80;
    28   PlayerHouseSize = 30;
    29   PlayerHouseDoorSize = 8;
     30  PlayerHouseSize = 29;
     31  PlayerHouseDoorSize = 7;
    3032  ExplosionDelay = 2;
    3133  NewRoundDelay = 2;
     
    476478      CheckNewDestination;
    477479    end else begin
    478         NewPosition := Position;
    479         if not CheckNewDestination then begin
    480           // if direction is changed then try to check movement plus one step
    481           // to prevent tank block
    482           NewPosition := Point(Position.X + Delta.X, Position.Y + Delta.Y);
    483           CheckNewDestination;
    484         end;
     480      NewPosition := Position;
     481      if not CheckNewDestination then begin
     482        // if direction is changed then try to check movement plus one step
     483        // to prevent tank block
     484        NewPosition := Point(Position.X + Delta.X, Position.Y + Delta.Y);
     485        CheckNewDestination;
    485486      end;
     487    end;
    486488  end;
    487489
     
    520522    if ColisionState.Diggable then begin
    521523      if (Engine.KeyBoard.KeyState[Ord(Keys.Shoot)] and
    522     ((Now - LastDigTime) > ShootDigDelay * OneSecond)) or
    523     (not Engine.KeyBoard.KeyState[Ord(Keys.Shoot)] and
    524     ((Now - LastDigTime) > DigDelay * OneSecond)) then begin
    525       Dig := not Dig;
    526       with Engine, World do
    527       Surface.Merge(Surface.CreateIndex(
    528         Position.X - TMatrixByte(DigMasks[Direction]).Count.X div 2,
    529         Position.Y - TMatrixByte(DigMasks[Direction]).Count.Y div 2),
    530         TMatrixByte(DigMasks[Direction]), DigProc);
    531       Energy := Energy - EnergyDecreaseDig;
    532       if Energy < 0 then Energy := 0;
    533       Engine.Redraw;
    534       LastDigTime := Now;
    535       Direction := NewDirection;
    536       Result := True;
     524      ((Now - LastDigTime) > ShootDigDelay * OneSecond)) or
     525      (not Engine.KeyBoard.KeyState[Ord(Keys.Shoot)] and
     526      ((Now - LastDigTime) > DigDelay * OneSecond)) then begin
     527        Dig := not Dig;
     528        with Engine, World do
     529        Surface.Merge(Surface.CreateIndex(
     530          Position.X - TMatrixByte(DigMasks[Direction]).Count.X div 2,
     531          Position.Y - TMatrixByte(DigMasks[Direction]).Count.Y div 2),
     532          TMatrixByte(DigMasks[Direction]), DigProc);
     533        Energy := Energy - EnergyDecreaseDig;
     534        if Energy < 0 then Energy := 0;
     535        Engine.Redraw;
     536        LastDigTime := Now;
     537        Direction := NewDirection;
     538        Result := True;
    537539      end;
    538540    end else begin
     
    543545        Engine.Redraw;
    544546        LastMoveTime := Now;
     547        Energy := Energy - EnergyDecreaseMove;
    545548      end;
    546549    end;
     
    558561  if not ExplosionPending then begin
    559562    if not Engine.IsInsideHouses(Position) then begin
    560       Energy := Energy - 1 / EnergySteps;
     563      Energy := Energy - EnergyDecreaseOutside;
    561564    end else begin
    562565      if not Exploded then
    563         Energy := Energy + 5 * 1 / EnergySteps;
     566        Energy := Energy + EnergyIncreaseHome;
    564567      if Energy > 1 then Energy := 1;
    565568    end;
     
    711714    for X := 0 to PlayerHouseSize - 1 do begin
    712715      if ((Y = 0) or (Y = (PlayerHouseSize - 1)) or (X = 0) or (X = (PlayerHouseSize - 1))) and
    713       not (((Y = 0) or (Y = (PlayerHouseSize - 1))) and (X > ((PlayerHouseSize - PlayerHouseDoorSize) div 2)) and
    714       (X < ((PlayerHouseSize - 1 + PlayerHouseDoorSize) div 2)))
     716      not (((Y = 0) or (Y = (PlayerHouseSize - 1))) and
     717      (X >= ((PlayerHouseSize - PlayerHouseDoorSize) div 2)) and
     718      (X <= ((PlayerHouseSize - 1 + PlayerHouseDoorSize) div 2)))
    715719      then Matter := Byte(miPlayer1Home) + Id * 4
    716720        else Matter := Byte(miSpace);
     
    17871791      State := gsMenu;
    17881792    end;
     1793  end else
     1794  if State = gsGame then begin
     1795     if Key = KeyEsc then begin
     1796       State := gsMap;
     1797     end;
    17891798  end;
    17901799
     
    17991808      end;
    18001809    end;
    1801   end else
    1802   if (State = gsGame) and (Key = KeyF5) then begin
    1803     State := gsMap;
    18041810  end;
    18051811  {$ENDIF}
Note: See TracChangeset for help on using the changeset viewer.