#include "main.h"

/*
Constructor for the explosion class.
*/
EXPLO::EXPLO( int _x, int _y, int _size, bool _sound ) {
  id = ID_EXPLO;
  x = _x;
  y = _y;
  size = _size;
  scale = (size / 64.0);
  frame = 0;
  angle = random()%256;
  tbmp = create_bitmap(size,size);
  remove = false;
}

/*
Destructor for the explosion class.
*/
EXPLO::~EXPLO() {
  destroy_bitmap(tbmp);
}

/*
Draws the explosion.
*/
void EXPLO::draw() {
  drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
  draw_trans_sprite(buffer, (BITMAP *)gfxdata[FLARE1_BMP+2].dat, x-24, y-24);
  if (size != 64) {
    clear(tbmp);
    rotate_scaled_sprite(tbmp, _explodata(frame), 0, 0, itofix(angle), ftofix(scale));
    draw_trans_sprite(buffer, tbmp, x-(size>>1), y-(size>>1));
  } else {
    draw_trans_sprite(buffer, _explodata(frame), x-(size>>1), y-(size>>1));
  }
  drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
}

/*
Performs any needed calculations.
*/
void EXPLO::move() {
  if (size != 64) frame++;
  frame++;
  if (frame > 24) {
    remove = true;
    frame = 24;
  }
}

/*
Returns true when the entity can be removed from the list.
*/
bool EXPLO::done() {
  return remove;
}

/*
Explosions need no collision detection.
*/
void EXPLO::collide(ENTITY *other) {
}

/*
Get functions to allow access to private data inside the class.
*/
int EXPLO::get_x() {
  return x;
}

int EXPLO::get_y() {
  return y;
}

int EXPLO::get_id() {
  return id;
}

int EXPLO::get_va() {
  return 0;
}

float EXPLO::get_xa() {
  return 0;
}

float EXPLO::get_ya() {
  return 0;
}

int EXPLO::get_owner() {
  return -1;
}

/* END */
