From 3ac5e2ea7a4b7e5c2090003155925c9cd49366a6 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 10 Nov 2003 02:00:19 +0000 Subject: [PATCH] * test/demo.c: + Wrote a little sprite demo. * data/: + Added bar_fighter (from ttyvaders) and bar_boss (from shapes.txt). --- Makefile.am | 2 +- configure.ac | 1 + data/bar_boss | 27 +++++++++++++++++++++++++ data/bar_fighter | 14 +++++++++++++ test/demo.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 data/bar_boss create mode 100644 data/bar_fighter diff --git a/Makefile.am b/Makefile.am index fd4c83e..566a35b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ ############################################################################### SUBDIRS = libee test src -DIST_SUBDIRS = $(SUBDIRS) autotools debian +DIST_SUBDIRS = $(SUBDIRS) autotools data debian EXTRA_DIST = doc/shapes.txt bootstrap AUTOMAKE_OPTIONS = foreign dist-bzip2 diff --git a/configure.ac b/configure.ac index 238b9b2..0aa076e 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,7 @@ AC_OUTPUT([ test/Makefile src/Makefile autotools/Makefile + data/Makefile debian/Makefile ]) diff --git a/data/bar_boss b/data/bar_boss new file mode 100644 index 0000000..a8f4adb --- /dev/null +++ b/data/bar_boss @@ -0,0 +1,27 @@ +36 13 18 6 + _,--._ + ,' `. + |\ / ,-. ,-. \ /| + )o),/ ( ( o )( o ) ) \.(o( + /o/// /| `-' `-' |\ \\\o\ + / / |\ \( . , )/ /| \ \ + | | \o`-/ `\/' \-'o/ | | + \ \ `,' `.' / / +\. \ `-' ,'| /\ |`. `-' / ,/ + \`. `.__,' / / \ \ `.__,' ,'/ + \o\ ,' ,' `. `. /o/ + \o`---' ,' `. `---'o/ + `.____,' `.____,' + kkkkkk + kkkkkkkkkk + kk kkhhhkkhhhkk kk + khkkk kkhhehhhhehhkk kkkhk + khkkk kkkkhhhkkhhhkkkk kkkhk + kkk kk kkkkkhkkkkhkkkkk kk kkk + kkk khkkkkkkkhhhhkkkkkkkhk kkk + kkk kkkkkkkkkkkkkkkkkkkk kkk +kk kkkkkkkkkkkkkkkkkkkkk kkkkk kk + kkk kkkkkk kkkkk kkkkk kkkkkk kkk + khk kkkkkk kkkkkk khk + khkkkkkkkkk kkkkkkkkkhk + kkkkkkkk kkkkkkkk diff --git a/data/bar_fighter b/data/bar_fighter new file mode 100644 index 0000000..6568586 --- /dev/null +++ b/data/bar_fighter @@ -0,0 +1,14 @@ +5 3 2 1 +,---. +\O o/ +^^^^^ +kkkkk +keeek +kkkkk +5 3 2 1 +,---. +\o O/ +^^^^^ +kkkkk +keeek +kkkkk diff --git a/test/demo.c b/test/demo.c index 31546dd..768a393 100644 --- a/test/demo.c +++ b/test/demo.c @@ -35,8 +35,10 @@ static void demo_thin_lines(void); static void demo_circles(void); static void demo_triangles(void); static void demo_outlined_triangles(void); +static void demo_sprites(void); int clipping = 0; +struct ee_sprite *sprite = NULL; int main(int argc, char **argv) { @@ -48,6 +50,10 @@ int main(int argc, char **argv) return 1; } + /* Initialize data */ + sprite = ee_load_sprite("data/bar_boss"); + + /* Main menu */ display_menu(); /* Go ! */ @@ -91,6 +97,10 @@ int main(int argc, char **argv) ee_clear(); demo = demo_outlined_triangles; break; + case '7': + ee_clear(); + demo = demo_sprites; + break; } } @@ -99,6 +109,7 @@ int main(int argc, char **argv) } /* Clean up */ + ee_free_sprite(sprite); ee_end(); return 0; @@ -133,6 +144,8 @@ static void display_menu(void) ee_putstr("5: triangles demo"); ee_goto(4, 11); ee_putstr("6: outlined triangles demo"); + ee_goto(4, 12); + ee_putstr("7: sprites demo"); ee_goto(4, yo - 2); ee_putstr("q: quit"); @@ -285,6 +298,44 @@ static void demo_outlined_triangles(void) ee_refresh(); } +static void demo_sprites(void) +{ + static int i = 0; + + int x1, y1, x2, y2, x3, y3; + + i++; + + x1 = 2; + y1 = 2; + + x2 = ee_get_width() - 3; + y2 = ee_get_height() / 2; + + x3 = ee_get_width() / 3; + y3 = ee_get_height() - 3; + + ee_clear(); + + /* Draw a sprite behind the triangle */ + ee_draw_sprite(ee_get_width() / 2 + cos(0.027*i) * 30, + ee_get_height() / 2 - sin(0.027*i) * 20, sprite); + + /* Draw a background triangle */ + ee_color(EE_BLUE); + ee_fill_triangle(x1, y1, x2, y2, x3, y3, '.'); + ee_color(EE_CYAN); + ee_draw_thin_line(x1, y1, x3, y3); + ee_draw_thin_line(x2, y2, x1, y1); + ee_draw_thin_line(x3, y3, x2, y2); + + /* Draw foreground sprite */ + ee_draw_sprite(ee_get_width() / 2 + cos(0.02*i) * 20, + ee_get_height() / 2 + sin(0.02*i) * 10, sprite); + + ee_refresh(); +} + static void demo_pyramid(void) { static int i = 0;