<commit_before>#include "PlayerUFO.h"

//---------------------------------------------------------------
//						CONSTRUCTORS & DESTRUCTOR
//---------------------------------------------------------------
PlayerUFO::PlayerUFO(void)
{
	PlayerModel* p = new PlayerModel;
	pModel = (Model*)p;
	pos = new GLfloat[3];
	pos[0] = 0.0f;
	pos[1] = 0.0f;
	pos[2] = 0.0f;
	box = new BoundingBox(pos[0],pos[1],pos[2],pos[0]+1.0f,pos[1]+0.5f,pos[2]+1.0f, true);
	ct = new CollisionTester;
	ct->staticBoxes.push_back(box);
        updateLights(pos[0], pos[1], pos[2]);
}

PlayerUFO::PlayerUFO(GLfloat x, GLfloat z)
{
	PlayerModel* p = new PlayerModel;
	pModel = (Model*)p;
	pos = new GLfloat[3];
	pos[0] = x;
	pos[1] = 0;
	pos[2] = z;
	box = new BoundingBox(pos[0],pos[1],pos[2],pos[0]+1.0f,pos[1]+0.5f,pos[2]+1.0f, true);
	ct = new CollisionTester;
	ct->staticBoxes.push_back(box);

        //LIGHTING
        updateLights(pos[0], pos[1], pos[2]);
}

PlayerUFO::~PlayerUFO(void)
{
	if (pModel != NULL) {
		delete pModel;
		pModel = NULL;
	}
}

//---------------------------------------------------------------
//						LIGHTS
//---------------------------------------------------------------
void PlayerUFO::updateLights(GLfloat xPos, GLfloat yPos, GLfloat zPos)
{
        spotLight = new SpotLight(0.3f, 0.9f, 0.1f, 0.0f);
        light = new LightPost(xPos+0.5f, yPos, zPos+0.5f, 0, -1, 0);
        glLightfv(GL_LIGHT7, GL_AMBIENT, spotLight->getAmbient()); //Setup ambient lighting
        glLightfv(GL_LIGHT7, GL_DIFFUSE, spotLight->getDiffuse()); // Setup diffuse lighting
        glLightfv(GL_LIGHT7, GL_SPECULAR, spotLight->getSpecular());
        glLightfv(GL_LIGHT7, GL_POSITION, light->getPositionArray()); // Setup the lighting 
        glLightf(GL_LIGHT7, GL_SPOT_CUTOFF, 25.0f);
        glLightf(GL_LIGHT7, GL_SPOT_EXPONENT, 0);
        glLightfv(GL_LIGHT7, GL_SPOT_DIRECTION, light->getDirectionArray());
        glEnable(GL_LIGHT7);
}


//---------------------------------------------------------------
//						DRAW
//---------------------------------------------------------------
void PlayerUFO::draw(){
	incrementHeight(false);
	glPushMatrix();
                box->draw();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(pos[0],pos[1],pos[2]);
		pModel->draw();
	glPopMatrix();
        updateLights(pos[0], pos[1], pos[2]);
}

//---------------------------------------------------------------
//			TRANSLATE UFO (AND BOUNDING BOX)
//---------------------------------------------------------------
void PlayerUFO::incrementHeight(bool positive){
	if(positive){
		if(pos[1]+0.5f <= MAX_PLAYER_HEIGHT){
			pos[1] += 0.5f;
			box->lockBox(pos[0],pos[1],pos[2]);
		}
                if(pos[1]+0.3 > MAX_PLAYER_HEIGHT){
                    pos[1] = MAX_PLAYER_HEIGHT-0.3;
                   box->lockBox(pos[0],pos[1],pos[2]);
                }
	}
	else{
		if(pos[1]-0.02f >= MIN_PLAYER_HEIGHT&&
		!ufoCollisionTest(pos[0],pos[1]-0.02f,pos[2])){
			pos[1] -= 0.2f;
			box->lockBox(pos[0],pos[1],pos[2]);
		}
	}
        updateLights(pos[0], pos[1], pos[2]);
}

void PlayerUFO::incrementXPos(bool positive){
	if(positive){
		if(!ufoCollisionTest(pos[0]+0.05f,pos[1],pos[2])){
			pos[0] += 0.05f;
			box->moveBox(0.05f,0.0f,0.0f);
		}
	}
	else{
		if(!ufoCollisionTest(pos[0]-0.05f,pos[1],pos[2])){
			pos[0] -= 0.05f;
			box->moveBox(-0.05f,0.0f,0.0f);
		}
	}
        updateLights(pos[0], pos[1], pos[2]);
}

void PlayerUFO::incrementZPos(bool positive){
	if(positive){
		if(!ufoCollisionTest(pos[0],pos[1],pos[2]+0.05f)){
			pos[2] += 0.05f;
			box->moveBox(0.0f,0.0f,0.05f);
		}
	}
	else{
		if(!ufoCollisionTest(pos[0],pos[1],pos[2]-0.05f)){
			pos[2] -= 0.05f;
			box->moveBox(0.0f,0.0f,-0.05f);
		}
	}
        updateLights(pos[0], pos[1], pos[2]);
}

//---------------------------------------------------------------
//					COLLISION DETECTION
//---------------------------------------------------------------
bool PlayerUFO::ufoCollisionTest(GLfloat x, GLfloat y, GLfloat z){
		if(ct->collisionTest(x,y,z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x, y, z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x,	y,	z+box->size.z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x,	y,	z+box->size.z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x,	y+box->size.y,	z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x,	y+box->size.y,	z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x,	y+box->size.y,	z+box->size.z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x,	y+box->size.y,	z+box->size.z,box->movingBoxId)){
			return true;
		}

		return false;
}<commit_msg>fixed a warning<commit_after>#include "PlayerUFO.h"

//---------------------------------------------------------------
//						CONSTRUCTORS & DESTRUCTOR
//---------------------------------------------------------------
PlayerUFO::PlayerUFO(void)
{
	PlayerModel* p = new PlayerModel;
	pModel = (Model*)p;
	pos = new GLfloat[3];
	pos[0] = 0.0f;
	pos[1] = 0.0f;
	pos[2] = 0.0f;
	box = new BoundingBox(pos[0],pos[1],pos[2],pos[0]+1.0f,pos[1]+0.5f,pos[2]+1.0f, true);
	ct = new CollisionTester;
	ct->staticBoxes.push_back(box);
        updateLights(pos[0], pos[1], pos[2]);
}

PlayerUFO::PlayerUFO(GLfloat x, GLfloat z)
{
	PlayerModel* p = new PlayerModel;
	pModel = (Model*)p;
	pos = new GLfloat[3];
	pos[0] = x;
	pos[1] = 0;
	pos[2] = z;
	box = new BoundingBox(pos[0],pos[1],pos[2],pos[0]+1.0f,pos[1]+0.5f,pos[2]+1.0f, true);
	ct = new CollisionTester;
	ct->staticBoxes.push_back(box);

        //LIGHTING
        updateLights(pos[0], pos[1], pos[2]);
}

PlayerUFO::~PlayerUFO(void)
{
	if (pModel != NULL) {
		delete pModel;
		pModel = NULL;
	}
}

//---------------------------------------------------------------
//						LIGHTS
//---------------------------------------------------------------
void PlayerUFO::updateLights(GLfloat xPos, GLfloat yPos, GLfloat zPos)
{
        spotLight = new SpotLight(0.3f, 0.9f, 0.1f, 0.0f);
        light = new LightPost(xPos+0.5f, yPos, zPos+0.5f, 0, -1, 0);
        glLightfv(GL_LIGHT7, GL_AMBIENT, spotLight->getAmbient()); //Setup ambient lighting
        glLightfv(GL_LIGHT7, GL_DIFFUSE, spotLight->getDiffuse()); // Setup diffuse lighting
        glLightfv(GL_LIGHT7, GL_SPECULAR, spotLight->getSpecular());
        glLightfv(GL_LIGHT7, GL_POSITION, light->getPositionArray()); // Setup the lighting 
        glLightf(GL_LIGHT7, GL_SPOT_CUTOFF, 25.0f);
        glLightf(GL_LIGHT7, GL_SPOT_EXPONENT, 0);
        glLightfv(GL_LIGHT7, GL_SPOT_DIRECTION, light->getDirectionArray());
        glEnable(GL_LIGHT7);
}


//---------------------------------------------------------------
//						DRAW
//---------------------------------------------------------------
void PlayerUFO::draw(){
	incrementHeight(false);
	glPushMatrix();
                box->draw();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(pos[0],pos[1],pos[2]);
		pModel->draw();
	glPopMatrix();
        updateLights(pos[0], pos[1], pos[2]);
}

//---------------------------------------------------------------
//			TRANSLATE UFO (AND BOUNDING BOX)
//---------------------------------------------------------------
void PlayerUFO::incrementHeight(bool positive){
	if(positive){
		
		if(pos[1]+0.5f <= MAX_PLAYER_HEIGHT){
			pos[1] += 0.5f;
			box->lockBox(pos[0],pos[1],pos[2]);
		}
                if(pos[1]+0.3 > MAX_PLAYER_HEIGHT){
                    pos[1] = MAX_PLAYER_HEIGHT-0.3f;
                   box->lockBox(pos[0],pos[1],pos[2]);
                }
				
	}
	else{
		if(pos[1]-0.02f >= MIN_PLAYER_HEIGHT&&
		!ufoCollisionTest(pos[0],pos[1]-0.02f,pos[2])){
			pos[1] -= 0.2f;
			box->lockBox(pos[0],pos[1],pos[2]);
		}
	}
        updateLights(pos[0], pos[1], pos[2]);
}

void PlayerUFO::incrementXPos(bool positive){
	if(positive){
		if(!ufoCollisionTest(pos[0]+0.05f,pos[1],pos[2])){
			pos[0] += 0.05f;
			box->moveBox(0.05f,0.0f,0.0f);
		}
	}
	else{
		if(!ufoCollisionTest(pos[0]-0.05f,pos[1],pos[2])){
			pos[0] -= 0.05f;
			box->moveBox(-0.05f,0.0f,0.0f);
		}
	}
        updateLights(pos[0], pos[1], pos[2]);
}

void PlayerUFO::incrementZPos(bool positive){
	if(positive){
		if(!ufoCollisionTest(pos[0],pos[1],pos[2]+0.05f)){
			pos[2] += 0.05f;
			box->moveBox(0.0f,0.0f,0.05f);
		}
	}
	else{
		if(!ufoCollisionTest(pos[0],pos[1],pos[2]-0.05f)){
			pos[2] -= 0.05f;
			box->moveBox(0.0f,0.0f,-0.05f);
		}
	}
        updateLights(pos[0], pos[1], pos[2]);
}

//---------------------------------------------------------------
//					COLLISION DETECTION
//---------------------------------------------------------------
bool PlayerUFO::ufoCollisionTest(GLfloat x, GLfloat y, GLfloat z){
		if(ct->collisionTest(x,y,z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x, y, z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x,	y,	z+box->size.z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x,	y,	z+box->size.z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x,	y+box->size.y,	z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x,	y+box->size.y,	z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x,	y+box->size.y,	z+box->size.z,box->movingBoxId)){
			return true;
		}
		if(ct->collisionTest(x+box->size.x,	y+box->size.y,	z+box->size.z,box->movingBoxId)){
			return true;
		}

		return false;
}
{'fraction_non_alphanumeric': 0.3112758073054526, 'fraction_numerical': 0.040021175224986764, 'mean_word_length': 2.0698732531686708, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6582357', 'n_tokens_mistral': 4008, 'n_tokens_neox': 3683, 'n_words': 496}