Changeset 13


Ignore:
Timestamp:
Mar 22, 2011, 5:24:11 PM (13 years ago)
Author:
george
Message:
  • Fixed: Tank explosion effect.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r12 r13  
    1111const
    1212  MaxBulletCount = 10;
    13   EnergySteps = 40;
    14   ShieldSteps = 40;
    15   ExplosionBulletCount = 200;
    16   ExplosionRange = 15;
     13  EnergySteps = 400;
     14  ShieldSteps = 400;
     15  ExplosionBulletCount = 100;
     16  ExplosionRange = 20;
     17  ExplosionBulletMaxSpeed = 0.5;
     18  ExplosionBulletMinSpeed = 0.2;
    1719
    1820type
     
    3537    Shoot: Word;
    3638  end;
     39
     40  { TBullet }
    3741
    3842  TBullet = class
     
    4347    Distance: Real;
    4448    StopByDirt: Boolean;
     49    constructor Create;
    4550  end;
    4651
     
    163168end;
    164169
     170{ TBullet }
     171
     172constructor TBullet.Create;
     173begin
     174  MaxDistance := -1;
     175  Distance := 0;
     176end;
     177
    165178{ TTank }
    166179
     
    352365  I: Integer;
    353366  Pos: TPoint;
    354 begin
     367  D: Real;
     368begin
     369  // Check energy
     370  if not Engine.IsInsideHouses(Position) then begin
     371    Energy := Energy - 1 / EnergySteps;
     372    if Energy <= 0 then begin
     373      Energy := 0;
     374      Explosion;
     375    end;
     376  end else begin
     377    Energy := Energy + 5 * 1 / EnergySteps;
     378    if Energy > 1 then Energy := 1;
     379  end;
     380  if LastEnergy <> Energy then begin
     381    LastEnergy := Energy;
     382    Engine.Redraw;
     383  end;
     384
     385  // Bullet movement
    355386  for I := Bullets.Count - 1 downto 0 do
    356387  with TBullet(Bullets[I]) do begin
     
    362393    Distance := Distance + Sqrt(Sqr(Direction.X) + Sqr(Direction.Y));
    363394    //ShowMessage(FloatToStr(Distance));
    364     if (Distance > MaxDistance) and (MaxDistance > 0) then begin
     395    if (Distance > MaxDistance) and (MaxDistance >= 0) then begin
    365396      Bullets.Delete(I);
     397      Engine.Redraw;
    366398      Continue;
    367399    end;
     
    369401    Pos := Point(Trunc(Position.X), Trunc(Position.Y));
    370402
    371     if Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] <> Byte(smNothing) then begin
     403    if (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] <> Byte(smNothing)) and
     404    (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] <> Byte(smBullet)) then begin
    372405      if (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] = Byte(smDirt1)) or
    373406        (Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] = Byte(smDirt2)) then begin
     
    393426      end;
    394427    Engine.World.Surface.ItemsXY[Pos.X, Pos.Y] := Byte(smBullet);
    395     Engine.Redraw;
    396   end;
    397 
    398   if not Engine.IsInsideHouses(Position) then begin
    399     Energy := Energy - 1 / EnergySteps;
    400     if Energy <= 0 then begin
    401       Energy := 0;
    402       Explosion;
    403     end;
    404   end else begin
    405     Energy := Energy + 5 * 1 / EnergySteps;
    406     if Energy > 1 then Energy := 1;
    407   end;
    408   if LastEnergy <> Energy then begin
    409     LastEnergy := Energy;
    410428    Engine.Redraw;
    411429  end;
     
    521539  NewBullet: TBullet;
    522540  I: Integer;
    523 const
    524   BulletMaxSpeed = 1;
    525   BulletMinSpeed = 0.5;
     541  Speed: Real;
     542  Angle: Real;
    526543begin
    527544  if not Exploded then begin
     
    531548      NewBullet := TBullet.Create;
    532549      NewBullet.Player := Self;
    533       NewBullet.Direction.X := (BulletMaxSpeed - BulletMinSpeed) * (Random - 0.5);
    534       NewBullet.Direction.Y := (BulletMaxSpeed - BulletMinSpeed) * (Random - 0.5);
    535       //NewBullet.Direction.X := NewBullet.Direction.X + BulletMinSpeed * Sign(NewBullet.Direction.X);
    536       //NewBullet.Direction.Y := NewBullet.Direction.Y + BulletMinSpeed * Sign(NewBullet.Direction.Y);
    537       NewBullet.Position.X := Position.X + NewBullet.Direction.X * 2;
    538       NewBullet.Position.Y := Position.Y + NewBullet.Direction.Y * 2;
    539 (*      if NewBullet.Direction.X < (Speed / 10) then
    540         NewBullet.Direction.X := Speed / 10;
    541       if NewBullet.Direction.Y < (Speed / 10) then
    542         NewBullet.Direction.Y := Speed / 10;*)
     550      Speed := ExplosionBulletMinSpeed + (ExplosionBulletMaxSpeed - ExplosionBulletMinSpeed) * Random;
     551      Angle := Random * 2 * Pi;
     552      NewBullet.Direction.X := Sin(Angle) * Speed;
     553      NewBullet.Direction.Y := Cos(Angle) * Speed;
     554      NewBullet.Position.X := Position.X + NewBullet.Direction.X * 3;
     555      NewBullet.Position.Y := Position.Y + NewBullet.Direction.Y * 3;
    543556      NewBullet.MaxDistance := Random(ExplosionRange);
    544557      Bullets.Add(NewBullet);
  • trunk/UMainForm.lfm

    r11 r13  
    2020    Width = 514
    2121    Panels = <   
     22      item
     23        Width = 50
     24      end   
     25      item
     26        Width = 50
     27      end   
     28      item
     29        Width = 50
     30      end   
     31      item
     32        Width = 50
     33      end   
    2234      item
    2335        Width = 50
  • trunk/UMainForm.pas

    r11 r13  
    7777      IntToStr(TPlayer(Engine.Players[0]).Direction);
    7878    StatusBar1.Panels[2].Text := FloatToStr(RoundTo(DrawDuration / OneMillisecond, -2));
     79    StatusBar1.Panels[3].Text := IntToStr(TPlayer(Engine.Players[0]).Bullets.Count);
    7980  finally
    8081    Drawing := False;
  • trunk/tunneler.lpi

    r12 r13  
    5050        <TopLine Value="1"/>
    5151        <CursorPos X="15" Y="4"/>
    52         <UsageCount Value="78"/>
     52        <UsageCount Value="79"/>
    5353      </Unit0>
    5454      <Unit1>
     
    5858        <ResourceBaseClass Value="Form"/>
    5959        <UnitName Value="UMainForm"/>
    60         <EditorIndex Value="8"/>
    61         <WindowIndex Value="0"/>
    62         <TopLine Value="96"/>
    63         <CursorPos X="6" Y="101"/>
    64         <UsageCount Value="78"/>
     60        <EditorIndex Value="9"/>
     61        <WindowIndex Value="0"/>
     62        <TopLine Value="62"/>
     63        <CursorPos X="25" Y="78"/>
     64        <UsageCount Value="79"/>
    6565        <Loaded Value="True"/>
    6666        <LoadedDesigner Value="True"/>
     
    7373        <EditorIndex Value="0"/>
    7474        <WindowIndex Value="0"/>
    75         <TopLine Value="518"/>
    76         <CursorPos X="9" Y="535"/>
    77         <UsageCount Value="78"/>
     75        <TopLine Value="1"/>
     76        <CursorPos X="20" Y="14"/>
     77        <UsageCount Value="79"/>
    7878        <Loaded Value="True"/>
    7979      </Unit2>
     
    104104      <Unit6>
    105105        <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/objpas/classes/classesh.inc"/>
    106         <EditorIndex Value="2"/>
     106        <EditorIndex Value="3"/>
    107107        <WindowIndex Value="0"/>
    108108        <TopLine Value="19"/>
    109109        <CursorPos X="4" Y="36"/>
    110         <UsageCount Value="11"/>
     110        <UsageCount Value="12"/>
    111111        <Loaded Value="True"/>
    112112      </Unit6>
     
    143143      <Unit11>
    144144        <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/>
    145         <EditorIndex Value="1"/>
    146         <WindowIndex Value="0"/>
    147         <TopLine Value="157"/>
    148         <CursorPos X="44" Y="171"/>
    149         <UsageCount Value="31"/>
     145        <EditorIndex Value="2"/>
     146        <WindowIndex Value="0"/>
     147        <TopLine Value="152"/>
     148        <CursorPos X="1" Y="158"/>
     149        <UsageCount Value="32"/>
    150150        <Loaded Value="True"/>
    151151      </Unit11>
     
    265265        <ResourceBaseClass Value="Form"/>
    266266        <UnitName Value="UMapForm"/>
    267         <EditorIndex Value="7"/>
     267        <EditorIndex Value="8"/>
    268268        <WindowIndex Value="0"/>
    269269        <TopLine Value="1"/>
    270270        <CursorPos X="20" Y="39"/>
    271         <UsageCount Value="57"/>
     271        <UsageCount Value="58"/>
    272272        <Loaded Value="True"/>
    273273      </Unit27>
     
    288288      <Unit30>
    289289        <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/inc/mathh.inc"/>
    290         <WindowIndex Value="0"/>
    291         <TopLine Value="63"/>
    292         <CursorPos X="14" Y="80"/>
     290        <EditorIndex Value="1"/>
     291        <WindowIndex Value="0"/>
     292        <TopLine Value="58"/>
     293        <CursorPos X="14" Y="75"/>
    293294        <UsageCount Value="14"/>
     295        <Loaded Value="True"/>
    294296      </Unit30>
    295297      <Unit31>
     
    303305        <Filename Value="../../../lazarus/lcl/intfgraphics.pas"/>
    304306        <UnitName Value="IntfGraphics"/>
    305         <EditorIndex Value="6"/>
     307        <EditorIndex Value="7"/>
    306308        <WindowIndex Value="0"/>
    307309        <TopLine Value="3131"/>
    308310        <CursorPos X="42" Y="3148"/>
    309         <UsageCount Value="14"/>
     311        <UsageCount Value="15"/>
    310312        <Loaded Value="True"/>
    311313      </Unit32>
     
    335337      <Unit36>
    336338        <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericBitmap.inc"/>
    337         <EditorIndex Value="4"/>
     339        <EditorIndex Value="5"/>
    338340        <WindowIndex Value="0"/>
    339341        <TopLine Value="25"/>
    340342        <CursorPos X="14" Y="25"/>
    341         <UsageCount Value="18"/>
     343        <UsageCount Value="19"/>
    342344        <Loaded Value="True"/>
    343345      </Unit36>
     
    400402        <IsPartOfProject Value="True"/>
    401403        <UnitName Value="UPlatform"/>
    402         <UsageCount Value="37"/>
     404        <UsageCount Value="38"/>
    403405      </Unit44>
    404406      <Unit45>
     
    428430      <Unit48>
    429431        <Filename Value="../../../lazarus/lcl/include/custombitmap.inc"/>
    430         <EditorIndex Value="5"/>
     432        <EditorIndex Value="6"/>
    431433        <WindowIndex Value="0"/>
    432434        <TopLine Value="330"/>
    433435        <CursorPos X="35" Y="338"/>
    434         <UsageCount Value="14"/>
     436        <UsageCount Value="15"/>
    435437        <Loaded Value="True"/>
    436438      </Unit48>
     
    447449        <IsPartOfProject Value="True"/>
    448450        <UnitName Value="URectangle"/>
    449         <EditorIndex Value="3"/>
     451        <EditorIndex Value="4"/>
    450452        <WindowIndex Value="0"/>
    451453        <TopLine Value="120"/>
    452454        <CursorPos X="44" Y="150"/>
    453         <UsageCount Value="22"/>
     455        <UsageCount Value="23"/>
    454456        <Loaded Value="True"/>
    455457      </Unit50>
     
    458460      <Position1>
    459461        <Filename Value="UCore.pas"/>
    460         <Caret Line="348" Column="1" TopLine="331"/>
     462        <Caret Line="375" Column="1" TopLine="354"/>
    461463      </Position1>
    462464      <Position2>
    463465        <Filename Value="UCore.pas"/>
    464         <Caret Line="349" Column="1" TopLine="331"/>
     466        <Caret Line="376" Column="1" TopLine="354"/>
    465467      </Position2>
    466468      <Position3>
    467469        <Filename Value="UCore.pas"/>
    468         <Caret Line="336" Column="35" TopLine="321"/>
     470        <Caret Line="377" Column="1" TopLine="354"/>
    469471      </Position3>
    470472      <Position4>
    471473        <Filename Value="UCore.pas"/>
    472         <Caret Line="334" Column="1" TopLine="321"/>
     474        <Caret Line="379" Column="1" TopLine="354"/>
    473475      </Position4>
    474476      <Position5>
    475477        <Filename Value="UCore.pas"/>
    476         <Caret Line="335" Column="1" TopLine="321"/>
     478        <Caret Line="385" Column="1" TopLine="357"/>
    477479      </Position5>
    478480      <Position6>
    479481        <Filename Value="UCore.pas"/>
    480         <Caret Line="336" Column="1" TopLine="321"/>
     482        <Caret Line="387" Column="1" TopLine="359"/>
    481483      </Position6>
    482484      <Position7>
    483485        <Filename Value="UCore.pas"/>
    484         <Caret Line="337" Column="1" TopLine="321"/>
     486        <Caret Line="403" Column="1" TopLine="386"/>
    485487      </Position7>
    486488      <Position8>
    487489        <Filename Value="UCore.pas"/>
    488         <Caret Line="338" Column="1" TopLine="321"/>
     490        <Caret Line="404" Column="1" TopLine="386"/>
    489491      </Position8>
    490492      <Position9>
    491493        <Filename Value="UCore.pas"/>
    492         <Caret Line="339" Column="1" TopLine="321"/>
     494        <Caret Line="405" Column="1" TopLine="386"/>
    493495      </Position9>
    494496      <Position10>
    495497        <Filename Value="UCore.pas"/>
    496         <Caret Line="340" Column="1" TopLine="321"/>
     498        <Caret Line="410" Column="1" TopLine="386"/>
    497499      </Position10>
    498500      <Position11>
    499501        <Filename Value="UCore.pas"/>
    500         <Caret Line="343" Column="1" TopLine="321"/>
     502        <Caret Line="411" Column="1" TopLine="386"/>
    501503      </Position11>
    502504      <Position12>
    503505        <Filename Value="UCore.pas"/>
    504         <Caret Line="344" Column="1" TopLine="321"/>
     506        <Caret Line="371" Column="1" TopLine="354"/>
    505507      </Position12>
    506508      <Position13>
    507509        <Filename Value="UCore.pas"/>
    508         <Caret Line="345" Column="1" TopLine="321"/>
     510        <Caret Line="372" Column="1" TopLine="354"/>
    509511      </Position13>
    510512      <Position14>
    511513        <Filename Value="UCore.pas"/>
    512         <Caret Line="346" Column="1" TopLine="321"/>
     514        <Caret Line="373" Column="1" TopLine="354"/>
    513515      </Position14>
    514516      <Position15>
    515517        <Filename Value="UCore.pas"/>
    516         <Caret Line="348" Column="1" TopLine="321"/>
     518        <Caret Line="375" Column="1" TopLine="354"/>
    517519      </Position15>
    518520      <Position16>
    519521        <Filename Value="UCore.pas"/>
    520         <Caret Line="349" Column="1" TopLine="321"/>
     522        <Caret Line="376" Column="1" TopLine="354"/>
    521523      </Position16>
    522524      <Position17>
    523525        <Filename Value="UCore.pas"/>
    524         <Caret Line="350" Column="1" TopLine="322"/>
     526        <Caret Line="377" Column="1" TopLine="354"/>
    525527      </Position17>
    526528      <Position18>
    527529        <Filename Value="UCore.pas"/>
    528         <Caret Line="351" Column="39" TopLine="324"/>
     530        <Caret Line="379" Column="1" TopLine="354"/>
    529531      </Position18>
    530532      <Position19>
    531533        <Filename Value="UCore.pas"/>
    532         <Caret Line="334" Column="1" TopLine="324"/>
     534        <Caret Line="385" Column="1" TopLine="357"/>
    533535      </Position19>
    534536      <Position20>
    535537        <Filename Value="UCore.pas"/>
    536         <Caret Line="378" Column="9" TopLine="364"/>
     538        <Caret Line="387" Column="1" TopLine="359"/>
    537539      </Position20>
    538540      <Position21>
    539541        <Filename Value="UCore.pas"/>
    540         <Caret Line="81" Column="20" TopLine="63"/>
     542        <Caret Line="403" Column="1" TopLine="386"/>
    541543      </Position21>
    542544      <Position22>
    543545        <Filename Value="UCore.pas"/>
    544         <Caret Line="394" Column="1" TopLine="362"/>
     546        <Caret Line="404" Column="1" TopLine="386"/>
    545547      </Position22>
    546548      <Position23>
    547549        <Filename Value="UCore.pas"/>
    548         <Caret Line="349" Column="14" TopLine="332"/>
     550        <Caret Line="377" Column="10" TopLine="366"/>
    549551      </Position23>
    550552      <Position24>
    551553        <Filename Value="UCore.pas"/>
    552         <Caret Line="741" Column="27" TopLine="735"/>
     554        <Caret Line="175" Column="9" TopLine="158"/>
    553555      </Position24>
    554556      <Position25>
    555557        <Filename Value="UCore.pas"/>
    556         <Caret Line="514" Column="32" TopLine="504"/>
     558        <Caret Line="555" Column="3" TopLine="537"/>
    557559      </Position25>
    558560      <Position26>
    559         <Filename Value="UCore.pas"/>
    560         <Caret Line="344" Column="18" TopLine="328"/>
     561        <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/>
     562        <Caret Line="158" Column="1" TopLine="152"/>
    561563      </Position26>
    562564      <Position27>
    563565        <Filename Value="UCore.pas"/>
    564         <Caret Line="376" Column="22" TopLine="360"/>
     566        <Caret Line="374" Column="12" TopLine="363"/>
    565567      </Position27>
    566568      <Position28>
    567569        <Filename Value="UCore.pas"/>
    568         <Caret Line="528" Column="31" TopLine="518"/>
     570        <Caret Line="545" Column="6" TopLine="536"/>
    569571      </Position28>
    570572      <Position29>
    571573        <Filename Value="UCore.pas"/>
    572         <Caret Line="530" Column="26" TopLine="518"/>
     574        <Caret Line="565" Column="106" TopLine="561"/>
    573575      </Position29>
    574576      <Position30>
    575577        <Filename Value="UCore.pas"/>
    576         <Caret Line="15" Column="27" TopLine="1"/>
     578        <Caret Line="521" Column="3" TopLine="519"/>
    577579      </Position30>
    578580    </JumpHistory>
Note: See TracChangeset for help on using the changeset viewer.