/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    map3.c
    special blits (rotated, flipped, ..)
*/

#include <tscope.h>

map *map1, *map2;

void makemaps()
{
    // allocate memory
    map1 = ts_makebmp(50, 50);
    map2 = ts_makebmp(50, 50);

    // map1: red circle + small green circle
    ts_tobmp(map1);
    ts_clrbmp(map1, TRANS);
    ts_fill(TRUE);
    ts_fgcolor(RED);
    ts_circle(0, 0, map1->w - 1);
    ts_fgcolor(GREEN);
    ts_circle(0, 0, 24);

    // map2: a big '5'
    ts_tobmp(map2);
    ts_clrbmp(map2, TRANS);
    ts_fgcolor(YELLOW);
    ts_font(COURIER, 72, BOLD);
    ts_printf_centre(0, 0, "5");

    // set screen as drawing target
    ts_toscr();
}

void killmaps()
{
    // free memory
    ts_killbmp(map1);
    ts_killbmp(map2);
}

int main()
{
    // open Tscope
    ts_scrsize(SIZE1);
    ts_doublebuff(1);
    ts_init();

    // draw bitmaps
    makemaps();

    ts_font(COURIER, 20, BOLD);
    ts_fgcolor(WHITE);

    // example 1: regular blit
    ts_printf_centre(0, YMAX / 2, "regular blit");
    ts_blit(map1, 0, 0);
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // example 2: partial blit
    ts_printf_centre(0, YMAX / 2, "partial blit");
    ts_partblit(map1, -30, -30, 30, 30, 0, 0);
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // example 3: stretching/shrinking
    ts_printf_centre(0, YMAX / 2, "stretchblit");
    ts_stretchblit(map1, 2, 0, 0);
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // example 4: flipped blit
    ts_printf_centre(0, YMAX / 2, "flipped blit");
    ts_flipblit(map2, HFLIP, 0, 0);
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // example 5: rotated blit
    float fi;
    for (fi = -360; fi <= 720; fi += .5) {
        ts_clrbuff();
        ts_tobuff();
        ts_printf_centre(0, YMAX / 2, "rotated blit");
        ts_rotateblit(map2, 0, 0, fi, 0, 0);
        ts_blitbuff();
    }
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    killmaps();
    return 0;
}

END_OF_MAIN();


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information