示例#1
0
static void DisplayLoop()
{
	
#if defined(USE_OPENGL) || defined(USE_GLES)
	if (UseOpenGL) {
		/* update only if screen changed */
		ValidateOpenGLScreen();
	}
#endif

	/* update only if viewmode changed */
	CheckViewportMode();

	/*
	 *	update only if Update flag is set
	 *	FIXME: still not secure
	 */
	if (UI.Minimap.UpdateCache) {
		UI.Minimap.Update();
		UI.Minimap.UpdateCache = false;
	}

	//
	// Map scrolling
	//
	DoScrollArea(MouseScrollState | KeyScrollState, (KeyModifiers & ModifierControl) != 0, MouseScrollState == 0 && KeyScrollState > 0);

	ColorCycle();

#ifdef REALVIDEO
	if (FastForwardCycle > GameCycle && RealVideoSyncSpeed != VideoSyncSpeed) {
		RealVideoSyncSpeed = VideoSyncSpeed;
		VideoSyncSpeed = 3000;
	}
#endif
	if (FastForwardCycle <= GameCycle || GameCycle <= 10 || !(GameCycle & 0x3f)) {
		//FIXME: this might be better placed somewhere at front of the
		// program, as we now still have a game on the background and
		// need to go through the game-menu or supply a map file
		UpdateDisplay();

		//
		// If double-buffered mode, we will display the contains of
		// VideoMemory. If direct mode this does nothing. In X11 it does
		// XFlush
		//
		RealizeVideoMemory();
	}
#ifdef REALVIDEO
	if (FastForwardCycle == GameCycle) {
		VideoSyncSpeed = RealVideoSyncSpeed;
	}
#endif
}
示例#2
0
static void DisplayLoop()
{
#if defined(USE_OPENGL) || defined(USE_GLES)
	if (UseOpenGL) {
		/* update only if screen changed */
		ValidateOpenGLScreen();
	}
#endif

	/* update only if viewmode changed */
	CheckViewportMode();

	/*
	 *	update only if Update flag is set
	 *	FIXME: still not secure
	 */
	if (UI.Minimap.UpdateCache) {
		UI.Minimap.Update();
		UI.Minimap.UpdateCache = false;
	}

	//
	// Map scrolling
	//
	DoScrollArea(MouseScrollState | KeyScrollState, (KeyModifiers & ModifierControl) != 0, MouseScrollState == 0 && KeyScrollState > 0);

	ColorCycle();

	//Wyrmgus start
	//do tile animation
	if (!GamePaused && GameCycle != 0 && GameCycle && GameCycle % (CYCLES_PER_SECOND / 4) == 0) { // same speed as color-cycling
		for (size_t z = 0; z < Map.Fields.size(); ++z) {
			for (int i = 0; i < Map.Info.MapWidths[z] * Map.Info.MapHeights[z]; ++i) {
				CMapField &mf = Map.Fields[z][i];
				if (mf.Terrain && mf.Terrain->SolidAnimationFrames > 0) {
					mf.AnimationFrame += 1;
					if (mf.AnimationFrame >= mf.Terrain->SolidAnimationFrames) {
						mf.AnimationFrame = 0;
					}
				}
				if (mf.OverlayTerrain && mf.Terrain->SolidAnimationFrames > 0) {
					mf.OverlayAnimationFrame += 1;
					if (mf.OverlayAnimationFrame >= mf.Terrain->SolidAnimationFrames) {
						mf.OverlayAnimationFrame = 0;
					}
				}
			}
		}
	}
	//Wyrmgus end
		
#ifdef REALVIDEO
	if (FastForwardCycle > GameCycle && RealVideoSyncSpeed != VideoSyncSpeed) {
		RealVideoSyncSpeed = VideoSyncSpeed;
		VideoSyncSpeed = 3000;
	}
#endif
	if (FastForwardCycle <= GameCycle || GameCycle <= 10 || !(GameCycle & 0x3f)) {
		//FIXME: this might be better placed somewhere at front of the
		// program, as we now still have a game on the background and
		// need to go through the game-menu or supply a map file
		UpdateDisplay();

		//
		// If double-buffered mode, we will display the contains of
		// VideoMemory. If direct mode this does nothing. In X11 it does
		// XFlush
		//
		RealizeVideoMemory();
	}
#ifdef REALVIDEO
	if (FastForwardCycle == GameCycle) {
		VideoSyncSpeed = RealVideoSyncSpeed;
	}
#endif
}
示例#3
0
/* main loop tasks */
void UpdateAnimations (int time)
{
	int c;
	TLN_Sequence sequence;
	TLN_SequenceFrame* frames;
	struct Strip* strips;
	
	for (c=0; c<engine->numanimations; c++)
	{
		Animation* animation = &engine->animations[c];
		if (animation->enabled==false)
			continue;

		sequence = animation->sequence;
		if (animation->type == TYPE_PALETTE)
		{
			int i;
			strips = (struct Strip*)&sequence->data;
			for (i=0; i<sequence->count; i++)
			{
				struct Strip* strip = &strips[i];
				/* next frame */
				if (time >= strip->timer)
				{
					strip->timer = time + strip->delay;
					strip->pos = (strip->pos + 1) % strip->count;
					strip->t0 = time;
					if (!animation->blend)
						ColorCycle (animation->srcpalette, animation->palette, strip);
				}

				/* interpolate */
				if (animation->blend)
					ColorCycleBlend (animation->srcpalette, animation->palette, strip, time);
			}
			continue;
		}

		if (time < animation->timer)
			continue;

		frames = (TLN_SequenceFrame*)&sequence->data;
		animation->timer = time + frames[animation->pos].delay;
		switch (animation->type)
		{
		case TYPE_TILEMAP:
			ReplaceTiles (engine->layers[animation->idx].tilemap, 
				frames[animation->pos].index, 
				frames[animation->pos + 1].index % sequence->count);
			break;

		case TYPE_SPRITE:
			TLN_SetSpritePicture (animation->idx, frames[animation->pos].index);
			break;

		case TYPE_TILESET:
			TLN_CopyTile (engine->layers[animation->idx].tileset, frames[animation->pos].index, sequence->target);
			break;
		}

		/* next frame */
		animation->pos++;
		if (animation->pos == sequence->count)
		{
			if (animation->loop > 1)
			{
				animation->loop--;
				animation->pos = 0;
			}
			else if (animation->loop == 1)
				animation->enabled = false;
			else if (animation->loop == 0)
				animation->pos = 0;
		}
	}
}