summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c199
1 files changed, 46 insertions, 153 deletions
diff --git a/src/main.c b/src/main.c
index 71e465d..6d521be 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,113 +6,54 @@
#include "viewport.h"
#include "area.h"
+#define DEMO() \
+ do { \
+ vp->x = x * map->tilewidth + map->tilewidth / 2 - vp->w / 2; \
+ vp->y = y * map->tileheight + map->tileheight / 2 - vp->h / 2; \
+ render_area_to_viewport(a, vp); \
+ SDL_Flip(vp->screen); \
+ SDL_Delay(100); \
+ } while (0)
+
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;
+ int x, y;
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("screen: bpp: %u, masks: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x",
+ vp->screen->format->BitsPerPixel,
+ vp->screen->format->Rmask, vp->screen->format->Gmask,
+ vp->screen->format->Bmask, vp->screen->format->Amask);
+ img = img_png_get("../forest-6-layer-test_ground.png");
+ 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);
+ img = img_png_get("data/tilesets/mountain_landscape_19-16.png");
+ 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);
+ img = img_png_get("data/tilesets/mountain_landscape_19-16-8bit.png");
+ 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);
debug("Map dimensions: %dx%d", map->width, map->height);
for (ts = map->tilesets_head; ts != NULL; ts = ts->next) {
@@ -129,68 +70,20 @@ main(void)
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);
+ /* Demo */
+ x = 19;
+ y = 38;
+ for (; y > 34; y -= 1) DEMO(); /* Up */
+ for (; x < 23; x += 1) DEMO(); /* Right */
+ for (; y > 16; y -= 1) DEMO(); /* Up */
+ for (; x > 15; x -= 1) DEMO(); /* Left */
+ for (; y < 25; y += 1) DEMO(); /* Down */
+ for (; x > 4; x -= 1) DEMO(); /* Left */
+ for (; y > 18; y -= 1) DEMO(); /* Up */
+ for (; x < 9; x += 1) DEMO(); /* Right */
+ for (; y > 5; y -= 1) DEMO(); /* Up */
+ for (; x < 15; x += 1) DEMO(); /* Right */
+ for (; y > 1; y -= 1) DEMO(); /* Up */
quit(0);