#include #include "init.h" #include "logging.h" #include "resources/image.h" #include "resources/map.h" #include "viewport.h" #include "area.h" int main(void) { struct viewport *vp; SDL_Surface *screen; struct map *map; struct image *img; struct map_tileset *ts; struct map_exit *e; SDL_Rect imgrect, surfacerect; struct area *a; init(); vp = init_viewport(240, 160, 32); screen = vp->screen; map = map_get("data/forest1-8bit.tmx"); a = area_new(map); render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(500); #if 0 vp->x = 208; vp->y = 544; render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(125); for (; vp->y >= 464; vp->y -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(50); } for (; vp->x <= 256; vp->x += 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(50); } for (; vp->y >= 192; vp->y -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(50); } for (; vp->x >= 160; vp->x -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(50); } for (; vp->y <= 288; vp->y += 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(50); } #endif vp->x = 208; vp->y = 544; render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(125); for (; vp->y >= 464; vp->y -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->x <= 256; vp->x += 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->y >= 192; vp->y -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->x >= 160; vp->x -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->y <= 320; vp->y += 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->x >= -16; vp->x -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->y >= 192; vp->y -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->x <= 64; vp->x += 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } for (; vp->y >= 0; vp->y -= 4) { render_area_to_viewport(a, vp); SDL_Flip(screen); SDL_Delay(25); } quit(0); debug("Map dimensions: %dx%d", map->width, map->height); for (ts = map->tilesets_head; ts != NULL; ts = ts->next) { debug("Tileset name: %s", ts->tileset->name); debug("Tileset firstgid: %d", ts->firstgid); } for (e = map->map_exits_head; e != NULL; e = e->next) { debug("Exit target (size %dx%d) at (%d,%d) " "to map %s (size %dx%d) at (%d,%d)", e->width, e->height, e->x, e->y, e->target_map_name, e->target_map->width, e->target_map->height, e->target_x_coord, e->target_y_coord); } img = img_png_get("../forest-6-layer-test_ground.png"); debug("screen: bpp: %u, masks: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x", screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); debug("image: bpp: %u, masks: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x", img->image->format->BitsPerPixel, img->image->format->Rmask, img->image->format->Gmask, img->image->format->Bmask, img->image->format->Amask); img_png_free(img); quit(0); return 0; img = img_png_get("../forest-6-layer-test_ground.png"); img = img_png_get("../forest-6-layer-test_ground.png"); img = img_png_get("../forest-6-layer-test_ground.png"); img = img_png_get("../forest-6-layer-test_ground.png"); img_png_free(img); img_png_free(img); img_png_free(img); img = img_png_get("../forest-6-layer-test_ground.png"); imgrect.w = 240; imgrect.h = 160; surfacerect.x = 0; surfacerect.y = 0; surfacerect.w = 240; surfacerect.h = 160; imgrect.x = 208; imgrect.y = 480; SDL_BlitSurface(img->image, &imgrect, screen, &surfacerect); SDL_Flip(screen); SDL_Delay(500); imgrect.x = 208; imgrect.y = 464; SDL_BlitSurface(img->image, &imgrect, screen, &surfacerect); SDL_Flip(screen); SDL_Delay(500); imgrect.x = 224; imgrect.y = 464; SDL_BlitSurface(img->image, &imgrect, screen, &surfacerect); SDL_Flip(screen); SDL_Delay(500); imgrect.x = 240; imgrect.y = 464; SDL_BlitSurface(img->image, &imgrect, screen, &surfacerect); SDL_Flip(screen); SDL_Delay(500); imgrect.x = 256; imgrect.y = 464; SDL_BlitSurface(img->image, &imgrect, screen, &surfacerect); SDL_Flip(screen); SDL_Delay(500); imgrect.x = 256; imgrect.y = 448; SDL_BlitSurface(img->image, &imgrect, screen, &surfacerect); SDL_Flip(screen); SDL_Delay(500); quit(0); /* Control doesn't actually reach here. */ return 0; }