#include "objekt.h"
#include <allegro.h>

Objekt::Objekt() //konstruktor
{
px=0;
py=0;
speed=0;
uhol=0;
health = 1;
max_health = 1;
dalsia = predosla = NULL;
bitmap = NULL;
obrazok = NULL;

  max_speed = 0.0;
  zrychlenie = 0.0;
  otacanie = 0.0;
  uhol = 0;
  speed = zrychlenie;
}

Objekt::~Objekt()
{
 destroy_bitmap(obrazok);
}

void Objekt::Nakresli() //inak to kompilator nezere
{}

void Objekt::Pohni()
{
  SetSx((GetSpeed()*sin(GetUhol()*pi180)));
  SetSy((GetSpeed()*cos(GetUhol()*pi180)));
  SetPx(GetPx() + GetSx()); 
  SetPy(GetPy() + GetSy()); 
  if(GetPy()<=768/10 + 25) //ked sa dostane nad hladinu mora
  {
    if(GetUhol() <= 180 && GetUhol() > 75)
      SetUhol(GetUhol() - GetOtacanie()*5);
    if(GetUhol() > 180 && GetUhol() < 285)
      SetUhol(GetUhol() + GetOtacanie()*5);
    SetSpeed(GetSpeed() - 0.02);
    if(GetSpeed()<=0.15)
      SetSpeed(0.15); 
    if(GetSy()<=0)
      SetSy(0.1);  
  }
  SetPrebijanie(GetPrebijanie() + 1);
}
