#include "StdAfx.h"
#include "FragileBlock.h"

#include "OGLrendrer.h"
#include "Level.h"

extern Level *myLvl;

FragileBlock::FragileBlock(int x_, int y_)
{
	x = x_;
	y = y_;
}


FragileBlock::~FragileBlock(void)
{
}

void 
FragileBlock::draw(OGLrendrer *ogl)
{
	void(__stdcall* glMultiTexCoord2dARB)(GLenum, double,double)=(void(__stdcall*)(GLenum,double,double))ogl->getGlProcAddress("glMultiTexCoord2dARB");

	glBindTexture(GL_TEXTURE_2D, 1);

	glBegin(GL_QUADS);
		glMultiTexCoord2dARB(GL_TEXTURE0_ARB,0.25,1.0); glVertex3f(x, y, 1);
		glMultiTexCoord2dARB(GL_TEXTURE0_ARB,0.25,0.0); glVertex3f(x, y+1, 1);
		glMultiTexCoord2dARB(GL_TEXTURE0_ARB,0.50,0.0); glVertex3f(x+1, y+1, 1);
		glMultiTexCoord2dARB(GL_TEXTURE0_ARB,0.50,1.0); glVertex3f(x+1, y, 1);
	glEnd();

	drawBomb(ogl);
}

void 
FragileBlock::leaveSquare()
{
	//Disintegrate. 
	Block::leaveSquare();

	myLvl->removeBlock(this);
	delete this;
}

bool 
FragileBlock::canStop()
{
	return true;
}

bool 
FragileBlock::canMove()
{
	return false;
}