Exemplo n.º 1
0
void HeliBrain::RunDecisionRoutines(void)
{
   /*-----------------------*/
   /* collision avoid check */
   /*-----------------------*/
   CollisionCheck();

   /*-----------*/
   /* Guns Jink */
   /*-----------*/
   GunsJinkCheck();
	// checks for missiles too
   GunsEngageCheck();

   /* Special cases for close in combat logic.                 */
   /* These maneuvers are started from within other maneuvers, */
   /* eg. "rollAndPull" and are self-terminating.            */

   /*------------------*/
   /* default behavior */
   /*------------------*/
   // if (isWing)
   //    AddMode (WingyMode);
   AddMode(WaypointMode);
}
Exemplo n.º 2
0
int MainRun()
{
    CollisionCheck();
    ScreenDrawer();

    return 0;
}
Exemplo n.º 3
0
void GameMaster::PlayerMove(int player, int up_down)
{
	switch (player)
	{
	case 1:
		switch (up_down)
		{
		case 1:
			m_player1.PaddleUp();
			break;
		case 2:
			m_player1.PaddleDown();
			break;
		}
		break;
	case 2:			
		switch (up_down)
		{
		case 1:
			m_player2.PaddleUp();
			break;
		case 2:
			m_player2.PaddleDown();
			break;
		}
		break;
	}
	CollisionCheck();
}
Exemplo n.º 4
0
void CButton::ClickState(int x, int y, bool bClick, bool bPress)
{
	m_bClick = false ;
	if(!m_bActivate || !m_bVisible)
		return ;

	if(bPress && CollisionCheck(x, y))
	{
		m_bClick = true ;
	}
	else if(bClick && CollisionCheck(x, y))
	{
		m_nState = m_nIndex[1] ;
	}
	else
	{
		m_nState = m_nIndex[0] ;
	}
}
Exemplo n.º 5
0
void Player::CollideWBaklava( Baklava * bakl, int * upgradeCountPtr, bool * upgrSeenPtr, bool * doneGameplay, SAMPLE * hurt, SAMPLE * pickUp )
{

	if( CollisionCheck( bakl->GetColRect() ) )
		{
			bakl->Respawn();
			EatBaklava( bakl->GetId(), upgradeCountPtr, upgrSeenPtr, doneGameplay, hurt, pickUp );
		}

}
Exemplo n.º 6
0
void ObjectManager::Update( float dt, ofPoint LHandPos, ofPoint RHandPos )
{
	for(auto &elem : m_GameBlockList)
	{
		elem->Update(dt);
	}

	m_Ball->Update(dt);
	m_Bar->Update(dt, LHandPos, RHandPos);
	CollisionCheck();
}
void BoundingObjectManager::Update(void)
{
	m_vCollidingNames.clear();
	for(int nObject = 0; nObject < m_nObjects; nObject++)
	{
		m_vBoundingObject[nObject]->SetColorOBB(MEWHITE);
		m_vBoundingObject[nObject]->SetVisible(false);
	}
	CollisionCheck();
	CollisionResponse();
}
/// <summary>
/// Detects the collisions.
/// </summary>
void PhysicsSystem::DetectCollisions()
{
    ComponentFactory& CF = ComponentFactory::Instance();
    if(!CF.hasComponentCache<PhysicsComponent>() || !CF.hasComponentCache<PositionalComponent>() ) //check for any graphicsComponents
        return;

    //grab the caches
    std::vector<PhysicsComponent>& phys         = CF.getCache<PhysicsComponent>()->storage;      //Physics components
    std::vector<PositionalComponent>& positions = CF.getCache<PositionalComponent>()->storage;   //Position Components
    GameObjectCache& GOC                        = GameObjectCache::Instance();

    std::vector<PhysicsComponent>::iterator A_iter;
    std::vector<PhysicsComponent>::iterator B_iter;

    

    for(A_iter = phys.begin(); A_iter != phys.end(); ++A_iter)
    {
        PhysicsComponent& A = *A_iter;
        if(!A.active)
            continue;
        PositionalComponent& posA = *A_iter->parent()->getComponent<PositionalComponent>();

        if(!A.active)
            continue;

        B_iter = A_iter;
        ++B_iter;
        for( ; B_iter != phys.end(); ++B_iter)
        {
            PhysicsComponent& B = *B_iter;
            if(!B.active)
                continue;
            PositionalComponent& posB = *B_iter->parent()->getComponent<PositionalComponent>();

            if(!B.active)
            continue;

            if( !A.IsStatic || !B.IsStatic )
            {
                Contact c;
                if(CollisionCheck(A_iter->body, posA.position + A_iter->offset, B_iter->body, posB.position + B_iter->offset, c))
                {
                    c.ObjIDs[0]     = A.parentID;
                    c.ObjIDs[1]     = B.parentID;
                    c.Velocities[0] = A.velocity;
                    c.Velocities[1] = B.velocity;
                    c.Restitution = min(A.Restitution,B.Restitution);
                    contacts.push_back(c);
                }
            }
        }// End B loop
    }//End A loop
}// End Function
Exemplo n.º 9
0
void World::Update(sf::Int32 dt)
{
	runTime += dt;

	auto ballPos = BallPos(runTime);
	for (size_t i = 0; i < balls.size(); i++)
	{
		balls[i].pos[0] = ballPos[i];
		balls[i].time = runTime;
	}

	CollisionCheck();
}
Exemplo n.º 10
0
/*
 * DrawScreen
 *
 * This does a lot of work.  It draws the background and 
 * all the units, as well as the radar.  This routine is 
 * essentially the main loop that gets called by the 
 * timer every update frequency.
 */
void DrawScreen (GdkPixmap *pixmap, GtkWidget *drawing_area)
{
    /* --- Move player based on keys pressed --- */
    HandleKeysPressed ();

    /* --- Get the screen width --- */
    nScreenWidth = drawing_area->allocation.width;

    /* --- Figure out the offset of the player --- */
    CalculateAdjustments (drawing_area);

    /* --- clear pixmap (background image) --- */
    gdk_draw_rectangle (pixmap,
              drawing_area->style->black_gc,
              TRUE,
              0, 0,
              drawing_area->allocation.width,
              drawing_area->allocation.height);

    /* --- Draw top border and radar screen --- */
    gdk_draw_line (pixmap, drawing_area->style->white_gc, 
                   0, RADAR_HEIGHT, 
                   drawing_area->allocation.width, 
                   RADAR_HEIGHT);

    /* --- Oh those high peaks --- */
    DrawMountains (pixmap, drawing_area, 
                   drawing_area->allocation.height - 65,
                   drawing_area->allocation.height - BOTTOM_HEIGHT);
 
    /* --- Draw the characters --- */
    DrawAllUnits (pixmap, drawing_area); 

    /* --- Draw the units on the radar --- */
    DrawRadar (pixmap, drawing_area);

    /* --- Look for collisions --- */
    CollisionCheck ();

    /* --- Clean up those that got destroyed --- */
    FreeDestroyedUnits ();
}
Exemplo n.º 11
0
bool CScene::CollisionCheck( )
{
	// 플레이어와 각각의 오브젝트들의 충돌체크를 검사
	// 각 셰이더에 있는 오브젝트들과 검사하여 충돌되면 위치 이동 불가
	// 플레이어가 이동할 때 검사해야함

	// 세이더 전체 검색
	// 셰이더의 0번째는 항상 스카이박스, 스카이박스와는 충돌체크할 필요가 없음
	for (int i = 1; i <m_nShaders; i++)
	{
		// 각 세이더가 가지는 오브젝트 검색
		int objCount = m_ppShaders[i]->getObjectCount( );
		for (int j = 0; j <objCount; j++)
		{
			// 오브젝트와 일일히 검사, 하나라도 충돌하면 true를 리턴함
			if (CollisionCheck( m_pPlayer, m_ppShaders[i]->getObjects( )[j] ) )
				return true;
		}
	}
	// 하나도 충돌하지 않은 경우 false 리턴
	return false;
}
Exemplo n.º 12
0
//------------------------------------------------------------------------------
//! \brief Do the object
//------------------------------------------------------------------------------
void CClockBoss::Do( void )
{
	switch (m_Command)
	{
		case CLOCKBOSS_NORMAL:

			ControlHands();
			CollisionCheck();
			BallCollision();
			InitSize(clockboss_size);
			DirFly();
			break;
		case CLOCKBOSS_OUCH:
			m_WhiteFlag = 1;
			m_OuchCount--;
			if (m_OuchCount<0)
			{
				m_Command = CLOCKBOSS_NORMAL;
				m_WhiteFlag = 0;
			}
			break;
	}
}
Exemplo n.º 13
0
//------------------------------------------------------------------------------
//! \brief Do the object
//------------------------------------------------------------------------------
void CCrabBoss::Do( void )
{
	switch (m_Command)
	{
		case CRABBOSS_NORMAL:
			m_ClawCounter++;

			CollisionCheck();
			BossCollision();

			DoPattern();
			break;
		case CRABBOSS_OUCH:
			m_WhiteFlag = 1;
			m_OuchCount--;
			if (m_OuchCount<0)
			{
				m_Command = CRABBOSS_NORMAL;
				m_WhiteFlag = 0;
			}
			break;
	}
}
Exemplo n.º 14
0
//------------------------------------------------------------------------------
//! \brief Do the object
//------------------------------------------------------------------------------
void CClownBoss::Do( void )
{
	switch (m_Command)
	{
		case CLOWNBOSS_NORMAL:
			m_MouthCounter++;

			CollisionCheck();
			TomatoCollision();

			InitSize(clownboss_size);
			DirFly();
			break;
		case CLOWNBOSS_OUCH:
			m_WhiteFlag = 1;
			m_OuchCount--;
			if (m_OuchCount<0)
			{
				m_Command = CLOWNBOSS_NORMAL;
				m_WhiteFlag = 0;
			}
			break;
	}
}
Exemplo n.º 15
0
bool GameMaster::BallMove()
{
	m_ball.BallMove();
	return CollisionCheck();
}
Exemplo n.º 16
0
	bool MainScene::Update()
	{
		switch (updateState)
		{
		case isGameOver:
			Input::KeyInput();
			if (Y == Input::GetLastKey())
			{
				StageManager::GetInstance()->ReSetStage();
				Sleep(2000);
				renderState = isLevelUpdate;
				updateState = isLevelUpdate;
			}
			if (N == Input::GetLastKey())
				BreakBlockGame::setScene(new EndScene());

			break;
		case isLevelUpdate:
			Sleep(2000);
			renderState = isPrimeDraw;
			updateState = isGameing;
			break;
		case isMissionClear:
			StageManager::GetInstance()->SetNextStage();
			Sleep(2000);
			renderState = isLevelUpdate;
			updateState = isLevelUpdate;
			break;
		case isGameing:
			CollisionCheck();
			UpdateObjects();
			renderState = isGameing;
			if (StageManager::GetInstance()->CheckLifeZero() ||
				StageManager::GetInstance()->CheckTimeEnd())
			{
				renderState = isGameOver;
				updateState = isGameOver;
			}
			if (StageManager::GetInstance()->CheckMissionClear())
			{
				renderState = isMissionClear;
				updateState = isMissionClear;
			}
		case isUiDraw:
			if (GetTickCount() >= UiDrawTime)
			{
				StageManager::GetInstance()->AddPlayTime();
				UiDrawTime = GetTickCount() + 1000;
				renderState = isUiDraw;
			}
		case isPrimeDraw:
			if (GetTickCount() >= primeDrawTime)
			{
				primeDrawTime = GetTickCount() + 1000;
				renderState = isPrimeDraw;
			}
			break;
		default:
			break;
		}
		return true;
	}
Exemplo n.º 17
0
int Player::PowerThree(unsigned int updatevalue,float dt)
{
	float Xmove = 0.0f;
	float Ymove = 0.0f;
	float oldX = position.x;
	float oldY = position.y;
	float PX1 = position.x;
	float PY1 = position.y;
	float PX2 =(PX1 + rect.right);
	float PY2 = (PY1 + rect.bottom);
	bool yellowPower;
	yellowPower	= false;
	int theNumber= 0;
	if((updatevalue & M_LEFT)!=false)
	{
		Xmove = dt* MovementSpeedX;
		oldX = position.x;
		position.x -= Xmove;
		if(CollisionCheck(PX1-=Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 1)
		{
			position.x = oldX;
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
						for (int i = 0; i<32; i++)
			{
				PX1 = position.x;
				PY1 = position.y;
				PX2 =(PX1 + rect.right);
				PY2 = (PY1 + rect.bottom);
				Xmove = 1;
				oldX = position.x;
				position.x -= Xmove;
				if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 1)
				{
					position.x = oldX;
				}
			}
		}
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
		}
	}
	if((updatevalue & M_RIGHT)!=false)
	{
		Xmove = dt* MovementSpeedX;
		oldX = position.x;
		position.x += Xmove;
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 1)
		{
			position.x = oldX;
			//position.y = oldY;
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
			for (int i = 0; i<32; i++)
			{
				PX1 = position.x;
				PY1 = position.y;
				PX2 =(PX1 + rect.right);
				PY2 = (PY1 + rect.bottom);
				Xmove = 1;
				oldX = position.x;
				position.x += Xmove;
				if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 1)
				{
					position.x = oldX;
				}

			}
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
		}
	}
	if((updatevalue & M_JUMP)!= false)
	{
		Ymove = dt* JumpingConstant;
		if(CollisionCheck(PX1+Ymove,PY1,PX2+Ymove,PY2,ObjectList) == 1 || CollisionCheck(PX1-Ymove,PY1,PX2-Ymove,PY2,ObjectList) == 1)
		{
			//Ymove = dt* JumpingConstant;
			oldY = position.y;
			position.y -= Ymove;
			if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 1)
			{
				theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
				position.y = oldY;
			for (int i = 0; i<32; i++)
			{
				PX1 = position.x;
				PY1 = position.y;
				PX2 =(PX1 + rect.right);
				PY2 = (PY1 + rect.bottom);
				Ymove = 1;
				oldY = position.y;
				position.y -= Ymove;
				if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 1)
				{
					position.y = oldY;
				}

			}
				//return
			}
			if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 2)
			{
				theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
				//return
			}
			if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 3)
			{
				theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
				//return
			}

		}
	}
	if((updatevalue & M_JUMP)==false)
	{
		Ymove = dt* Gravity;
		oldY = position.y;
		position.y += Ymove;
		if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 1)
		{
			position.y = oldY;
			theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
			for (int i = 0; i<32; i++)
			{
				PX1 = position.x;
				PY1 = position.y;
				PX2 =(PX1 + rect.right);
				PY2 = (PY1 + rect.bottom);
				Ymove = 1;
				oldY = position.y;
				position.y += Ymove;
				if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 1)
				{
					position.y = oldY;
				}

			}
		}
		if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
		}
		if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
		}
	}
	//powers
	if((updatevalue & P1)!=false)
	{
		SelectedPower = 2;
	}
	if((updatevalue & P2)!=false)
	{
		SelectedPower = 3;
	}
	if((updatevalue & P3)!=false)
	{
		SelectedPower = 4;
	}
	if((updatevalue & P4)!=false)
	{
		SelectedPower = 1;
	}
	xvelocity = position.x - oldX;
	yvelocity = position.y - oldY;
	return theNumber;
}
Exemplo n.º 18
0
int Player::PowerTwo(unsigned int updatevalue,float dt)
{
	float Xmove = 0.0f;
	float Ymove = 0.0f;
	float oldX = position.x;
	float oldY = position.y;
	float PX1 = position.x;
	float PY1 = position.y;
	float PX2 =(PX1 + rect.right);
	float PY2 = (PY1 + rect.bottom);
	int theNumber = 0;
	Xmove = xvelocity; 

	if(Xmove > 0)
	{
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) != 1)
		{
			position.x -= Xmove;
		}
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 1)
		{
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
		}
		//			else if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 1)
		//			{
		////				position.x += Xmove;
		//			}
	}
	if(Xmove < 0)
	{
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) != 1)
		{
			position.x += Xmove;
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 1)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+=Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
		}
	}
	if(Ymove < 0)
	{
		Ymove = yvelocity;
		if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) != 1)
		{
			position.y -= Ymove;
			//IsJumping = true;
		}
		if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 1)
		{
			theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
			//return
		}
		if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
			//return
		}
		if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
			//return
		}
	}
	if(Ymove > 0)
	{
		Ymove = yvelocity;
		if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) != 1)
		{
			position.y += Ymove;
			//IsJumping = true;
		}
		if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 1)
		{
			theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
			//return
		}
		if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
			//return
		}
		if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
			//return
		}
	}
	Ymove = dt* Gravity;
	if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) != 1)
	{
		position.y += Ymove;
	}
	if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 1)
	{
		theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
	}
	if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 2)
	{
		theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
	}
	if(CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList) == 3)
	{
		theNumber = CollisionCheck(PX1,PY1+Ymove,PX2,PY2+Ymove,ObjectList);
	}
	//}
	//powers
	if((updatevalue & P1)!=false)
	{
		SelectedPower = 2;
	}
	if((updatevalue & P2)!=false)
	{
		SelectedPower = 3;
	}
	if((updatevalue & P3)!=false)
	{
		SelectedPower = 4;
	}
	if((updatevalue & P4)!=false)
	{
		SelectedPower = 1;
	}
	xvelocity = position.x - oldX;
	yvelocity = position.y - oldY;
	return theNumber;
}
Exemplo n.º 19
0
int Player::PowerOne(unsigned int updatevalue,float dt)
{
	float Xmove = 0.0f;
	float Ymove = 0.0f;
	float oldX = position.x;
	float oldY = position.y;
	float PX1 = position.x;
	float PY1 = position.y;
	float PX2 =(PX1 + rect.right);
	float PY2 = (PY1 + rect.bottom);
	int theNumber= 0;
	if((updatevalue & M_LEFT)!=false)
	{
		Xmove = dt* MovementSpeedX;
		oldX = position.x;
		position.x -= Xmove;
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 1)
		{
			position.x = oldX;
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
			for (int i = 0; i<32; i++)
			{
				PX1 = position.x;
				PY1 = position.y;
				PX2 =(PX1 + rect.right);
				PY2 = (PY1 + rect.bottom);
				Xmove = 1;
				oldX = position.x;
				position.x -= Xmove;
				if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 1)
				{
					position.x = oldX;
				}
			}
		}
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1-Xmove,PY1,PX2-Xmove,PY2,ObjectList);
		}
	}
	if((updatevalue & M_RIGHT)!=false)
	{
		//process right movement
		Xmove = dt* MovementSpeedX;
		Xmove = dt* MovementSpeedX;
		oldX = position.x;
		position.x -= Xmove;

		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) != 1)
		{
			position.x += Xmove;
			for (int i = 0; i<32; i++)
			{
				PX1 = position.x;
				PY1 = position.y;
				PX2 =(PX1 + rect.right);
				PY2 = (PY1 + rect.bottom);
				Xmove = 1;
				oldX = position.x;
				position.x += Xmove;
				if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 1)
				{
					position.x = oldX;
				}

			}
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 1)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 2)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
		}
		if(CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList) == 3)
		{
			theNumber = CollisionCheck(PX1+Xmove,PY1,PX2+Xmove,PY2,ObjectList);
		}
	}
	if((updatevalue & M_JUMP)!= false)
	{
	}
	Ymove = dt* Gravity;
	if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) != 1)
	{
		position.y -= Ymove;
	}
	if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 1)
	{
		theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
	}
	if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 2)
	{
		theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
	}
	if(CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList) == 3)
	{
		theNumber = CollisionCheck(PX1,PY1-Ymove,PX2,PY2-Ymove,ObjectList);
	}
	//}
	//powers
	if((updatevalue & P1)!=false)
	{
		SelectedPower = 2;
	}
	if((updatevalue & P2)!=false)
	{
		SelectedPower = 3;
	}
	if((updatevalue & P3)!=false)
	{
		SelectedPower = 4;
	}
	if((updatevalue & P4)!=false)
	{
		SelectedPower = 1;
	}
	xvelocity = position.x - oldX;
	yvelocity = position.y - oldY;

	return theNumber;
}
Exemplo n.º 20
0
bool CircleCollider::CollisionCheck(Line2& a_lLine)
{

	return CollisionCheck(a_lLine.PointOne,a_lLine.PointTwo);
}
Exemplo n.º 21
0
bool CollisionProceed(MyRect& rv, MyRect& lv) 
{

	if (CollisionCheck(rv, lv))
	{
		//물리법칙 흉내 버전
		float rvCenterX = rv.x1 + rv.size / 2.0f;
		float lvCenterX = lv.x1 + lv.size / 2.0f;
		float rvCenterY = rv.y1 + rv.size / 2.0f;
		float lvCenterY = lv.y1 + lv.size / 2.0f;

		float xForce = (rv.size + lv.size) / (rvCenterX - lvCenterX) *2.0f;
		float yForce = (rv.size + lv.size) / (rvCenterY - lvCenterY) *2.0f;
		
		//적게 겹친 쪽만 적용.
		if (std::abs(xForce) < std::abs(yForce)) {
			rv.xVelocity += xForce / rv.size;
			lv.xVelocity -= xForce / lv.size;
		}
		else {
			rv.yVelocity += yForce / rv.size;
			lv.yVelocity -= yForce / lv.size;
		}
		
		rv.Move(rv.xVelocity/2, rv.yVelocity/2);
		lv.Move(lv.xVelocity/2, lv.yVelocity/2);

		//단순 충돌
		/*float xCollisionDepth ;
		if (rv.x1 + rv.size - lv.x1 > 0)
			xCollisionDepth = rv.x1 + rv.size - lv.x1;
		else if (lv.x1 + lv.size - rv.x1 > 0)
			xCollisionDepth = lv.x1 + lv.size - rv.x1;
		else
			assert(false);

		float yCollisionDepth;
		if (rv.y1 + rv.size - lv.y1 > 0)
			yCollisionDepth = rv.y1 + rv.size - lv.y1;
		else if (lv.y1 + lv.size - rv.y1 > 0)
			yCollisionDepth = lv.y1 + lv.size - rv.y1;
		else
			assert(false);

		if (xCollisionDepth < yCollisionDepth)
		{
			rv.xVelocity = -rv.xVelocity;
			lv.xVelocity = -lv.xVelocity;
			if (rv.xVelocity > 0)
			{
				rv.Move(xCollisionDepth / 2.0f, 0);
				lv.Move(-xCollisionDepth / 2.0f, 0);
			}
			else
			{
				rv.Move(-xCollisionDepth / 2.0f, 0);
				lv.Move(xCollisionDepth / 2.0f, 0);
			}
			
		}
		else
		{
			rv.yVelocity = -rv.yVelocity;
			lv.yVelocity = -lv.yVelocity;
			if (rv.yVelocity > 0)
			{
				rv.Move(0, yCollisionDepth / 2.0f);
				lv.Move(0, -yCollisionDepth / 2.0f);
			}
			else {
				rv.Move(0, -yCollisionDepth / 2.0f);
				lv.Move(0, yCollisionDepth / 2.0f);
			}
		}*/
		return true;
	}
	return false;
}
Exemplo n.º 22
0
bool eventListener(int &x, int &y, int xcen,int ycen, char Map[][MapMax], char input)
{


//checks if you can move to the north map
    if(CollisionCheck(x,y,xcen,ycen,Map,'`') && input == '\n')
    {
        switch(maplocation)
        {
        case 3:
            maplocation = 0;
            x = 0;
            y = -y;
            break;
        case 4:
            maplocation = 1;
            x = -17;
            y = -y+1;
            break;
        case 6:
            maplocation = 3;
            x = 0;
            y = -y+2;
            break;
        case 7:
            maplocation = 4;
            x = 0;
            y = -y+2;
            break;
        case 8:
            maplocation = 5;
            x = 0;
            y = -y+2;
            break;
        case 9:
            maplocation = 6;
            x = 0;
            y = -y+3;
            break;
        case 10:
            maplocation = 7;
            x = 0;
            y = -y+2;
            break;
        case 11:
            maplocation = 8;
            x = 0;
            y = -y+2;
            break;
        case 13:
            maplocation = 12;
            x = 0;
            y = -y;
            break;
        }
        return true;
    }
//checks if you can move to the east map

    else if(CollisionCheck(x,y,xcen,ycen,Map,':') && input == '\n')
    {
        switch(maplocation)
        {
        case 0:
            maplocation = 1;
            x = -x;
            y = 0;
            break;
        case 1:
            maplocation = 2;
            x = -x;
            y = 0;
            break;
        case 3:
            maplocation = 4;
            x = -x;
            y = 8;
            break;
        case 4:
            maplocation = 5;
            x = -x-1;
            y = -10;
            break;
        case 5:
            maplocation = 12;
            x = -x;
            y = 0;
            break;
        case 6:
            maplocation = 7;
            x = -x;
            y = -5;
            break;
        case 9:
            maplocation = 10;
            x = -x;
            y = 2;
            break;
        }
        return true;
    }
//checks if you can move to the south map

    else if(CollisionCheck(x,y,xcen,ycen,Map,',') && input == '\n')
    {
        switch(maplocation)
        {
        case 0:
            maplocation = 3;
            x = 0;
            y = -y;
            break;
        case 1:
            maplocation = 4;
            x = -17;
            y = -y;
            break;
        case 3:
            maplocation = 6;
            x = 0;
            y = -y;
            break;
        case 4:
            maplocation = 7;
            x = 0;
            y = -y;
            break;
        case 5:
            maplocation = 8;
            x = 0;
            y = -y;
            break;
        case 6:
            maplocation = 9;
            x = 0;
            y = -y;
            break;
        case 7:
            maplocation = 10;
            x = 0;
            y = -y;
            break;
        case 8:
            maplocation = 11;
            x = 0;
            y = -y;
            break;
        case 12:
            maplocation = 13;
            x = 0;
            y = -y;
            break;

        }
        return true;
    }
//checks if you can move to the west map

    else if(CollisionCheck(x,y,xcen,ycen,Map,';') && input == '\n')
    {
        switch(maplocation)
        {
        case 1:
            maplocation = 0;
            x = -x -4;
            y = 0;
            break;
        case 2:
            maplocation = 1;
            x = -x -4;
            y = 0;
            break;
        case 4:
            maplocation = 3;
            x = -x -4;
            y = 8;
            break;
        case 5:
            maplocation = 4;
            x = -x -4;
            y = -14;
            break;
        case 7:
            maplocation = 6;
            x = -x -4;
            y = -3;
            break;
        case 10:
            maplocation = 9;
            x = -x -4;
            y = 2;
            break;
        case 12:
            maplocation = 5;
            x = -x -4;
            y = 0;
            break;
        }
        return true;
    }

// Collision Check for Enemies
    else if(CollisionCheck(x,y,xcen,ycen,Map,'<') || CollisionCheck(x,y,xcen,ycen,Map,'>'))
    {
        CDisplay display;
        display.Message("If the battle system was implemented, you would be fighting.");
        refresh();
        bool leave = false;
        while(leave == false)
        {
            if(Input() == '\n')
            {
                leave = true;
            }
        }
        return true;
    }

// Collision Check for Chests
    else if(CollisionCheck(x,y,xcen,ycen,Map,'&') && input == '\n')
    {
        CDisplay display;
        display.Message("You opened the chest. There was nothing inside!");
        refresh();
        bool leave = false;
        while(leave == false)
        {
            if(Input() == '\n')
            {
                leave = true;
            }
        }
        return true;

    }

// Collision Check for Person A
    else if(CollisionCheck(x,y,xcen,ycen,Map,'A') && input == '\n')
    {
        CDisplay display;
        display.Message("Oh, you're awake. Welcome to the city of Seaview. Yes, I know it's a terrible name. Blame the mayor.You washed up in our lake, so we placed you in our");
        refresh();
        bool leave1 = false;
        while(leave1 == false)
        {
            if(Input() == '\n')
            {
                leave1 = true;
            }
        }
        display.Message("inn to heal. And by inn, I suppose I mean guest   bedroom, considering the size of our town. Anyway,enough of that. Your clothes tell me you're not");
        refresh();
        bool leave2 = false;
        while(leave2 == false)
        {
            if(Input() == '\n')
            {
                leave2 = true;
            }
        }
        display.Message("from around here. Let me guess, you messed up     casting some sort of interdimensional spell and   landed in our lake. ");
        refresh();
        bool leave3 = false;
        while(leave3 == false)
        {
            if(Input() == '\n')
            {
                leave3 = true;
            }
        }
        display.Message("It figures. Truth be told, you're the fourth this year. I don't know why but our town seems to be a popular hotspot for this kind of stuff.");
        refresh();
        bool leave4 = false;
        while(leave4 == false)
        {
            if(Input() == '\n')
            {
                leave4 = true;
            }
        }
        display.Message("My name's Aryn. It's nice to meet you.");
        refresh();
        bool leave5 = false;
        while(leave5 == false)
        {
            if(Input() == '\n')
            {
                leave5 = true;
            }
        }
        clearevent(x,y,xcen,ycen,Map,'A','Á');
        refresh();
        return true;
    }

// Collision Check for Person Á
    else if(CollisionCheck(x,y,xcen,ycen,Map,'Á') && input == '\n')
    {
        CDisplay display;
        display.Message("Nothing new to report here.");
        refresh();
        bool leave1 = false;
        while(leave1 == false)
        {
            if(Input() == '\n')
            {
                leave1 = true;
            }
        }
        return true;
    }

// Collision Check for Person B
    else if(CollisionCheck(x,y,xcen,ycen,Map,'B') && input == '\n')
    {
        CDisplay display;
        if(Event[0] == 0)
        {
            display.Message("I apologize, but my shop is currently closed.");
            refresh();
            bool leave1 = false;
            while(leave1 == false)
            {
                if(Input() == '\n')
                {
                    leave1 = true;
                }
                Event[0] = 1;
            }
        }

        else if(Event[0] == 1)
        {
            display.Message("Please come back at a later time.");
            refresh();
            bool leave2 = false;
            while(leave2 == false)
            {
                if(Input() == '\n')
                {
                    leave2 = true;
                }
            }
        }
        return true;
    }

// Collision Check for Person M
    else if(CollisionCheck(x,y,xcen,ycen,Map,'M') && input == '\n')
    {
        CDisplay display;
        if(Event[0]==1)
        {
// if(Event[0] == 1)
// {
            display.Message("Hm? Some person is locked out of their house?");
            refresh();
            bool leave1 = false;
            while(leave1 == false)
            {
                if(Input() == '\n')
                {
                    leave1 = true;
                }
            }
            display.Message("Well, I may have known you for all of two seconds, but here, take the town keys.");
            refresh();
            bool leave2 = false;
            while(leave2 == false)
            {
                if(Input() == '\n')
                {
                    leave2 = true;
                }
//            event[1] = 1;
            }
//    }
//    else
//    {
            display.Message("I'm busy at the moment.");
            refresh();
            bool leave3 = false;
            while(leave3 == false)
            {
                if(Input() == '\n')
                {
                    leave3 = true;
                }
            }

            display.Message("I'm busy at the moment.");
            refresh();
            bool leave4 = false;
            while(leave4 == false)
            {
                if(Input() == '\n')
                {
                    leave4 = true;
                }
            }
        }
//    }

// Collision Check for Person H
        else if(CollisionCheck(x,y,xcen,ycen,Map,'H') && input == '\n')
        {
            CDisplay display;
            display.Message("For whatever reason the mayor has decided to lock the passageway to my house.");
            refresh();
            bool leave1 = false;
            while(leave1 == false)
            {
                if(Input() == '\n')
                {
                    leave1 = true;
                }
            }
        }

// Collision Check for Doors
        else if(CollisionCheck(x,y,xcen,ycen,Map,'!') && input == '\n')
        {
//        if(event[1] = 1)
            clearevent(x,y,xcen,ycen,Map,'!','#');
        }

//Collision Check for Trees
        else if((CollisionCheck(x,y,xcen,ycen,Map,'[') || CollisionCheck(x,y,xcen,ycen,Map,']') || CollisionCheck(x,y,xcen,ycen,Map,'/') || CollisionCheck(x,y,xcen,ycen,Map,'v'))  && input == '\n')
        {
            CDisplay display;
            display.Message("It's a tree. Fascinating.");
            refresh();
            bool leave = false;
            while(leave == false)
            {
                if(Input() == '\n')
                {
                    leave = true;
                }
            }

        }

// Collision Check for Bosses
        else if(CollisionCheck(x,y,xcen,ycen,Map,'$') && input == '\n')
        {
            CDisplay display;
            display.Message("This would be a boss battle.");
            refresh();
            bool leave = false;
            while(leave == false)
            {
                if(Input() == '\n')
                {
                    leave = true;
                }
            }

        }
        return true;
    }
    return false;
}