示例#1
0
文件: PlayState.cpp 项目: nebula2/Pew
void PlayState::HandleUpdates(Game &game){
	UpdateManager::EnemyUpdate(enemyv, game.window, elapsedTime, game.highscore);				//enemy
	UpdateManager::StdUpdate(enemyFormationv, game.window, elapsedTime);						//enemyFormation
	UpdateManager::StdUpdate(monkeyv, game.window, elapsedTime);								//monkey
	UpdateManager::StdUpdate(shitv, game.window, elapsedTime);									//shit
	UpdateManager::StdUpdate(boss1v, game.window, elapsedTime);									//boss1
	UpdateManager::StdUpdate(unlockPewv, game.window, elapsedTime);								//unlockpew
	UpdateManager::StdUpdate(b1Weaponv, game.window, elapsedTime);								//b1Weapon
	UpdateManager::StdUpdate(boss2v, game.window, elapsedTime);									//boss2
	UpdateManager::Boss2WeaponUpdate(boss2Weaponv, game.window, elapsedTime, player1);			// b2Weapon
	UpdateManager::StdUpdate(boss3v, game.window, elapsedTime);									//boss3
	UpdateManager::StdUpdate(cowv, game.window, elapsedTime);									//cow
	UpdateManager::StdUpdate(healthv, game.window, elapsedTime);								//health
	UpdateManager::StdUpdate(boss3FWeaponv, game.window, elapsedTime);							//boss3firstWeapon
	UpdateManager::StdUpdate(boss3SWeaponv, game.window, elapsedTime);							//boss3SecWeapon
																								
	UpdateManager::WeaponUpdate(bulletv, elapsedTime);								//bullet
	UpdateManager::WeaponUpdate(dShotv, elapsedTime);								//double shot
	UpdateManager::WeaponUpdate(pewv, elapsedTime);									//pewv

	UpdateHUD(game.window);

	if (player1.getActiveBool())
	player1.Update(game.window, elapsedTime);
}
示例#2
0
void Vehicle::Update()
{
  UpdateHUD();
  UpdateWheels();
  UpdateEffects();
  UpdateSounds();
  UpdateCameraEntity();
  UpdateLight();
}
    // IGameFramework methods
    void CCoherentUISystem::OnPostUpdate( float fDeltaTime )
    {
        SetTexturesForListeners();

        if ( m_pUISystem )
        {
            UpdateHUD();
            m_pUISystem->Update();
        }
    }
示例#4
0
void StopRun(char reason[255])
{
	isRunning=false;
	DumpToFile();
	//CaptureScene(); don't know why this doesn't work
	printf("Run Stopped. (Reason: %s)\n",reason);
	char logFile[255];
	sprintf(logFile,"%s\\%s\\%s.log",_getcwd(NULL,0),gRunBaseName,gRunBaseName);
	LogRunStats(logFile);
	LogExperimentStats(logFile);
	WritePrivateProfileString("experiment","stop_reason",reason,logFile);
	SetThreadExecutionState(ES_CONTINUOUS); // save electricity for the uni
	if (bQuitWhenDone) exit(0);
	UpdateHUD();
}
示例#5
0
void Simulation::Step() {
	// dispatch the new frame, this wraps up the follow Viewer operations:
	//   advance() to the new frame
	//   eventTraversal() that collects events and passes them on to the event handlers and event callbacks
	//   updateTraversal() to calls the update callbacks
	//   renderingTraversals() that runs syncronizes all the rendering threads (if any) and dispatch cull, draw and swap buffers

	int64 tmptime = cvGetTickCount();
	int64 difftime = (tmptime-loop_time_)/cvGetTickFrequency();
//	if(difftime < loop_target_time_){
//		//std::cout<<"sleeping: "<<loop_target_time_-difftime<<std::endl;
//		usleep(loop_target_time_-difftime);
//		return;
//	}
	loop_time_ = tmptime;



	viewer_.advance();
	viewer_.eventTraversal();
	viewer_.updateTraversal();
	viewer_.renderingTraversals();

//	osg::Matrix testmat = viewer_.getView(2)->getCamera()->getProjectionMatrix();
//	testmat = viewer_.getView(2)->getCamera()->getProjectionMatrix();
//	std::cout<<testmat(0,0)<<"  "<<testmat(0,1)<<"  "<<testmat(0,2)<<"  "<<testmat(0,3)<<std::endl;
//	std::cout<<testmat(1,0)<<"  "<<testmat(1,1)<<"  "<<testmat(1,2)<<"  "<<testmat(1,3)<<std::endl;
//	std::cout<<testmat(2,0)<<"  "<<testmat(2,1)<<"  "<<testmat(2,2)<<"  "<<testmat(2,3)<<std::endl;
//	std::cout<<testmat(3,0)<<"  "<<testmat(3,1)<<"  "<<testmat(3,2)<<"  "<<testmat(3,3)<<std::endl;
//	std::cout<<std::endl;




	viewer_.getView(0)->getCamera()->getViewMatrixAsLookAt(view_matrix_eye_, view_matrix_center_, view_matrix_up_, view_matrix_distance_);
	view_matrix_ = viewer_.getView(0)->getCamera()->getViewMatrix();

//	osg::Matrix windowMatrix = viewer_.getView(2)->getCamera()->getViewport()->computeWindowMatrix();
//	osg::Matrix projectionMatrix = viewer_.getView(2)->getCamera()->getProjectionMatrix();
//	osg::Matrix mat = projectionMatrix*windowMatrix;
//	std::cout<<"mat: "<<mat(0,0)<<" "<<mat(1,1)<<" "<<mat(2,0)<<" "<<mat(2,1)<<std::endl;
//	std::cout<<"eye: "<<view_matrix_eye_.x()<<" "<<view_matrix_eye_.y()<<" "<<view_matrix_eye_.z()<<std::endl;

	if(particles_on_){
		// The dynamic update of the particle filter.
		localisation_->dynamic(robotdata_->incremente_left_,robotdata_->incremente_right_);

		// Update of simulations view of particles.
		particle_view_->Update(localisation_->getParticles(), particle_visibility_ratio_);
	}

	//Picture handling
	if(screen_shot_callback_->isPicTaken() && !picture_processed_){
		osg::ref_ptr<osg::Image> osgImage = screen_shot_callback_->getImage();
		cv::Mat cvImg(osgImage->t(), osgImage->s(), CV_8UC3);
		cv::Mat cvCopyImg(osgImage->t(), osgImage->s(), CV_8UC3);
		cvImg.data = (uchar*)osgImage->data();
		cv::flip(cvImg, cvCopyImg, 0); // Flipping because of different origins
		observedImg_ = &cvCopyImg;

		// Write position, orientation and image to log file.
		data_to_file_writer_.WriteData(robotdata_->incremente_left_, robotdata_->incremente_right_,
												robotdata_->x_pos_, view_matrix_eye_[0], localisation_->getPosition().at(0),
												robotdata_->y_pos_, view_matrix_eye_[1], localisation_->getPosition().at(2),
												robotdata_->psi_, view_matrix_(0,0), localisation_->getOrientation().at(1), cvCopyImg);
		Observe();
		//		old version
		//		data_to_file_writer_.WritePlotData(	robotdata_->x_pos_, robotdata_->y_pos_, robotdata_->psi_,
		//											localisation_->getPosition().at(0), localisation_->getPosition().at(2),
		//											localisation_->getPosition().at(1)*3, localisation_->getPosition().at(3)*3, true);
				es_ = localisation_->getEstimatedRobotPose();
				data_to_file_writer_.WritePlotData(	robotdata_->x_pos_, robotdata_->y_pos_,
													es_->x, es_->y,
													es_->sigmaXYLarge, es_->sigmaXYSmall,
													es_->sigmaXYAngle/M_PI*180, true);
		// observe for particle filter is done here.
		picture_processed_ = true;
	}

	else {
		// writes the current position and orientation of the robot to file.
		data_to_file_writer_.WriteData(robotdata_->incremente_left_, robotdata_->incremente_right_,
														robotdata_->x_pos_, view_matrix_eye_[0], localisation_->getPosition().at(0),
														robotdata_->y_pos_, view_matrix_eye_[1], localisation_->getPosition().at(2),
														robotdata_->psi_, view_matrix_(0,0), localisation_->getOrientation().at(1));

		es_ = localisation_->getEstimatedRobotPose();
		data_to_file_writer_.WritePlotData(	robotdata_->x_pos_, robotdata_->y_pos_,
											es_->x, es_->y,
											es_->sigmaXYLarge, es_->sigmaXYSmall,
											es_->sigmaXYAngle/M_PI*180);
	}

	UpdateHUD();

	// without pad_control pictures are taken every takepicture_intervall_ ms
//	if( (!pad_control_on_) && (0.001*(cvGetTickCount()-take_picture_timer_)/cvGetTickFrequency()>takepicture_intervall_) ){
//		std::cout<<"Sim: 'I queued a Shot!'"<<std::endl;
//		screen_shot_callback_->queueShot();
//		picture_processed_ = false;
//		take_picture_timer_ = cvGetTickCount();
//	}

	if(step_counter_ % takepicture_intervall_ == 0){
		screen_shot_callback_->queueShot();
		picture_processed_ = false;
		take_picture_timer_ = cvGetTickCount();
	}

	if(pad_control_on_){
		if(picture_processed_ && !take_picture_button_pressed_ && sixaxes_->buttonPressed(BUTTON_CIRCLE)){
				// Every 2 sec a Shot is queued to get a picture form the scene.
				screen_shot_callback_->queueShot();
				take_picture_button_pressed_ = true;
				picture_processed_ = false;
				take_picture_timer_ = cvGetTickCount();
		}

		if(!sixaxes_->buttonPressed(BUTTON_CIRCLE))
			take_picture_button_pressed_ = false;

		// If Padcontrol is enabled, the inputs from the pad are written to the robotData.
		// That way the callback will use the inputs to move the robot.
		if(sixaxes_->buttonPressed(BUTTON_L1) && sixaxes_->buttonPressed(BUTTON_R1)){
			robotdata_->speed_ = sixaxes_->axis(AXIS_LY)*-0.2;
			robotdata_->psi_speed_ = sixaxes_->axis(AXIS_RX)*-0.05;
		}
		else{
			robotdata_->speed_ = 0.0;
			robotdata_->psi_speed_ = 0.0;
		}
		if(sixaxes_->buttonPressed(BUTTON_TRIANGLE)){
			while(viewer_.areThreadsRunning()){
				viewer_.stopThreading();
			}
			viewer_.setDone(true);
		}
	}

	if(!trajectory_from_file_.empty()){
		double temp = trajectory_from_file_.front();
		if(temp<1){
			//screen_shot_callback_->queueShot();
			//picture_processed_ = false;
		}
		trajectory_from_file_.erase(trajectory_from_file_.begin());

		temp = trajectory_from_file_.front();
		if(temp>0){
			while(viewer_.areThreadsRunning()){
				viewer_.stopThreading();
			}
			viewer_.setDone(true);
		}
		trajectory_from_file_.erase(trajectory_from_file_.begin());

		temp = trajectory_from_file_.front();
		robotdata_->speed_ = temp;
		trajectory_from_file_.erase(trajectory_from_file_.begin());

		temp = trajectory_from_file_.front();
		robotdata_->psi_speed_ = temp;
		trajectory_from_file_.erase(trajectory_from_file_.begin());
	}
	else{
		trajectory_buffer_ << screen_shot_callback_->isPicTaken() << std::endl;
		trajectory_buffer_ << viewer_.done() << std::endl;
		trajectory_buffer_ << robotdata_->speed_ << std::endl;
		trajectory_buffer_ << robotdata_->psi_speed_ << std::endl;
	}
	//trajectory_buffer_ << "------------------" << std::endl;
	step_counter_ ++;
}
void RPG_GuiManager_VisionGUI::OnTick(float const deltaTime)
{
  RPG_Character* characterEntity = static_cast<RPG_Character *>(RPG_PlayerUI::s_instance.GetController()->GetOwner());
  VASSERT(characterEntity);
  UpdateHUD(characterEntity, deltaTime);
}
void HUD::Update()
{
	UpdateFrame();
	UpdateHUD();
}