Пример #1
0
cocos2d::Vec2 Blocks::GeneratePoint(float startWidth, float endWidth, float height)
{
	Vec2 point = Vec2::ZERO;
	point.x = RandomFloatBetween(startWidth, endWidth);
	point.y = height;
	return point;
}
Пример #2
0
NormalEnemy::NormalEnemy(BaseEngine* pEngine ) 
	: EnemyProperties( pEngine )
{
	// Current and previous coordinates for the object - set them the same 
	//initially 

	int xVal, yVal;

	switch (rand()%4)
	{
	case 0:
		xVal = - (m_iDrawWidth/2);
		yVal = rand() % GetEngine()->GetScreenHeight();
		break;

	case 1:	
		xVal = rand() % GetEngine()->GetScreenWidth();
		yVal = - (m_iDrawHeight/2);
		break;

	case 2:
		xVal = rand() % GetEngine()->GetScreenWidth();
		yVal = GetEngine()->GetScreenHeight() + (m_iDrawHeight/2);
		break;

	case 3:
		xVal = GetEngine()->GetScreenWidth() + (m_iDrawWidth/2);
		yVal = rand() % GetEngine()->GetScreenHeight();
		break;

	default:
		break;
	}

	SetSpeed(RandomFloatBetween(MIN_ENEMY_SPEED, MAX_ENEMY_SPPED));

	m_iCurrentScreenX = m_iPreviousScreenX = xVal; 
	m_iCurrentScreenY = m_iPreviousScreenY = yVal; 
	// The object coordinate will be the top left of the object 

	m_iStartDrawPosX = 0; 
	m_iStartDrawPosY = 0;

	// And make it visible 
	SetVisible(true); 
}