unit ugmph;

{$mode delphi}

interface

uses
  uGMPL, zglHeader, uGMPLib, uGMPBul;

type

{ TGMPH }

TGMPH = class(TGMPL)
  constructor Create;
  procedure Control; override;
  procedure Live0; override;
// procedure OnBul(Demage : Single; ATempC : Integer; Dir : ZPos); override;
end;

implementation
uses
  uGlobal, ugmppart, GSound;

{ TGMPH }

constructor TGMPH.Create;
begin
  Size.x := chsize;
  Size.y := chsize;
  Pos.X := WinW / 2;
  Pos.Y := WinH / 2;
  Speed := 2;
  Gun := 1;
  Live := 200;
  Color:= $32DF32;

  GunMag[1].Count1 :=  10;
  GunMag[1].Count2 := 120;

  GunMag[2].Count1 :=  10;
  GunMag[2].Count2 := 120;

  GunMag[3].Count1 :=  10;
  GunMag[3].Count2 := 120;

  GunMag[4].Count1 :=  10;
  GunMag[4].Count2 := 120;
end;

procedure TGMPH.Control;
var
  OldGun : Integer;
begin
  Color:= $32DF32;
  Move.X := 0;
  Move.Y := 0;
  if (key_Down(K_W) or key_Down(K_UP)) and (Pos.y > 64+chsize) then
    Move.Y := Move.Y - 1;
  if (key_Down(K_A) or key_Down(K_LEFT)) and (Pos.X > chsize) then
    Move.X := Move.X - 1;
  if (key_Down(K_S) or key_Down(K_DOWN)) and (Pos.Y < WinH - chsize)then
    Move.Y := Move.Y + 1;
  if (key_Down(K_D) or key_Down(K_RIGHT)) and (Pos.X < WinW - chsize) then
    Move.X := Move.X + 1;

  Dir.SetValue(mouse_X - Pos.x, mouse_Y - Pos.y);

  Dir.Normalize;

  Fire := mouse_Down(M_BLEFT) and (mouse_Y > 64);

  OldGun := Gun;

  if key_Down(K_R) then
  begin
    Regun:= true;
    PlaySound(5 + Gun);
  end;

  if key_Down(K_1) then
    Gun:= 1;
  if key_Down(K_2) then
    Gun:= 2;
  if key_Down(K_3) then
    Gun:= 3;
  if key_Down(K_4) then
    Gun:= 4;
  if OldGun <> Gun then
    Regun:=false;

end;

procedure TGMPH.Live0;
begin
  GMP.Lose;
end;

end.

