Пример #1
0
/* entry point */
int main (int argc, char* argv[])
{
	TLN_Tilemap tilemap;
	int frame = 0;

	/* setup engine */
	TLN_Init (WIDTH, HEIGHT, 1,0,0);

	/* load layer */
	TLN_SetLoadPath ("assets/sonic");
	tilemap = TLN_LoadTilemap ("Sonic_md_fg1.tmx", NULL);
	
	/* setup the layer */
	TLN_SetLayer (0, NULL, tilemap);
	TLN_SetBGColor (32,32,128);

	/* main loop */
	TLN_CreateWindow (NULL, 0);
	while (TLN_ProcessWindow ())
	{
		/* scroll the layer, one pixel per frame */
		TLN_SetLayerPosition (0, frame, 0);
		
		/* render to the window */
		TLN_DrawFrame (frame);
		frame++;
	}

	/* release resources */
	TLN_DeleteTilemap (tilemap);
	TLN_Deinit ();

	return 0;
}
Пример #2
0
JNIEXPORT void JNICALL Java_Tilengine_SetLoadPath (JNIEnv* env, jobject thisobj, jstring path)
{
	const char* chars = NULL;
	
	chars = (*env)->GetStringUTFChars (env, path, NULL);
	TLN_SetLoadPath (chars);
	(*env)->ReleaseStringUTFChars (env, path, chars);
}
Пример #3
0
int main (int argc, char* argv[])
{
	int c;
	TLN_Tilemap tilemap = NULL;
	TLN_Spriteset spriteset = NULL;

	/* basic setup */
	TLN_Init(WIDTH, HEIGHT, 1, 1, 1);
	TLN_SetBGColor (0,128,238);
	TLN_SetRenderTarget(framebuffer, WIDTH * 4);
	TLN_SetLoadPath("../assets/sonic");
	TLN_SetLogLevel(TLN_LOG_VERBOSE);
	printf("Tilengine version %06X\n", TLN_GetVersion());
	
	/* test layer */
	tilemap = TLN_LoadTilemap("dummy", NULL);
	for (c = 0; c < 2; c++)
	{
		TLN_SetLayer(0, NULL, tilemap);
		if (tilemap == NULL)
			tilemap = TLN_LoadTilemap("Sonic_md_bg1.tmx", NULL);
	}
	TLN_SetLayerPosition(1, 0, 0);
	TLN_SetLayerPosition(0, 0, 0);

	/* test sprite */
	spriteset = TLN_LoadSpriteset("dummy");
	for (c = 0; c < 2; c++)
	{
		TLN_ConfigSprite(0, spriteset, 0);
		if (spriteset == NULL)
			spriteset = TLN_LoadSpriteset("smw_sprite");
	}
	TLN_SetSpritePosition(1, 10, 10);
	TLN_SetSpritePosition(0, 10, 10);

	TLN_UpdateFrame(0);

	TLN_DeleteSpriteset(spriteset);
	TLN_DeleteTilemap(tilemap);
	TLN_Deinit ();
	return 0;
}
Пример #4
0
int main (int argc, char* argv[])
{
	TLN_Init (640,480,0,0,1);
	TLN_CreateWindow (NULL, CWF_VSYNC);
	TLN_EnableBlur (true);
	TLN_SetLoadPath ("cycles");	

	palette = TLN_CreatePalette (256);
	palette_int = TLN_CreatePalette (256);
	SetScene (pos);

	while (TLN_ProcessWindow ())
	{
		if (TLN_GetInput (INPUT_LEFT))
		{
			if (dec == false)
			{
				dec = true;
				pos = (pos - 1 + MAX_SCENE) % MAX_SCENE;
				SetScene (pos);
			}
		}
		else
			dec = false;

		if (TLN_GetInput (INPUT_RIGHT))
		{
			if (inc == false)
			{
				inc = true;
				pos = (pos + 1) % MAX_SCENE;
				SetScene (pos);
			}
		}
		else
			inc = false;

		/* update palette */
		if (!(frame & 0x01))
		{
			TLN_Palette pal1, pal2;
			int t = frame % MAX_TIME;
			int idx1 = FindTimeIndex (t);
			int idx2 = (idx1 + 1) % maxpal;
			int t1 = palettes[idx1].time;
			int t2 = palettes[idx2].time;

			if (t1 > t2)
			{
				t2 += MAX_TIME;
				if (t < t1)
					t += MAX_TIME;
			}

			t -= t1;
			t2 -= t1;

			pal1 = palettes[idx1].palette;
			pal2 = palettes[idx2].palette;
			TLN_MixPalettes (pal1, pal2, palette_int, t*255/t2); /* rescale t2 to 255 */
			SetPalette (idx1);
		}

		TLN_DrawFrame (frame);
		
		frame++;
	}

	TLN_DeleteBitmap (background);
	TLN_DeletePalette (palette);
	TLN_DeletePalette (palette_int);
	TLN_DeleteWindow ();
	TLN_Deinit ();
	return 0;
}