Ejemplo n.º 1
0
void Tutorial::update(float dt)
{
	if (move == true)//moves everything up the screen at the same speed
	{
		player->setPositionY(player->getPosition().y + 7.5);
		pauseItem->setPositionY(pauseItem->getPosition().y + 7.5);
	}
	if (speed == true && move == true)
	{
		player->setPositionY(player->getPosition().y + 3.0);
		pauseItem->setPositionY(pauseItem->getPosition().y + 3.0);
	}
	if (player->getPosition().y > 1500 && player->getPosition().y < 1525)
	{
		player->setPositionY(1526);
		activateTutorialInfo1(this);
	}

	if (player->getPosition().y > 3300 && player->getPosition().y < 3325)
	{
		player->setPositionY(3326);
		activateTutorialInfo2(this);
	}

	if (player->getPosition().y > 5150 && player->getPosition().y < 5160)
	{
		player->setPositionY(5161);
		activateTutorialInfo3(this);
	}

	if (player->getPosition().y > 7150 && player->getPosition().y < 7175)
	{
		player->setPositionY(7176);
		activateTutorialInfo4(this);
	}

	if (player->getPosition().y > 8350)//checks to see if the player has finished the level
	{
		activateGameOverScene(1);
	}

	//checks to make sure the player stays withen the bounds of the screen
	if (player->getPosition().x < 25)
	{
		player->setPositionX(26);
	}
	if (player->getPosition().x > 372)
	{
		player->setPositionX(371);
	}

	//gets the camera to follow the players y postion  
	cameraTarget->setPositionY(player->getPosition().y + 115);
}
bool Level1::onContactBegin(cocos2d::PhysicsContact &contact)
{
	auto nodeA = contact.getShapeA()->getBody()->getNode();
	auto nodeB = contact.getShapeB()->getBody()->getNode();

	if (nodeA && nodeB)
	{
		//bullet and boss collision
		//if bullet
		if (nodeA->getTag() == 10)
		{
			//if boss
			if (nodeB->getTag() == 30)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("bossHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				boss->loseLives();
				if (boss->getLives() <= 0){
					boss->removehealthBar();
					//start level 2 switch statement
					level = 'B';
					//removes boss1
					nodeB->removeFromParentAndCleanup(true);
					//re-initilize level
					init();
					player->setLives();
				}
			}
			//if boss1bullet
			else if (nodeB->getTag() == 40)
			{
				nodeA->removeFromParentAndCleanup(true);
				nodeB->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
			//if boss2
			else if (nodeB->getTag() == 50)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("bossHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				boss2->loseLives();
				if (boss2->getLives() <= 0){
					activateGameCompleteScene(this);
				}
			}
			//if boss1bullet2
			else if (nodeB->getTag() == 60)
			{
				nodeA->removeFromParentAndCleanup(true);
				nodeB->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
			//if boss1bullet3
			else if (nodeB->getTag() == 70)
			{
				nodeA->removeFromParentAndCleanup(true);
				nodeB->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
			//if boss2bullet2
			else if (nodeB->getTag() == 80)
			{
				nodeA->removeFromParentAndCleanup(true);
				nodeB->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
			//if boss2bullet3
			else if (nodeB->getTag() == 90)
			{
				nodeA->removeFromParentAndCleanup(true);
				nodeB->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
			//if boss2bullet3
			else if (nodeB->getTag() == 100)
			{
				nodeA->removeFromParentAndCleanup(true);
				nodeB->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
		}
		//bullet and boss collision
		//if boss
		else if (nodeA->getTag() == 30)
		{
			// if bullet
			if (nodeB->getTag() == 10)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("bossHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				boss->loseLives();
				if (boss->getLives() <= 0){
					boss->removehealthBar();
					level = 'B';
					nodeA->removeFromParentAndCleanup(true);
					init();
					player->setLives();
				}
			}
		}
		//bullet and boss collision
		//if boss2
		else if (nodeA->getTag() == 50)
		{
			//if player bullet
			if (nodeB->getTag() == 10)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("bossHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				boss2->loseLives();
				if (boss2->getLives() <= 0){
					activateGameCompleteScene(this);
					player->setLives();
				}
			}
		}
		//player and bossbullet collision
		//if boss1bullet1
		else if (nodeA->getTag() == 40)
		{
			//if player
			if (nodeB->getTag() == 20)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if bullet
			else if (nodeB->getTag() == 10)
			{
				nodeB->removeFromParentAndCleanup(true);
				nodeA->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
		}
		//player and bossbullet2 collision
		//if boss1bullet2
		else if (nodeA->getTag() == 60)
		{
			//if player
			if (nodeB->getTag() == 20)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if bullet
			else if (nodeB->getTag() == 10)
			{
				nodeB->removeFromParentAndCleanup(true);
				nodeA->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
		}
		//player and boss1bullet collision
		//if boss1bullet3
		else if (nodeA->getTag() == 70)
		{
			//if player
			if (nodeB->getTag() == 20)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if bullet
			else if (nodeB->getTag() == 10)
			{
				nodeB->removeFromParentAndCleanup(true);
				nodeA->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
		}
		//player and bossbullet collision
		//if boss2bullet1
		else if (nodeA->getTag() == 80)
		{
			//if player
			if (nodeB->getTag() == 20)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}

			}
			//if bullet
			else if (nodeB->getTag() == 10)
			{
				nodeB->removeFromParentAndCleanup(true);
				nodeA->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
		}
		//player and bossbullet collision
		//if boss2bullet2
		else if (nodeA->getTag() == 90)
		{
			//if player
			if (nodeB->getTag() == 20)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if bullet
			else if (nodeB->getTag() == 10)
			{
				nodeB->removeFromParentAndCleanup(true);
				nodeA->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
		}
		//player and bossbullet collision
		//if boss2bullet3
		else if (nodeA->getTag() == 100)
		{
			//if player
			if (nodeB->getTag() == 20)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeA->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if bullet
			else if (nodeB->getTag() == 10)
			{
				nodeB->removeFromParentAndCleanup(true);
				nodeA->removeFromParentAndCleanup(true);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("metalBang.wav");
			}
		}
		//player and bossbullet collision
		//if player
		else if (nodeA->getTag() == 20)
		{
			//if bossbullet
			if (nodeB->getTag() == 40)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					//removes bossbullet
					activateGameOverScene(this);
				}
			}
			//if bossbullet2
			else if (nodeB->getTag() == 60)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if bossbullet3
			else if (nodeB->getTag() == 70)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if boss2bullet1
			else if (nodeB->getTag() == 80)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if boss2bullet2
			else if (nodeB->getTag() == 90)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
			//if boss2bullet3
			else if (nodeB->getTag() == 100)
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("playerHit.wav");
				nodeB->removeFromParentAndCleanup(true);
				player->loseLives();
				if (player->getLives() <= 0){
					activateGameOverScene(this);
				}
			}
		}
	}
	return true;
}