Example #1
0
void CArrow::Update(float eTime)
{
	IScene::Update(eTime);
	pos.x += cos(rot) * speed * eTime;
	pos.y += sin(rot) * speed * eTime;
	if (pos.y > App::HEIGHT + 200)
	{
		this->parent->PopScene(this);
		return;
	}

	RECT arrowRect, playerRect, tempRect;
	//RECT ¼³Á¤
	arrowRect.left   = pos.x + rotatingCenter.x - 1;
	arrowRect.right  = pos.x + rotatingCenter.x + 1;
	arrowRect.top    = pos.y + rotatingCenter.y - 1;
	arrowRect.bottom = pos.y + rotatingCenter.y + 1;

	CGameScene *gs = (CGameScene*)this->parent->parent;
	CPlayer *player = gs->m_pPlayer;
	playerRect.left = player->pos.x;
	playerRect.right = player->pos.x + player->normalAni->width;
	playerRect.top = player->pos.y;
	playerRect.bottom = player->pos.y + player->normalAni->height;
	//
	if (IntersectRect(&tempRect, &playerRect, &arrowRect) == true)
	{
		CParticleSystem *p = gs->PushEffect(pos.x + rotatingCenter.x, pos.y + rotatingCenter.y);
		p->start();
		this->parent->PopScene(this);
		return;
	}
}
void CGameScene::PushEffect(float x, float y) {
	CParticleSystem *p = new CParticleSystem("resource/particle/particle.png", 50);
	p->SetPosition(x, y);
	p->setScalep(1, 1);
	p->setColor1(400, 200, 220, 200);
	p->setLife(0.2, 0.3);
	m_pEffectScene->PushScene(p);
	p->start();
}
Example #3
0
void CEnemy1::Update(float eTime)
{
	IEnemy::Update(eTime);
	CGameScene *gs = (CGameScene*)this->parent->parent;
	
	if (hp <= 0)
	{
		CParticleSystem *p = gs->PushEffect(pos.x + ani->width/2, pos.y + ani->height/2 + 55.0f);
		p->setScalep(4.0f, 5.0f);
		p->direction = -90;
		p->spread = 30;
		p->setSpeed(400.0f, 700.0f);
		p->start();


		CGSoundManager * sm = App::GetInstance()->g_pSoundManager;
		sm->Play(2);
		
		this->parent->PopScene(this);
		return;
	}

	time += eTime;
	time2 += eTime;
	if (pos.y < 50)
	{
		pos.y += 150 * eTime;
		if (pos.y > 50) pos.y = 50;
	}

	if (time > 3.0f)
	{
		gs->PushEffect(this->pos.x+20, this->pos.y + 140);
		gs->PushArrow(this->pos.x - 65, this->pos.y + 170, D3DX_PI / 2);
		gs->PushArrow(this->pos.x - 65, this->pos.y + 170, D3DX_PI / 2 - 0.4);
		gs->PushArrow(this->pos.x - 65, this->pos.y + 170, D3DX_PI / 2 + 0.4);
		time = 0.f;
	}

	if (time2 > 7.0f)
	{
		pos.y += 700 * eTime;
	}

	if (pos.y > App::HEIGHT)
	{
		this->parent->PopScene(this);
		return;
	}

}
Example #4
0
void CGameScene::Update(float eTime)
{
	IScene::Update(eTime);
	time += eTime;
	bulletTime += eTime;

	if (time >= delay)
	{
		delay = (float)(rand() % 1000) / 300.f;
		time = 0.f;
		//this->PushArrow(rand() % App::WIDTH, -200.0f);
		this->PushEnemy1(rand() % App::WIDTH, -200.0f);
	}

	//this->PushEffect(rand() % App::WIDTH, rand() % App::HEIGHT);

	for (auto iter = m_pBulletScene->children.begin(); iter != m_pBulletScene->children.end();iter++)
	{
		CBullet *bullet = (CBullet*)(*iter);
		
		RECT bulletRect;
		bulletRect.left = bullet->pos.x;
		bulletRect.top = bullet->pos.y;
		bulletRect.right = bullet->pos.x + bullet->sprite->width;
		bulletRect.bottom = bullet->pos.y + bullet->sprite->height;

		for (auto iter2 = m_pEnemyScene->children.begin(); iter2 != m_pEnemyScene->children.end();iter2++)
		{
			IEnemy *enemy = (IEnemy*)(*iter2);
			
			RECT enemyRect;
			enemyRect.left = enemy->pos.x;
			enemyRect.top = enemy->pos.y;
			enemyRect.right = enemy->pos.x + enemy->width;
			enemyRect.bottom = enemy->pos.y + enemy->height;

			RECT t;
			if (IntersectRect(&t, &bulletRect, &enemyRect) == true)
			{
				CParticleSystem *p = PushEffect(bullet->pos.x, bullet->pos.y);
				p->start();
				bullet->available = false;
				enemy->hit();
				break;
			}
		}
	}

}