Subversion Repositories AndroidProjects

Rev

Blame | Last modification | View Log | RSS feed

unit app_particle_flowers;

interface

uses sux_constant, sux_object, app_constant, resource_texture,
     resource_list, app_particle_main, app_particle_part;

type
  TFlowers=record
  end;
  SAPFlowers=class(SAParticle)
    flowers: TFlowers;

    procedure addFlowers(const pos: SXVertex2D);

    procedure onTimerFlowers;
    procedure onTimer; override;

    procedure initialize; override;
    constructor Create(const parent: TObject);
    destructor Destroy; override;
  end;

implementation

uses main, gl_main, OpenGL;


// --- SAPFlowers


procedure SAPFlowers.addFlowers(const pos: SXVertex2D);
var p: SXInt;
    part: SAPPart;
    partpos: SXVertex2D;
    partmove: SXVertex2D;
begin
  for p := 0 to 2 do
  begin
    partpos.x := pos.x + sx.math.random.getRandomFloat(-8, 8);
    partpos.y := pos.y + sx.math.random.getRandomFloat(-8, 8);
    part := addParticle(0, partpos, sx.math.random.getRandomFloat(0, 360), sx.math.random.getRandomFloat(1, 2));
    part.setDensity(1.0);

    partmove.x := sx.math.random.getRandomFloat(-1, 1);
    partmove.y := sx.math.random.getRandomFloat(-1, 1);
    partmove := sx.math.multiplyVertex(partmove, sx.math.random.getRandomFloat(4, 15));

    part.setAnimation(partmove, 0, 4, sx.convert.ColorRGBOf(0, 0, 0), -0.1);
  end;
end;




procedure SAPFlowers.onTimerFlowers;
var p: SXInt;
    part: SAPPart;
begin
  for p := parts.getMax downto 0 do
  begin
    part := SAPPart(parts.getObject(p));
    if (part.settings.lifetime > 1.6) then part.settings.animation.addsize := 0;
    if (part.settings.lifetime > 3.4) then part.settings.animation.adddensity := -1;
  end;
end;


procedure SAPFlowers.onTimer;
begin
  onTimerFlowers;
  onTimerParts;
  deleteIfEmpty;
end;




procedure SAPFlowers.initialize;
begin
end;


constructor SAPFlowers.Create(const parent: TObject);
begin
  inherited Create(parent);

  setupAppearance(app.scene.board.settings.flower, 1);
  setBlending(SX_GL_BLEND_AVERAGE);
end;


destructor SAPFlowers.Destroy;
begin
  inherited;
end;


end.