/*
 * Garbage.cpp
 *
 *  Created on: 2009-07-11
 *      Author: wasyl
 */

#include <cmath>
#include <allegro5/a5_primitives.h>

#include "Spikes.h"
#include "../prep/res/Resources.h"
#include "../prep/misc/Vector2D.h"
#include "Level.h"
#include "Game.h"

Spikes::Spikes()
{
	Resources::load(mSprite, "media/tilesheet.png");
	mWorld = NULL;
}

Spikes::~Spikes()
{
}

void Spikes::update(double dt)
{
	Entity *avatar = mWorld->entity(ID("avat"));
	bool hit = avatar->bbox().contains(mPos + Vec(0, 18));
	hit |=     avatar->bbox().contains(mPos + Vec(10, 18));
	hit |=     avatar->bbox().contains(mPos + Vec(20, 18));

	if (hit)
	{
		Avatar *a = (Avatar*)avatar;
		a->die("ate some spiky death");
	}
}

void Spikes::render()
{
	al_draw_bitmap(mSprite->get(5), mPos.x, mPos.y, 0);
}
