Beispiel #1
0
void conway_test()
{
	force_write(1,2,is_world_calc);
	force_write(2,2,is_world_calc);
	force_write(3,2,is_world_calc);
	display_world();

	//write_cell(3, 3, 2);
	//display_world();
	printf("%i \n",check_cell(1, 2, is_world_calc));
	printf("%i \n",check_cell(2, 2, is_world_calc));
	printf("%i \n",check_cell(3, 2, is_world_calc));
	printf("%i \n",check_cell(2, 1, is_world_calc));
	on_tick();
	printf("%i \n",check_cell(1, 2, is_world_calc));
	printf("%i \n",check_cell(2, 2, is_world_calc));
	printf("%i \n",check_cell(3, 2, is_world_calc));
	printf("%i \n",check_cell(2, 1, is_world_calc));
	on_tick();
	printf("%i \n",check_cell(1, 2, is_world_calc));
	printf("%i \n",check_cell(2, 2, is_world_calc));
	printf("%i \n",check_cell(3, 2, is_world_calc));
	printf("%i \n",check_cell(2, 1, is_world_calc));
	on_tick();
}
Beispiel #2
0
/**
 * @brief Clock::Clock constructor
 * @param parent - used for memory management (Clock will be added to param's cildren list and will be deleted with param)
 */
Clock::Clock(QWidget *parent): QLCDNumber(parent), m_time(0, 0, 0) {
    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(on_tick()));
    m_timer->start(1000);
    display(m_time.toString("hh:mm:ss"));
    setFixedSize(100, 30);
}
void BaseElement::run() {
	if (initial_tick) {
		on_start();
		initial_tick = false;
	}
	else {
		on_tick();
	}
}
static gboolean
on_tick (MateBGCrossfade *fade)
{
	gdouble now, percent_done;
	cairo_t *cr;
	cairo_status_t status;

	g_return_val_if_fail (MATE_IS_BG_CROSSFADE (fade), FALSE);

	now = get_current_time ();

	percent_done = (now - fade->priv->start_time) / fade->priv->total_duration;
	percent_done = CLAMP (percent_done, 0.0, 1.0);

	/* If it's taking a long time to get to the first frame,
	 * then lengthen the duration, so the user will get to see
	 * the effect.
	 */
	if (fade->priv->is_first_frame && percent_done > .33) {
		fade->priv->is_first_frame = FALSE;
		fade->priv->total_duration *= 1.5;
		return on_tick (fade);
	}

	if (fade->priv->fading_surface == NULL ||
	    fade->priv->end_surface == NULL) {
		return FALSE;
	}

	if (animations_are_disabled (fade)) {
		return FALSE;
	}

	/* We accumulate the results in place for performance reasons.
	 *
	 * This means 1) The fade is exponential, not linear (looks good!)
	 * 2) The rate of fade is not independent of frame rate. Slower machines
	 * will get a slower fade (but never longer than .75 seconds), and
	 * even the fastest machines will get *some* fade because the framerate
	 * is capped.
	 */
	cr = cairo_create (fade->priv->fading_surface);

	cairo_set_source_surface (cr, fade->priv->end_surface,
				  0.0, 0.0);
	cairo_paint_with_alpha (cr, percent_done);

	status = cairo_status (cr);
	cairo_destroy (cr);

	if (status == CAIRO_STATUS_SUCCESS) {
		draw_background (fade);
	}
	return percent_done <= .99;
}
Beispiel #5
0
bool FePresent::tick()
{
	bool ret_val = false;
	if ( on_tick())
		ret_val = true;

	if ( video_tick() )
		ret_val = true;

	return ret_val;
}
Beispiel #6
0
bool Application::run(const std::string& name, const uint2& dimensions, bool windowed)
{
	if (!init(name, dimensions, windowed))
	{
		return false;
	}

	double accumulator = simulation_frequency_;

	while (!request_close_)
	{
        client_.update();

		const platform::Message message = client_.query_message();

		if (platform::Message::Quit == message)
		{
			break;
		}
		else if (platform::Message::Nothing == message)
		{
			update();

			double frame_time = fps_counter_.frame_time();
			accumulator += frame_time;

			while (accumulator >= simulation_frequency_)
			{
				/*
				previousState = currentState;
				integrate( currentState, t, dt );
				t += dt;
				*/

				scene_.on_tick(time_slice_);

				scripter_.execute_on_tick(time_slice_);

				on_tick(time_slice_);

				accumulator -= simulation_frequency_;
			}

			float interpolation_delta = static_cast<float>(accumulator / simulation_frequency_);

			float frame_time_float = static_cast<float>(frame_time);

			float speed = frame_time_float * (time_slice_ / static_cast<float>(simulation_frequency_));

			scene_.on_update(interpolation_delta, frame_time_float, speed);

			on_render(interpolation_delta);

			//---
			controls_.cleanup_update();
			//--
		}
	}

	release();

	return true;
}