示例#1
0
文件: Enemy.cpp 项目: Mistakex/SP-2
void Enemy::update(Camera3 camera,const double &dt, Player *p,vector<Turret> *Turrets)
{
	if (redAlien)
	{
		redTimer += (float)dt;
		if (redTimer > 0.3f)
		{
			redAlien = false;
			redTimer = 0.f;
		}
	}
	if (Turrets->empty())
	{
		target = camera.position;
	}
	else
	{
		float minDist = 1000;
		int turretNumber2 = 0;
		for (vector<Turret>::iterator it = (*Turrets).begin(); it != (*Turrets).end(); ++it, ++turretNumber2)
		{
			if (sqrt(pow((it->GetPosition() - position).x, 2) + pow((it->GetPosition() - position).y, 2) + pow((it->GetPosition() - position).z, 2)) < minDist)
			{
				minDist = sqrt(pow((it->GetPosition() - position).x, 2) + pow((it->GetPosition() - position).y, 2) + pow((it->GetPosition() - position).z, 2));
				target = it->GetPosition();
				turretNumber = turretNumber2;
			}
		}
	}
	EnemyMove(dt,p,Turrets);
}
示例#2
0
文件: main.cpp 项目: shadowjen/vantan
// メインプログラム
// 
int main() {
	// アプリウインドウの準備
	AppEnv app_env(Window::WIDTH, Window::HEIGHT,
		false, true);

	Texture block1("res/block1.png");
	//Texture bg1("res/");

	int map_x = 0;
	int map_y = 0;
	int count = 0;

	Vec2f map_num[MAP_Y*MAP_X];

	for (map_y = MAP_Y - 1; map_y > -1 ;map_y--){
		for (map_x = 0; map_x < MAP_X; map_x++)
		{
			map_num[count] = Vec2f(Pos_x(size * (map_x)), Pos_y(size * map_y));
			count++;
		}
	}


	while (1)
	{
		if (!app_env.isOpen())return(0);
		app_env.setupDraw();

		Vec2f  mousepos = app_env.mousePosition();
		

			for (map_y = 0; map_y < MAP_Y; map_y++){
				for (map_x = 0; map_x < MAP_X; map_x++)
				{
					Draw2(map_num[(map_y*14)+map_x].x(), map_num[map_y*MAP_X+map_x].y());
				}
			}

		//EnemyMove();

		EnemyMove(map_num);

		Draw();



		drawFillBox(mousepos.x(), mousepos.y(), 20, 20, Color(1, 1, 1),0,Vec2f(1,1),Vec2f(10,10));

		app_env.update();
	}

	// アプリ終了
}
示例#3
0
void Unit_Dig::Update(void)
{
	if( m_Life <= 0)
	{
		TaskSet_DeadCalc( m_x, m_y, this );
		m_Exist = false;
	}
	SetStatus();
	BadStatusUpdate();
	switch(m_MoveStatus)
	{
	case UnitBase::MovePoint:
		MovePoint();
		break;
	case UnitBase::Free:
		FreeMove();
		break;
	case UnitBase::Enemy:
		EnemyMove();
	default:
		break;
	}
	
}
示例#4
0
//================================================
//ゲームメイン画面描画
//================================================
void DrawMain(void)
{
	frame.IsDisp = TRUE;
	
	/*当たり判定領域設定*/
	SetHitRect();
	
	g_Second++;
	
	if(!player.IsStop)
	{
		g_gamecounter++;
	}
	
	//------------------------------------------
	//アニメーション処理
	//------------------------------------------
	if(g_Second % 20 == 0)
	{
		player.animcounter++;

		if(!player.IsStop)
		{
			for(int i = 0;i < ENEMY_NUM;i++)
			{
				enemy[i].animcounter++;
			}
			
			boss.animcounter++;
		}
		
	}
	
	if(g_Second % 5 == 0)
	{
		if(!player.IsStop)
		{
			for(int i = 0;i < SKULL_NUM;i++)
			{
				boss.skull[i].animcounter++;
			}
			
			for(int i = 0;i < KNIFE_NUM;i++)
			{
				boss.knife[i].animcounter++;
			}
		}
		
	}

	/*ショット処理*/
	player.Shoot();
		
	/*当たり判定チェック*/
	CheckHitRect();
	
	//----------------------------------------
	//移動
	//----------------------------------------
	player.Move();
	
	/*敵の移動処理*/
	if(!player.IsStop)
	{
		EnemyMove();
		EnemyShoot();
	}
	
	/*ボスの移動処理*/
	if(!player.IsStop)
	{
		BossMove();
	}
	
	/*移動範囲補正*/
	MoveAdjust();
	
	player.UseGauge();
		
	//if(player.IsUseSpecial)
	//{
	//	if(LunaPad::GetState(0, PAD_STATE_PUSH, PAD_BUTTON_03) )
	//	{
	//		player.IsUseSpecial = FALSE;
	//	}
	//}
		
	//-----------------------------------------------------
	//化身状態
	//-----------------------------------------------------
	
	/*ポーズ*/
	if(LunaPad::GetState(0, PAD_STATE_PUSH, PAD_BUTTON_05) )
	{
		g_GameMode = SCENE_PAUSE;
	}
	
	/*カメラ更新*/
	if(!player.IsStop)
	{
		camera.Update();
	}
	
	model.Translation();
	
	/*キャラクタ変更*/
	player.UseCharaChange();
	
	/*待機ライフ回復*/
	if(Luna::GetSyncCounter() % 20 == 0)
	{
		player.Recoverlife();
	}
	
	/*ゲームオーバー処理*/
	if(player.IsDead)
	{
		g_GameMode = SCENE_GAMEOVER;
	}
	
	/*ボス死亡処理*/
	boss.Dead(&g_GameMode);
	
	player.Draw();
	
	//----------------------------------
	//シーン開始
	//----------------------------------
	if ( Luna3D::BeginScene() )
	{
		/*レンダリング*/
		Luna3D::SetRenderState(D3DRS_FOGENABLE, TRUE);
		
		model.Rendering();
		
		if(player.IsStop)
		{
			screen.IsDisp = TRUE;
			
			Luna3D::SetBlendingType(BLEND_REVERSE);
			screen.DrawTexture();
			Luna3D::SetBlendingType(BLEND_NORMAL);
		}
		
		Luna3D::SetRenderState(D3DRS_FOGENABLE, FALSE);
		
		Luna3D::SetFilterEnable(TRUE);
		
		/*敵出現ポイント*/
		EnemyPoint();
		
		frame.DrawTexture();
		
		player.Rendering();
		
		score.DrawFont(g_Score);
	
		boss.Rendering();
		
		// シーン終了
		Luna3D::EndScene();
	}
	
}