unit g_miniMap;

interface
uses
  g_Data,g_Types,
  {$INCLUDE uses.inc};

procedure Init_MiniMap(self : zMiniMap);
procedure Draw_MiniMap(self : zMiniMap);
implementation

procedure Init_MiniMap(self : zMiniMap);
begin
  self^.rad := 100;
  self^.size := self^.rad*2;
  self^.pos[0] := Options.ScreenWidth-self^.rad-10;
  self^.pos[1] := self^.rad;
end;

procedure Draw_MiniMap(self : zMiniMap);
var
  i : word;
  w,h : float;
  pos : izPosition_f;
begin
  pos[0] := -Camera.Pos[0] + self^.pos[0]-self^.rad;
  pos[1] := -Camera.Pos[1] + self^.pos[1]-self^.rad;
  w := World.MapSize[0]/self^.size;
  h := World.MapSize[1]/self^.size;
  glPushAttrib(GL_CURRENT_BIT);

  glEnable(GL_Blend);
  glColor4f(1,1,1,0.3);
  glBegin(GL_QUADS);
    glVertex2f(pos[0],pos[1]);
    glVertex2f(pos[0],pos[1]+self^.Size);
    glVertex2f(pos[0]+self^.Size,pos[1]+self^.Size);
    glVertex2f(pos[0]+self^.Size,pos[1]);
  glEnd();
  glDisable(GL_Blend);

  //***Рисуем монстров***\\
  i := World.MonsterTypeCount;
  glColor3f(1,0,0);
  glPointSize(4);
  glBegin(GL_POINTS);
  while i<World.EndCharAC do begin
  if World.Characters[i].State <> csDead then
    glVertex2f(pos[0]+World.Characters[i].pos[0]/w,
               pos[1]+World.Characters[i].pos[1]/h);
    inc(i);
  end;
  glEnd();

  glColor3f(0,0,1);
  glPointSize(8);
  glBegin(GL_POINTS);
  //***Рисуем пушки***\\
  i:=World.TowerTypeCount;
  while i<World.TowerCount do begin
    glVertex2f(pos[0]+World.Tower[i].pos[0]/w,
               pos[1]+World.Tower[i].pos[1]/h);
    inc(i);
  end;
  glEnd;

  //***Рисуем базу***\\
  glColor3f(0,0,0);
  glPointSize(20);
  glBegin(GL_POINTS);
    glVertex2f(pos[0]+World.Base.pos[0]/w,
               pos[1]+World.Base.pos[1]/h);
  glEnd;
  glPopAttrib;
end;

end.
