void Powerup::update()
{
	if (GameState::getInt(mKind) != 0)
	{
		return;
	}

	Hero *hero = getRoom()->getHero();
	Entity::CollisionRect cr = hero->getCollisionRect();
	if (Collides(getCollisionRect(), cr))
	{
		GameState::put(mKind, 1);
		std::string explanation;
		PowerUpScreen* screen;
		if (mKind == GameState::POWERUP_HIJUMP) {
			screen = new PowerUpScreen("HI JUMP SOCKS", "JUMP HIGHER");
		} else if (mKind == GameState::POWERUP_GUN) {
			screen = new PowerUpScreen("POWER GUN", "USE Z");
		} else if (mKind == GameState::POWERUP_GRENADE) {
			screen = new PowerUpScreen("GRAVITY GRANADE", "USE X");
		}
		
		ScreenManager::add(screen);
	}

	mFrame++;
}
void Savepoint::update()
{
	mFrame++;

	if (mTextCounter > 0)
	{
		mTextCounter--;
	}

	Hero *hero = getRoom()->getHero();
	Entity::CollisionRect cr= hero->getCollisionRect();
	bool heroOn = Collides(getCollisionRect(), cr);

	if (heroOn && !mHeroOn)
	{
		// SAVE
		GameState::put(GameState::LOCATION_X, getRoom()->getWorldOffsetX() * getRoom()->getTileWidth() + this->getPosition().x);
		GameState::put(GameState::LOCATION_Y, getRoom()->getWorldOffsetY() * getRoom()->getTileHeight() + this->getPosition().y + 10);
		GameState::saveToFile();
		Sound::playSample("data/sounds/coin.wav");
		mTextCounter = 50;
	}

	mHeroOn = heroOn;
}
void Weapon::Logic(vector<int> map, int width, cBicho* player) {

	cRect body;
	player->GetArea(&body);
	if (Collides(&body) && enemy_id == -1) {
		player->hurt(attackPower);
		enemy_id = 1;
		Sound::getInstance()->playHit();
	}


	if (enemy_id >= 1 && attackDelay < 11) {
		int ex, ey, ix, iy, ew, eh;
		player->GetPosition(&ex, &ey);
		player->GetWidthHeight(&ew, &eh);
		ix = x + w / 2;
		iy = y + h / 2;
		if (ex + ew / 2 < ix) ex = ex - 1;
		else ex = ex + 1;
		if (ey + eh / 2< iy) ey = ey - 1;
		else ey = ey + 1;
		player->SetPosition(ex, ey);
		++attackDelay;
	}

}
void Weapon::Logic(vector<int> map, int width, vector<cBicho*> enemies) {
	for (int i = 0; i < enemies.size() && enemy_id < 0; ++i)
	{
		cRect body;
		enemies[i]->GetArea(&body);
		if (Collides(&body)) {
			enemies[i]->hurt(attackPower);
			enemy_id = i;
			Sound::getInstance()->playHit();
		}
	}

	if (enemy_id >= 0 && attackDelay < 11) {
		int ex, ey, ix, iy, ew, eh;
		enemies[enemy_id]->GetPosition(&ex, &ey);
		enemies[enemy_id]->GetWidthHeight(&ew, &eh);
		//player->GetPosition(&ix, &iy);
		ix = x + w / 2;
		iy = y + h / 2;
		if (ex + ew / 2 < ix) ex = ex - 1;
		else ex = ex + 1;
		if (ey + eh / 2< iy) ey = ey - 1;
		else ey = ey + 1;
		enemies[enemy_id]->SetPosition(ex, ey);
		++attackDelay;

	}
}
void WallOfDeathStarter::update()
{
	if (!myUsed && Collides(mRoom->getHero()->getCollisionRect(), getCollisionRect()))
	{
		mRoom->broadcastStartWallOfDeath();
		myUsed = true;
	}
}
Exemple #6
0
Entity* Entity::Collides() {
	for (vector<Entity*>::iterator i = entities->begin(); i != entities->end(); i++) {
		Entity* entity = *i;

		if (Collides(this, entity))
			return entity;
	}
	return NULL;
}
Exemple #7
0
void Spike::update()
{
 	Hero* hero = mRoom->getHero();
	
	if (Collides(hero->getCollisionRect(), getCollisionRect()))
	{
		hero->kill();
	}
}
void Hero::checkEnemies(){
	std::vector<Entity*> entities;
	entities=mRoom->getEnemies();
	for (int i=0;i<entities.size();i++){
	  Entity::CollisionRect cr = entities[i]->getCollisionRect();
	  if(Collides(getCollisionRect(),cr)){
			die();
		}
	}
}
Exemple #9
0
void cShoot::Logic(cBicho &terra, vector<cBicho> *caixes, vector<vector<int>> &map) {
        float yaux;
        float x,y,z;
                GetPosition(&x,&y,&z);
                iner -= 0.0015;
                if (iner < 0) iner = 0.0;
                yaux=y;
                int tx,ty;
				//if(!(rotV >= -5 && rotV <= 5 && y>=3.95 && y<=4.01)) y-=0.03;
				y-=0.03;
                int suelo;
                suelo = ((int)floor(y))/4;
                GetTile(&tx,&ty);
                SetPosition(x,y,z);
                cRect rect;
                terra.GetArea(&rect);
                if(!Collides(&rect)) {
					bool b=false;
                    for(int i=-1;i<=1 && !b;++i) {
                        for(int j=-1;j<=1 && !b;++j) {
                            //if(!(i==0 && j==0)) {
                            if(map[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)]!=0) {
                                caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                                if(Collides(&rect)) {
                                    //y = yaux;
                                    //caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetPosition();
									b=true;
                                    y=rect.ymax;
									if(rotV<0)rotV -= 2*rotV; 
									//rotV -= 2*rotV;
                                    //rotV -= 2*rotV;
                                }
                            }
                        }
                    }
                }
                else {
                        y = yaux;
                        rotV -= 2*rotV;
                }
                SetPosition(x,y,z);
}
void BossFloor::update()
{
	myFrameCounter++;

	if (!myActive)
		return;

	if (Collides(mRoom->getHero()->getCollisionRect(), getCollisionRect()))
	{
		mRoom->getHero()->kill();
	}

	if (myFrameCounter > 60)
		myActive = false;
}
Exemple #11
0
void BossSaw::update()
{
	myFrameCounter++;

	if (myFrameCounter > myLifeTime)
		remove();

	setPosition(getPosition() + mySpeed);


	if (Collides(mRoom->getHero()->getCollisionRect(), getCollisionRect()))
	{
		mRoom->getHero()->kill();
	}
}
Exemple #12
0
bool InputEntity::MouseButtonDown(const SDL_Event& sdlEvent)
{
	if(visible)
	{
		if(NULL == input) SetValue("");
		if(Collides(sdlEvent.motion.x, sdlEvent.motion.y))
		{
			focused = true;
			AUDIOMODULE.PlaySample("click.wav");
		}
		else
		{
			focused = false;
			strip->SetVisible(false);
		}
	}
	return false;
}
Exemple #13
0
void Spell::UpdatePos(float dt) {
	if (direction == UP) {
		dy=-speed*dt;
	} else if (direction == DOWN) {
		dy=speed*dt;
	} else if (direction == LEFT) {
		dx=-speed*dt;
	} else if (direction == RIGHT) {
		dx=speed*dt;
	}

	xPos+=dx;
	yPos+=dy;

	distance += abs(dx) + abs(dy);

	Entity* entity = Collides();
	if (entity) {
		Impact(entity);
	}
	
}
void cEntity::Jump(boxCollider *Map)
{
	if (!jumping)
	{
		if (Collides(GetCollider(), Map))
		{
			jumping = true;
			jump_alfa = 0;
			jump_y = Position.y;
			
			if (state != ANIM_JUMP)
			{
				state = ANIM_JUMP;
				seq = 0;
				delay = 0;
				Model->SetAnimation(state);
			}
			
		}
	}


}
void SimpleWalkingMonster::update()
{
	switch(mState)
	{
	case State_Walking:
		{
			mVelocity.y += 6.0f;
			mVelocity.x = 20.0f * ((mFacing==Facing_Left)?-1:1);

			setVelocity(mVelocity);
			int bumps = moveWithCollision();

			if ((bumps & (Direction_Up | Direction_Down)) != 0) 
			{
				mVelocity.y = 0;
			}

			if ((bumps & (Direction_Left)) != 0)
			{
				mFacing = Facing_Right;
			}

			if ((bumps & (Direction_Right)) != 0)
			{
				mFacing = Facing_Left;
			}


			int offsetX = (mState==Facing_Right)?-getHalfSize().x-2:getHalfSize().x+2;
			int offsetY = getHalfSize().y+2;
		
			float2 position = getPosition();

			int x = (position.x+offsetX) / (float)mRoom->getTileWidth();
			int y = (position.y+offsetY) / (float)mRoom->getTileHeight();

			if (!mRoom->isCollidable(x, y))
			{
				if (mFacing == Facing_Left)
				{
					mFacing = Facing_Right;
				}
				else
				{
					mFacing = Facing_Left;
				}
			}

			if (mRand.getFloat(1.0f) < WALK_TO_IDLE_CHANCE)
			{
				mState = State_Idling;
			}
		}

		break;
	case State_Idling:

		if (mRand.getFloat(1.0f) < IDLE_TO_WALK_CHANCE)
		{
			if (mRand.getFloat(1.0f) > 0.5)
			{
				mFacing = Facing_Left;
			}
			else
			{
				mFacing = Facing_Right;
			}
			mState = State_Walking;
		}

		break;
	}

	Hero* hero = mRoom->getHero();
	if (Collides(hero->getCollisionRect(), getCollisionRect()))
	{
		hero->kill();
	}

	mFrame++;
}
Exemple #16
0
bool Display(float timeDelta)
{
	if( Device )
	{
		//update audio
		AudioUpdate();

		//keyboard
		if( ::GetAsyncKeyState('W') & 0x8000f)
		{
			TheCamera.walk(40.0f * timeDelta);
			//D3DXMATRIX forwardMovement;
			//D3DXMatrixRotationY(&forwardMovement, avatarYaw);
			//D3DXVECTOR3 v(0,0,forwardSpeed);
			//D3DXVECTOR4 vec4;
			//D3DXVec3Transform(&vec4, &v, &forwardMovement);
			//avatarDirection.x = v.x = vec4.x;
			//avatarDirection.y = v.y = vec4.y;
			//avatarDirection.z = v.z = vec4.z;
			//AvatarPosition.z += v.z;
			//AvatarPosition.x += v.x;
		}
		if( ::GetAsyncKeyState('S') & 0x8000f)
		{
			TheCamera.walk(-40.0f * timeDelta);
			//D3DXMATRIX forwardMovement;
			//D3DXMatrixRotationY(&forwardMovement, avatarYaw);
			//D3DXVECTOR3 v(0,0,-forwardSpeed);
			//D3DXVECTOR4 vec4;
			//D3DXVec3Transform(&vec4, &v, &forwardMovement);
			//avatarDirection.x = v.x = vec4.x;
			//avatarDirection.y = v.y = vec4.y;
			//avatarDirection.z = v.z = vec4.z;
			//AvatarPosition.z += v.z;
			//AvatarPosition.x += v.x;
		}
		if( ::GetAsyncKeyState('A') & 0x8000f)
		{
			TheCamera.yaw(-4.0f * timeDelta);
			//avatarYaw -= rotationSpeed;
		}
		if( ::GetAsyncKeyState('D') & 0x8000f)
		{
			TheCamera.yaw(4.0f * timeDelta);
			//avatarYaw -= rotationSpeed;
		}
		if( ::GetAsyncKeyState('I') & 0x8000f)
		{
			TheCamera.pitch(-4.0f * timeDelta);
		}
		if( ::GetAsyncKeyState('K') & 0x8000f)
		{
			TheCamera.pitch(4.0f * timeDelta);
		}

		D3DXVECTOR3 f = TheCamera.GetPosition();
		if(f.x > 190)
			f.x = 190;
		if(f.x < -190)
			f.x = -190;
		
		if(f.z > 190)
			f.z = 190;
		if(f.z < -190)
			f.z = -190;

		//if(f.y > 390)
		//	f.y = 390;
		//if(f.y < 10)
		//	f.y = 10;
		float height = TheTerrain->getHeight(f.x, f.z);
		f.y = height + 5.0f;


		TheCamera.setPosition(&f);

		//camera stuff
		D3DXMATRIX V, o;
		TheCamera.getViewMatrix(&V);
		Device->SetTransform(D3DTS_VIEW, &V);

		//UpdateCameraThirdPerson();
		//
		// Draw the scene:
		//
		Device->Clear(0, 0, 
			D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,
			0xff000000, 1.0f, 0L);

		Device->BeginScene();
				
		D3DXMATRIX I;
		D3DXMatrixIdentity(&I);
		if(TheTerrain)
			TheTerrain->draw(&I, false);

		//Device->SetTexture(0, Armor)
D3DXMATRIX i, tripler, grow;

		Collides();

		DisplayTime();
		DisplayRemaining();

		//
		//Barrels1
		//
		if(BoolTrash[0])
		{
		
		D3DXMatrixTranslation(&tripler, TrashPositions[0].x + 0,TrashPositions[0].y, TrashPositions[0].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Barrels.Draw(NULL);
		}

		//
		//Barrels2
		//
		if(BoolTrash[1])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[1].x +0,TrashPositions[1].y,TrashPositions[1].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Barrels.Draw(NULL);
		}
		//
		//Dalek1
		//
		if(BoolTrash[2])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[2].x +0,TrashPositions[2].y+8,TrashPositions[2].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Dalek.Draw(NULL);
		}
		//
		//Dalek2
		//
		if(BoolTrash[3])
		{
		D3DXMatrixTranslation(&tripler,TrashPositions[3].x +0,TrashPositions[3].y+8,TrashPositions[3].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Dalek.Draw(NULL);
		}
		//
		//Tank1
		//		
		if(BoolTrash[4])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[4].x +40,TrashPositions[4].y+14,TrashPositions[4].z+0);
		D3DXMatrixScaling(&grow, .1,.1,.1);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		tank.Draw(NULL);
		}
		//
		//Tank2
		//
		if(BoolTrash[5])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[5].x +40,TrashPositions[5].y+14,TrashPositions[5].z+0);
		D3DXMatrixScaling(&grow, .1,.1,.1);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		tank.Draw(NULL);
		}

		//
		//Table1
		//		
		if(BoolTrash[6])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[6].x +0,TrashPositions[6].y,TrashPositions[6].z-10);
		D3DXMatrixScaling(&grow, 10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Table.Draw(NULL);
		}
		//
		//Table2
		//
		if(BoolTrash[7])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[7].x +0,TrashPositions[7].y,TrashPositions[7].z-10);
		D3DXMatrixScaling(&grow,10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Table.Draw(NULL);
		}
		//
		//Ton1
		//
		if(BoolTrash[8])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[8].x +0,TrashPositions[8].y,TrashPositions[8].z-10);
		D3DXMatrixScaling(&grow,10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Ton.Draw(NULL);
		}
		//
		//Ton2
		//
		if(BoolTrash[9])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[9].x +0,TrashPositions[8].y,TrashPositions[9].z-10);
		D3DXMatrixScaling(&grow,10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Ton.Draw(NULL);
		}

		for(int i = 0; i < numbertrees; i++)
		{
			D3DXMatrixTranslation(&tripler, TreePositions[i].x +0,TreePositions[i].y,TreePositions[i].z-10);
			D3DXMatrixScaling(&grow,5,5,5);
			D3DXMatrixMultiply(&tripler, &grow, &tripler);
			Device->SetTransform(D3DTS_WORLD, &tripler);
			Tree.Draw(NULL);
		}

		if(messageDone)
		{
		if(allfound)
		{
			sprintf(buffers, "Seconds taken to find all objects: %i", seconds);
			::MessageBoxA(0, buffers, "Congratulations", 0);
			//::PostQuitMessage(0);
			messageDone = false;
		}
		}

		renderSkybox(Device, TheCamera);
		DrawMinimap();

		Device->EndScene();
		Device->Present(0, 0, 0, 0);
	}

	if(GetTickCount() - dwFinalTick > 1000)
	{
		seconds = seconds + 1;
		dwInitialTick = dwFinalTick;
		dwFinalTick = GetTickCount();

		countDown = countDown+ 1;
	}
	return true;
}
Exemple #17
0
void Boss::update()
{
	myAnimFrameCounter++;
	myFrameCounter++;

	if (myState == State_Init)
	{
		myOriginalPos = getPosition();
		myState = State_Sleeping;
	}

	if (myState != State_MoveUpwards && myState != State_Sleeping && myState != State_InitialBlow && myState != State_Dead && myState != State_Vulnerable)
	{
		if (Collides(mRoom->getHero()->getCollisionRect(), getCollisionRect()))
		{
			mRoom->getHero()->kill();
		}
	}

	if (myState == State_InitialBlow)
	{
		if (myFrameCounter % 60 == 0)
			Sound::playSample("data/sounds/alarm.wav");

		if (myFrameCounter >= INITIAL_BLOW_TIME)
		{
			Sound::playSample("data/sounds/reactor_explosion.wav");
			Sound::playSample("data/sounds/start.wav");
			ParticleSystem* ps = new ParticleSystem(Resource::getAnimation("data/images/debris.bmp", 4), 20, 200, 20, 1, 50, 50, -float2(0.0f, 150.0f), 5.0f);
			ps->setPosition(getPosition(), 10.0f);
			mRoom->addEntity(ps);
			myFrameCounter = 0;
			myState = State_Awakening;
		}		
	}

	if (myState == State_Awakening)
	{
		if (myFrameCounter > 60 * 3)
		{
			myState = State_MoveUpwards;
			myFrameCounter = 0;
			setTilesCollidable(false);
			Music::pushSong();
			Music::playSong("data/music/olof3.xm");
		}
	}

	if (myState == State_MoveUpwards)
	{
		setPosition(getPosition() + float2(0, -1));
		if (myOriginalPos.y - getPosition().y > 130)
		{
			myState = State_Float;
			mRoom->broadcastBoosWallActivate();
			myFrameCounter = 0;
		}
	}

	if (myState == State_Float)
	{
		float y =  sinf(myFrameCounter / 8) * 2.0f;
		if (myDirection == Direction_Right)
		{
			setPosition(getPosition() + float2(1.5f, y));
			if (getPosition().x  - myOriginalPos.x > 110)
				myDirection = Direction_Left;

		}

		if (myDirection == Direction_Left)
		{
			setPosition(getPosition() + float2(-1.5f, y));
			if (myOriginalPos.x - getPosition().x > 110)
				myDirection = Direction_Right;
		}

		if (myFrameCounter > 60 * 7)
		{
			myState = State_Attack;
			myFrameCounter = 0;
		}
	}

	if (myState == State_Attack)
	{
		if (myFrameCounter < 40)
		{
			if (myFrameCounter % 2 == 0)
				setPosition(getPosition() + float2(-2, 0));
			else 
				setPosition(getPosition() + float2(2, 0));
		}
		else
		{
			setPosition(getPosition() + float2(0, 6.0f));
			if (myOriginalPos.y < getPosition().y)
			{
				mRoom->broadcastBoosWallDectivate();
				setPosition(float2(getPosition().x, myOriginalPos.y));
				myState = State_Vulnerable;
				mRoom->getCamera()->addShake(5.0f, 80);
				int numPs = rand() % 10 + 5;
				ParticleSystem* ps = new ParticleSystem(Resource::getAnimation("data/images/debris.bmp", 4), 10, 40, 10, 1, 50, numPs, -float2(0.0f, 20.0f), 2.0f);
				ps->setPosition(getPosition(), 10.0f);
				mRoom->addEntity(ps);
				mRoom->broadcastBoosFloorActivate();
				Sound::playSample("data/sounds/reactor_explosion.wav");
				Coin::SpawnDeathCoins(rand() % 5 + 3, getPosition(), 60 * 6, mRoom);
			}
		}
	
	}

	if (myState == State_Vulnerable)
	{
		if (myFrameCounter > 60 * 5)
		{
			myState = State_MoveUpwards;
			myFrameCounter = 0;
		}
	}

	if (myState == State_Dead)
	{
		if (myFrameCounter % 60 == 0)
			Sound::playSample("data/sounds/alarm.wav");

		if (myFrameCounter >= BLOW_TIME)
		{
			Sound::playSample("data/sounds/reactor_explosion.wav");
			Sound::playSample("data/sounds/start.wav");
			ParticleSystem* ps = new ParticleSystem(Resource::getAnimation("data/images/debris.bmp", 4), 20, 200, 20, 1, 50, 50, -float2(0.0f, 150.0f), 5.0f);
			ps->setPosition(getPosition(), 10.0f);
			mRoom->addEntity(ps);
			ReactorCore* core = new ReactorCore;
			core->setPosition(getPosition());
			core->setVelocity(float2(0, -50));
			mRoom->addEntity(core);
			remove();
		}
	}
}
Exemple #18
0
void cShoot::MoveUp(vector<cBicho> *caixes, vector< vector<int> > &map, cBicho &terra, cSound &Sound,int &rebots)
{
                double xaux, zaux, yaux;
                float x,y,z;
                //float rot;
                //rot = GetRot();
                GetPosition(&x,&y,&z);
                xaux=x;
                zaux=z;
                yaux=y;
                int tx,ty;
                GetTile(&tx,&ty);
                //x-=iner*sin(rot*PI/180);
                //z-=iner*cos(rot*PI/180);
                x+=-cos(PI/180*rotV)*sin(PI/180*rot)*iner;
                z+=-cos(PI/180*rotV)*cos(PI/180*rot)*iner;
                if(y<0)y=0;
                int suelo;
                
                //y+=sin(PI/180*rotV)*iner;
                suelo = ((int)floor(y))/4;
				//y-=0.01;
                SetPosition(x,y,z);
                cRect rect;
                bool b=false;
                bool desliza_z=true;
                bool desliza_x=true;
                bool desliza_y=true;
                //if(suelo>1)suelo=1;
                //caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                terra.GetArea(&rect);
                /*if(Collides(&rect)) {
                        y=0;
                        rotV -= 2*rotV;
                }*/
                /*int i=0;
                int j=0;
                                if(map[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)]!=0 || map[suelo+1][(ty+i)*SCENE_DEPTH+ (tx+j)]!=0) {
                                        caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                                        if(!Collides(&rect)) {
                                                //y+=sin(PI/180*rotV)*iner;
                                                
                                                suelo = ((int)floor(y))/4;
                                                caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                                                if(Collides(&rect)) {
                                                        if(rotV >=0 && rotV <= 90) {
                                                                //double rotaux = 90.0 - (rot);
                                                                rotV -= 2*rotV;
                                                                //rot = 360-(rot);
                                                                //rot = fmod(rot,360);

                                                        }
                                                        else if(rotV >=-90 && rotV < 0) {
                                                                //double rotaux = (rot-90);
                                                                //double rotaux2 = 90-rotaux;
                                                                rotV -= 2*rotV;
                                                        }
                                                        b = true;
                                                        y=yaux;
                                                        SetPosition(x,y,z);
                                                }
                                        }
                                }*/
                
                b=false;
                suelo = ((int)floor(y))/4;
                for(int i=-1;i<=1 && !b;++i) {
                    for(int j=-1;j<=1 && !b;++j) {
                            //if(!(i==0 && j==0)) {
                        if(map[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)]!=0) {
                            caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                            if(Collides(&rect)) {
                                z = zaux;
                                //y = yaux;
                                SetPosition(x,y,z);
                                b = true;
                                for(int i=-1;i<=1;++i) {
                                    for(int j=-1;j<=1;++j) {
                                        caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                                        if(Collides(&rect)) {
                                            x = xaux;
                                            //y = yaux;
                                            desliza_x = false;
                                            //z-=0.1*cos(rot*PI/180);
                                            z+=-sin(PI/180*rotV)*cos(PI/180*rot)*iner;
                                            SetPosition(x,y,z);
                                            for(int i=-1;i<=1;++i) {
                                                for(int j=-1;j<=1;++j) {
                                                    caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                                                    if(Collides(&rect)) {
                                                        z = zaux;
                                                        //y = yaux;
                                                        desliza_z = false;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if(b) {
                        if(desliza_x) {
                                if(rot >=0 && rot < 90) {
                                        double rotaux = 90.0 - (rot);
                                        rot += 2*rotaux;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                        //rot = 360-(rot);
                                        //rot = fmod(rot,360);

                                }
                                else if(rot >=90 && rot < 180) {
                                        double rotaux = (rot-90);
                                        //double rotaux2 = 90-rotaux;
                                        rot -= 2*rotaux;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                }
                                else if(rot >=180 && rot < 270) {
                                        double rotaux =  90 - (rot - 180);
                                        //double rotaux2 = 90-rotaux;
                                        rot += 2*rotaux;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                }
                                else if(rot >=270 && rot < 360) {
                                        double rotaux = (rot-270);
                                        //double rotaux2 = 90-rotaux;
                                        rot -= 2*rotaux;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                }
                        }
                        else if(desliza_z) {
                                if(rot >=0 && rot < 90) {
                                        double rotaux = 90.0 - (rot);
                                        rot += 180 + 2*rotaux;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
                                        //rot = 360-(rot);
                                        //rot = fmod(rot,360);
										rebots++;

                                }
                                else if(rot >=90 && rot < 180) {
                                        double rotaux = 90.0 - (rot-90);
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                        //double rotaux2 = 90-rotaux;
                                        rot += 2*rotaux;
                                }
                                else if(rot >=180 && rot < 270) {
                                        double rotaux =  (rot - 180);
                                        //double rotaux2 = 90-rotaux;
                                        rot -= 2*rotaux;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                }
                                else if(rot >=270 && rot < 360) {
                                        double rotaux = 90.0 - (rot-90);
                                        //double rotaux2 = 90-rotaux;
                                        rot += 2*rotaux;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                }
                        }
                }
                SetPosition(x,y,z);
                rot = fmod(rot,360);
                //SetRot(rot);
                /*for(unsigned int i=1;i<=4;++i) {
                        caixes[tx*SCENE_WIDTH+ty+i].GetArea(&rect);
                        if(Collides(&rect)) {
                                x = xaux;
                                z = zaux;
                        }
                }*/
                y+=sin(PI/180*rotV)*iner;
                SetPosition(x,y,z);
            if(map[suelo][(ty)*SCENE_DEPTH+ (tx)] == 0) {
                    //y+=sin(PI/180*rotV)*iner;
                for(int i=-1;i<=1 && !b;++i) {
					for(int j=-1;j<=1 && !b;++j) {
						caixes[suelo+1][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
						if(Collides(&rect)) {
							b = true;
							if(rotV >=0 && rotV <= 90) {
									//double rotaux = 90.0 - (rot);
									rotV -= 2*rotV;
									Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
									rebots++;
									//rot = 360-(rot);
									//rot = fmod(rot,360);

							}
							else if(rotV >=-90 && rotV < 0) {
									//double rotaux = (rot-90);
									//double rotaux2 = 90-rotaux;
									rotV -= 2*rotV;
									Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
									rebots++;
							}
							y = yaux;
							SetPosition(x,y,z);
						}
					}
				}
            }
                        //if(!b) {
                                //if(map[suelo][(ty)*SCENE_DEPTH+ (tx)] == 0) {
				//y = yaux;
				//y+=sin(PI/180*rotV)*iner;
                //SetPosition(x,y,z);
                b=false;
                suelo--;
                if(suelo<0)suelo=0;
                for(int i=-1;i<=1 && !b;++i) {
                    for(int j=-1;j<=1 && !b;++j) {
                        if(map[suelo][(ty)*SCENE_DEPTH+ (tx)] != 0) {
                            caixes[suelo][(ty+i)*SCENE_DEPTH+ (tx+j)].GetArea(&rect);
                            if(Collides(&rect)) {
                                b = true;
                                if(rotV >=0 && rotV <= 90) {
                                        //double rotaux = 90.0 - (rot);
                                        rotV -= 2*rotV;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                        //rot = 360-(rot);
                                        //rot = fmod(rot,360);

                                }
                                else if(rotV >=-90 && rotV < 0) {
                                        //double rotaux = (rot-90);
                                        //double rotaux2 = 90-rotaux;
										
                                        rotV -= 2*rotV;
										Sound.PlaySoundW("resources/music/ricochet.ogg",false,0.2);
										rebots++;
                                }
								//if(yaux<rect.ymax)
									y=rect.ymax;
								//else
									//y = yaux;
                                SetPosition(x,y,z);
                            }
                        }
                    }
                //}
        //}
                }


}
void Shot::update(){
	if (++mLife > 180){
		setCollided(true);
	}
	if (touchesDangerousTile()){
		setCollided(true);
	}
	if(hasCollided()){
		if (--mCollidedTimer < 0){
			remove();
			//remove
		}
		return;
	}
	// move
	int cur_x = getPosition().x;
	int cur_y = getPosition().y;
	int floor_y, edge_x;
	int bumps;
	/*
	floor_y= cur_y+getHalfSize().y+5;
	if (mFacingDirection == Direction_Left){
		edge_x=cur_x-getHalfSize().x;
	} else {
		edge_x=cur_x+getHalfSize().x;
	}
	*/
	if(mGravity[mShotType] == ShotType_Bullet){
		setVelocity(float2(mInitialVelocity[mShotType].x*getDirection(),mInitialVelocity[mShotType].y));
	} else {
		setVelocity(float2(mInitialVelocity[mShotType].x*getDirection(),mInitialVelocity[mShotType].y+GRAVITY*mLife));
	}
	//setVelocity(float2(12.0f,.0f));
	bumps=moveWithCollision();

	if((bumps & Direction_Left) != 0 || (bumps & Direction_Right) != 0 || (bumps & Direction_Up) != 0|| (bumps & Direction_Down) != 0 ){
		setCollided(true);
		if (mShotType == ShotType_GravityGrenade || mShotType == ShotType_Fireball) { Sound::playSample("data/sounds/grenadeexplode.wav"); }
	}

	if(!mHurtPlayer){
		std::vector<Entity*> collidedEntity = mRoom->checkEntitiesForCollision(this);
		if(collidedEntity.size() > 0){
			setCollided(true);
			if (mShotType == ShotType_GravityGrenade || mShotType == ShotType_Fireball) { Sound::playSample("data/sounds/grenadeexplode.wav"); }
			for(int i=0;i<collidedEntity.size();i++){
				attack(collidedEntity[i]);
			}
		}
	} else {
		Hero* h = mRoom->getHero();
		Entity::CollisionRect cr= h->getCollisionRect();
		if(Collides(getCollisionRect(),cr)){
			setCollided(true);
			if (mShotType == ShotType_GravityGrenade || mShotType == ShotType_Fireball) { Sound::playSample("data/sounds/grenadeexplode.wav"); }
			if(mShotType == ShotType_Fireball || mShotType == ShotType_Bullet){
				h->die();
				return;
			}
			if(mShotType == ShotType_GravityGrenade){
				attack(h);
				return;
			}
		}
	}

	mFrame++;
	

}