Changeset 117 for libcaca


Ignore:
Timestamp:
Nov 10, 2003, 3:00:19 AM (20 years ago)
Author:
Sam Hocevar
Message:
  • test/demo.c: + Wrote a little sprite demo.
  • data/: + Added bar_fighter (from ttyvaders) and bar_boss (from shapes.txt).
Location:
libcaca/trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/Makefile.am

    r77 r117  
    44
    55SUBDIRS = libee test src
    6 DIST_SUBDIRS = $(SUBDIRS) autotools debian
     6DIST_SUBDIRS = $(SUBDIRS) autotools data debian
    77
    88EXTRA_DIST = doc/shapes.txt bootstrap
  • libcaca/trunk/configure.ac

    r111 r117  
    4343  src/Makefile
    4444  autotools/Makefile
     45  data/Makefile
    4546  debian/Makefile
    4647])
  • libcaca/trunk/test/demo.c

    r113 r117  
    3636static void demo_triangles(void);
    3737static void demo_outlined_triangles(void);
     38static void demo_sprites(void);
    3839
    3940int clipping = 0;
     41struct ee_sprite *sprite = NULL;
    4042
    4143int main(int argc, char **argv)
     
    4951    }
    5052
     53    /* Initialize data */
     54    sprite = ee_load_sprite("data/bar_boss");
     55
     56    /* Main menu */
    5157    display_menu();
    5258
     
    9298                demo = demo_outlined_triangles;
    9399                break;
     100            case '7':
     101                ee_clear();
     102                demo = demo_sprites;
     103                break;
    94104            }
    95105        }
     
    100110
    101111    /* Clean up */
     112    ee_free_sprite(sprite);
    102113    ee_end();
    103114
     
    134145    ee_goto(4, 11);
    135146    ee_putstr("6: outlined triangles demo");
     147    ee_goto(4, 12);
     148    ee_putstr("7: sprites demo");
    136149
    137150    ee_goto(4, yo - 2);
     
    286299}
    287300
     301static void demo_sprites(void)
     302{
     303    static int i = 0;
     304
     305    int x1, y1, x2, y2, x3, y3;
     306
     307    i++;
     308
     309    x1 = 2;
     310    y1 = 2;
     311
     312    x2 = ee_get_width() - 3;
     313    y2 = ee_get_height() / 2;
     314
     315    x3 = ee_get_width() / 3;
     316    y3 = ee_get_height() - 3;
     317
     318    ee_clear();
     319
     320    /* Draw a sprite behind the triangle */
     321    ee_draw_sprite(ee_get_width() / 2 + cos(0.027*i) * 30,
     322                   ee_get_height() / 2 - sin(0.027*i) * 20, sprite);
     323
     324    /* Draw a background triangle */
     325    ee_color(EE_BLUE);
     326    ee_fill_triangle(x1, y1, x2, y2, x3, y3, '.');
     327    ee_color(EE_CYAN);
     328    ee_draw_thin_line(x1, y1, x3, y3);
     329    ee_draw_thin_line(x2, y2, x1, y1);
     330    ee_draw_thin_line(x3, y3, x2, y2);
     331
     332    /* Draw foreground sprite */
     333    ee_draw_sprite(ee_get_width() / 2 + cos(0.02*i) * 20,
     334                   ee_get_height() / 2 + sin(0.02*i) * 10, sprite);
     335
     336    ee_refresh();
     337}
     338
    288339static void demo_pyramid(void)
    289340{
Note: See TracChangeset for help on using the changeset viewer.