/* 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; }
/* entry point */ int main (int argc, char* argv[]) { int y; /* setup engine */ TLN_Init (WIDTH, HEIGHT, MAX_LAYER,0,0); TLN_SetBGColor (0,128,238); TLN_CreateWindow ("overlay.bmp", false); /* load layer (tileset + tilemap) */ LoadMap (MAP_SKY, "NamcoHorizon"); LoadMap (MAP_TREES, "NamcoTrees"); LoadMap (MAP_ROAD1, "NamcoRoad1"); LoadMap (MAP_ROAD2, "NamcoRoad2"); TLN_SetRasterCallback (raster_callback); /* init road */ s0 = 0.03f; s1 = 1.0f; sf = (int)(s1/s0); for (y=0; y<ROAD_H; y++) { road[y].s = lerp (y, 0,ROAD_H, s0,s1); //road[y].s = ((y*49)/143) + 1; road[y].z = (int)500/road[y].s; //road[y].z = 500*50/road[y].s; road[y].t = lerp(road[y].z, 1,sf, 384,0)/50; curve[ROAD_H - y - 1] = (y*(y+1)/2)/64; } /* main loop */ while (TLN_ProcessWindow ()) { /* render to the window */ TLN_DrawFrame (frame); frame++; } /* release resources */ FreeMap (MAP_SKY); FreeMap (MAP_TREES); FreeMap (MAP_ROAD1); FreeMap (MAP_ROAD2); TLN_DeleteWindow (); TLN_Deinit (); return 0; }
JNIEXPORT void JNICALL Java_Tilengine_DrawFrame (JNIEnv* env, jobject thisobj, jint time) { TLN_DrawFrame (time); }
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; }