unit uSmoke;

interface

uses zglHeader, uVar;

procedure Smoke_Add(x, y, r, a: single);
procedure Smoke_Draw();
procedure Smoke_Update;

implementation

procedure Smoke_Add(x, y, r, a: single);
var i: integer;
begin
  for I := 0 to 511 do
    if not smoke[i].exist then
      begin
        smoke[i].exist := true;
        smoke[i].x     := x;
        smoke[i].y     := y;
        smoke[i].r     := r;
        smoke[i].a     := a;
        smoke[i].frame := 1;
        break;
      end;
end;

procedure Smoke_Draw();
var i: integer; a: single;
begin
  for I := 0 to 511 do
    if smoke[i].exist then
       begin
         a := m_Angle(smoke[i].x, smoke[i].y, 1000, smoke[i].y);
         ASprite2d_draw( texSmoke, smoke[i].x - 64 , smoke[i].y - 64 , smoke[i].r*2 , smoke[i].r*2, smoke[i].a, smoke[i].frame, 255 - smoke[i].frame*5);
       end;
end;

procedure Smoke_Update;
var i : integer;
begin
  for I := 0 to 511 do
    if smoke[i].exist then
      begin
        inc(smoke[i].frame);
        if smoke[i].frame > 12 then smoke[i].exist := false;
      end;
      
end;

end.
