Exemple #1
0
void ExplosionSprite::on_update() {
	if (!m_is_dead && animator()->is_done()) {
		send_dead_message();
		m_is_dead = true;
		is_visible(false);
	}
}
Exemple #2
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QApplication::setApplicationName("Animator");
    QApplication::setApplicationVersion("1.0");

    QStringList files;
    float duration;
    float fps;
    std::tie(files, duration, fps) = processArgs(app);

    Animator animator(files, duration, fps);
    animator.show();

    return app.exec();
}
Exemple #3
0
void Game::run()
{
	sf::Clock clock;
	sf::Time timeSinceLastUpdate = sf::Time::Zero;
	while (mWindow.isOpen())
	{
		sf::Time elapsedTime = clock.restart();
		timeSinceLastUpdate += elapsedTime;
		while (timeSinceLastUpdate > TimePerFrame)
		{
			timeSinceLastUpdate -= TimePerFrame;

			if (use_gp)
				processGamepad();

			processEvents();
			update(TimePerFrame);
			physics(TimePerFrame);
			animator(TimePerFrame);
		}

		render();
	}
}
Exemple #4
0
	/**
	 * Attempts to move the unit along the expected path.
	 * (This will do nothing unless check_expected_movement() was called first.)
	 *
	 * @param[in]  show            Set to false to suppress animations.
	 */
	void unit_mover::try_actual_movement(bool show)
	{
		static const std::string enter_hex_str("enter_hex");
		static const std::string exit_hex_str("exit_hex");

		const bool ally_interrupts = preferences::interrupt_when_ally_sighted();

		bool obstructed_stop = false;


		// Check for hidden units along the expected path before we start
		// animating and firing events.
		cache_hidden_units(begin_, expected_end_);

		if ( begin_ != ambush_limit_ ) {
			// Cache the moving unit's visibility.
			std::vector<int> not_seeing = get_sides_not_seeing(*move_it_);

			// Prepare to animate.
			unit_display::unit_mover animator(route_, show);
			animator.start(*move_it_);

			// Traverse the route to the hex where we need to stop.
			// Each iteration performs the move from real_end_-1 to real_end_.
			for ( real_end_ = begin_+1; real_end_ != ambush_limit_; ++real_end_ ) {
				const route_iterator step_from = real_end_ - 1;
				const bool can_break = !is_replay_  ||  replay_dest_ == *step_from;

				// See if we can leave *step_from.
				// Already accounted for: ambusher
				if ( event_mutated_  &&  can_break )
					break;
				if ( sighted_ && can_break && is_reasonable_stop(*step_from) )
				{
					sighted_stop_ = true;
					break;
				}
				// Already accounted for: ZoC
				// Already accounted for: movement cost
				if ( fire_hex_event(exit_hex_str, step_from, real_end_) ) {
					if ( can_break ) {
						report_extra_hex_ = true;
						break;
					}
				}
				if ( real_end_ == obstructed_ ) {
					// We did not check for being a replay when checking for an
					// obstructed hex, so we do not check can_break here.
					report_extra_hex_ = true;
					obstructed_stop = true;
					break;
				}
				if ( is_replay_  &&  replay_dest_ == *step_from )
					// Preserve the replay.
					break;

				// We can leave *step_from. Make the move to *real_end_.
				bool new_animation = do_move(step_from, real_end_, animator);
				// Update the fog.
				if ( current_uses_fog_ )
					handle_fog(*real_end_, ally_interrupts, new_animation);
				animator.wait_for_anims();

				// Fire the events for this step.
				// (These return values are not checked since real_end_ still
				// needs to be incremented. The event_mutated_ check will break
				// us out of the loop if needed.)
				fire_hex_event(enter_hex_str, real_end_, step_from);
				// Sighted events only fire if we could stop due to sighting.
				if ( is_reasonable_stop(*real_end_) )
					pump_sighted(real_end_);
			}//for
			// Make sure any remaining sighted events get fired.
			pump_sighted(real_end_-1);

			if ( move_it_.valid() ) {
				// Finish animating.
				animator.finish(*move_it_);
				// Check for the moving unit being seen.
				event_mutated_ = actor_sighted(*move_it_, &not_seeing);
			}
		}//if

		// Some flags were set to indicate why we might stop.
		// Update those to reflect whether or not we got to them.
		ambushed_ = ambushed_ && real_end_ == ambush_limit_;
		blocked_  = blocked_  && obstructed_stop;
		teleport_failed_ = teleport_failed_ && obstructed_stop;
		// event_mutated_ does not get unset, regardless of other reasons
		// for stopping, but we do save its current value.
		event_mutated_mid_move_ = event_mutated_;

		// Need the default ambush message?
		if ( ambushed_  &&  ambush_string_.empty() )
			ambush_string_ = _("Ambushed!");
	}
Exemple #5
0
void zoomOnScreenRegion(GlMainWidget *glWidget, const BoundingBox &boundingBox, const bool optimalPath,
                        const double velocity, const double p) {
  QtGlSceneZoomAndPanAnimator animator(glWidget, boundingBox,1000,"Main", optimalPath, velocity, p);
  animator.animateZoomAndPan();
}
Exemple #6
0
ExplosionSprite::ExplosionSprite()
	: Sprite("res/images/explosion_1.png", make_size(32,32))
{	
	m_is_dead = false;
	animator(new ForwardOnceAnimator(7, 50, false));
}
Exemple #7
0
void ExplosionSprite::on_pool_obtain() {
	m_is_dead = false;
	animator()->reset();
	is_visible(true);
}
//calls all the updates and then checks for user button presses and draws everything to the screen.
void runGame() {

	if(state == GAMEOVER) {
		return;
	}

	oldGary = gary;

	updateGary();


	oldMidWall[0] = middleWall[0];
	oldMidWall[1] = middleWall[1];
	oldMidWall[2] = middleWall[2];
	updateMiddle();

	for (int i = 0; i < 3; i++) {
		drawRect3(oldMidWall[i].yPos, oldMidWall[i].xPos, oldMidWall[i].width, oldMidWall[i].height, BLACK);
		drawRect3(middleWall[i].yPos, middleWall[i].xPos, middleWall[i].width, middleWall[i].height, middleWall[i].color);
	}

	for (int i = 0; i < NUM_RECS; i++)
	{
		oldTopWall[i] = topWall[i];
		oldBottomWall[i] = bottomWall[i];
	}

	updateBarriers();

	

	for (int i = 0; i < NUM_RECS; i++) {
		drawRect3(oldBottomWall[i].yPos, bottomWall[i].xPos, bottomWall[i].width, bottomWall[i].height, BLACK);
	}

	for (int i = 0; i < NUM_RECS; i++) {
		drawRect3(bottomWall[i].yPos, bottomWall[i].xPos, bottomWall[i].width, bottomWall[i].height, bottomWall[i].color);
	}



	for (int i = 0; i < NUM_RECS; i++) {
		
		drawRect3(oldTopWall[i].yPos, topWall[i].xPos, topWall[i].width, topWall[i].height, BLACK);

	}

	for (int i = 0; i < NUM_RECS; i++) {
		
		drawRect3(topWall[i].yPos, topWall[i].xPos, topWall[i].width, topWall[i].height, topWall[i].color);
		
	}


	distance += 1;
	sprintf(buffer, "Distance: %d", distance);
	drawString(150, 5, buffer, WHITE);
	drawRect3(0,0,240,20,RED);
	
	drawRect3(oldGary.xPos, oldGary.yPos, 15, 21, BLACK);
	animator(gary.xPos, gary.yPos);
	if(isHit())
		endGame();
	

}