Changeset 159
- Timestamp:
- Nov 12, 2003, 10:18:50 PM (19 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/Makefile.am
r117 r159 6 6 DIST_SUBDIRS = $(SUBDIRS) autotools data debian 7 7 8 EXTRA_DIST = doc/shapes.txt bootstrap8 EXTRA_DIST = BUGS doc/shapes.txt bootstrap 9 9 AUTOMAKE_OPTIONS = foreign dist-bzip2 10 10 -
libcaca/trunk/README
-
Property
svn:keywords
set to
Id
r157 r159 1 $Id$ 1 2 2 3 Building ttyvaders 3 ==================4 4 5 Run configure then make. Configure flags are:5 o Run configure then make. Useful configure flags are: 6 6 7 --enable-slang: use the SLang library (default)8 --enable-ncurses: use the ncurses library9 --enable-conio: use MS-DOS conio.h7 --enable-slang: use the SLang library (default) 8 --enable-ncurses: use the ncurses library 9 --enable-conio: use MS-DOS conio.h 10 10 11 Cross-compilation example: 12 ./configure --enable-conio --host=i386-pc-msdosdjgpp 11 o Cross-compilation example: 12 13 ./configure --enable-conio --host=i386-pc-msdosdjgpp 13 14 14 15 15 16 History of textmode games 16 =========================17 17 18 http://www.textmodegames.com/18 o http://www.textmodegames.com/ 19 19 20 20 21 21 Other terminal-based games 22 ==========================23 22 24 * moon-buggy: http://www.mathematik.uni-kl.de/~wwwstoch/voss/comp/moon-buggy.html25 extremely simple, extremely addictive23 o moon-buggy: extremely simple, extremely addictive 24 http://www.mathematik.uni-kl.de/~wwwstoch/voss/comp/moon-buggy.html 26 25 27 *0verkill: http://artax.karlin.mff.cuni.cz/~brain/0verkill/26 o 0verkill: http://artax.karlin.mff.cuni.cz/~brain/0verkill/ 28 27 29 *nInvaders: http://dettus.dyndns.org/ninvaders/30 real space invaders clone28 o nInvaders: http://dettus.dyndns.org/ninvaders/ 29 real space invaders clone 31 30 32 *Stardork: http://www.seekrut.com/rk/stardork.html33 more strategy than arcade31 o Stardork: http://www.seekrut.com/rk/stardork.html 32 more strategy than arcade 34 33 35 *Nethack: http://www.nethack.org/34 o Nethack: http://www.nethack.org/ 36 35 37 *Tetrinet: http://www.secret.com.au/games/tetrinet/36 o Tetrinet: http://www.secret.com.au/games/tetrinet/ 38 37 39 *MyMan: http://geocities.com/bsittler/40 pacman clone38 o MyMan: http://geocities.com/bsittler/ 39 pacman clone 41 40 42 *Tornado: http://home.kcore.de/~kiza/linux/tornado/41 o Tornado: http://home.kcore.de/~kiza/linux/tornado/ 43 42 44 *David's Perl games: http://davidsperlgames.sourceforge.net/43 o David's Perl games: http://davidsperlgames.sourceforge.net/ 45 44 46 *ascii-invaders: http://www.ip9.org/munro/invaders/index.html45 o ascii-invaders: http://www.ip9.org/munro/invaders/index.html 47 46 -
Property
svn:keywords
set to
-
libcaca/trunk/TODO
-
Property
svn:keywords
set to
Id
r69 r159 1 Things to do 1 $Id$ 2 2 3 * let the ship pick up bonuses 3 TODO for libee 4 4 5 DONE 23 Dec 2002: handle life5 o Sprite library 6 6 7 * alien swarms, programmed behaviour7 o Clip graphics 8 8 9 * sprite library9 o Fix the thin ellipse rendering 10 10 11 DONE 23 Dec 2002: mega ball 11 o Write a Linux console output for the drawing library 12 See also BUGS as to why it's very slow in console mode 12 13 13 * spiral weapon (vertical sine)14 o DONE 12 Nov 2003: Port to conio.h 14 15 15 DONE 23 Dec 2002: fragmentation bomb (merge with mega-ball?)16 16 17 * stick aliens to tunnel 17 TODO for ttyvaders 18 18 19 * change tunnel colour19 o Let the ship pick up bonuses 20 20 21 DONE Dec 23 2002: fill holes in the tunnel when |step| > 221 o Alien swarms, programmed behaviour 22 22 23 DONE Dec 18 2002: draw a 3rd alien type23 o Spiral weapon (vertical sine) 24 24 25 * draw bosses25 o Stick aliens to tunnel 26 26 27 * port to conio.h27 o Change tunnel colour 28 28 29 * clip graphics29 o Draw bosses 30 30 31 * promote precision for all coordinates except screen31 o Promote precision for all coordinates except screen 32 32 33 DONE Dec 19 2002: tunnel sometimes doesn't get drawn on the left33 o Animate the ship 34 34 35 * write a generic drawing library with automatic clipping 35 o The nuke should break the tunnel 36 Or at least a bit 36 37 37 * write a linux console output for the drawing library38 o The laser stays alive when the ship explodes 38 39 39 * animate the ship 40 o DONE 12 Nov 2003: Write a generic drawing library with automatic clipping 41 o DONE 23 Dec 2002: Handle life 42 o DONE 23 Dec 2002: Mega ball 43 o DONE 23 Dec 2002: Fragmentation bomb (merge with mega-ball?) 44 o DONE 23 Dec 2002: Fill holes in the tunnel when |step| > 2 45 o DONE 19 Dec 2002: Tunnel sometimes doesn't get drawn on the left 46 o DONE 18 Dec 2002: Draw a 3rd alien type 40 47 41 * the nuke should break the tunnel42 43 * the laser stays alive when the ship explodes44 -
Property
svn:keywords
set to
-
libcaca/trunk/libee/Makefile.am
r151 r159 7 7 ee.c \ 8 8 ee.h \ 9 ee_internals.h \ 9 10 graphics.c \ 10 11 io.c \ -
libcaca/trunk/libee/box.c
r153 r159 23 23 #include "config.h" 24 24 25 #ifdef USE_SLANG26 # include <slang.h>27 #elif USE_NCURSES28 # include <curses.h>29 #endif30 31 25 #include <stdlib.h> 32 26 33 27 #include "ee.h" 28 #include "ee_internals.h" 34 29 35 30 void ee_draw_box(int x1, int y1, int x2, int y2, char c) -
libcaca/trunk/libee/conic.c
r155 r159 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG26 # include <slang.h>27 #elif USE_NCURSES28 # include <curses.h>29 #endif30 24 31 25 #ifdef HAVE_INTTYPES_H … … 38 32 39 33 #include "ee.h" 34 #include "ee_internals.h" 40 35 41 36 static void ellipsepoints(int, int, int, int, char); -
libcaca/trunk/libee/ee.c
r157 r159 44 44 45 45 #include "ee.h" 46 #include "ee_internals.h" 47 48 /* Global array with color names */ 49 char *ee_color_names[16] = 50 { 51 "black", 52 "blue", 53 "green", 54 "cyan", 55 "red", 56 "magenta", 57 "brown", 58 "lightgray", 59 "darkgray", 60 "lightblue", 61 "lightgreen", 62 "lightcyan", 63 "lightred", 64 "lightmagenta", 65 "yellow", 66 "white", 67 }; 46 68 47 69 static int _ee_delay; 70 71 #if defined(USE_NCURSES) 72 int _ee_attr[16]; 73 #endif 74 48 75 #if defined(USE_CONIO) 49 76 static struct text_info ti; 50 char *_ screen_buffer;77 char *_ee_screen; 51 78 #endif 52 79 … … 54 81 { 55 82 #if defined(USE_SLANG) 56 static char * colors[] = { "black", "green", "yellow", "white", 57 "red", "gray", "lightgray", "blue", "cyan", "magenta", NULL }; 83 static char *slang_colors[16] = 84 { 85 "black", 86 "blue", 87 "green", 88 "cyan", 89 "red", 90 "magenta", 91 "brown", 92 "lightgray", 93 "gray", 94 "brightblue", 95 "brightgreen", 96 "brightcyan", 97 "brightred", 98 "brightmagenta", 99 "yellow", 100 "white", 101 }; 102 58 103 int i; 59 104 … … 82 127 SLsmg_refresh(); 83 128 84 for(i = 0; colors[i]; i++) 85 { 86 SLtt_set_color(i + 1, NULL, colors[i], "black"); 87 } 88 89 #elif defined(USE_NCURSES) 90 /* Initialize ncurses library */ 129 for(i = 0; i < 16; i++) 130 SLtt_set_color(i + 1, NULL, slang_colors[i], "black"); 131 132 #elif defined(USE_NCURSES) 133 int i; 134 91 135 initscr(); 92 136 keypad(stdscr, TRUE); … … 99 143 start_color(); 100 144 101 init_pair(EE_BLACK, COLOR_BLACK, COLOR_BLACK); 102 init_pair(EE_GREEN, COLOR_GREEN, COLOR_BLACK); 103 init_pair(EE_YELLOW, COLOR_YELLOW, COLOR_BLACK); 104 init_pair(EE_WHITE, COLOR_WHITE, COLOR_BLACK); 105 init_pair(EE_RED, COLOR_RED, COLOR_BLACK); 106 init_pair(EE_GRAY, COLOR_WHITE, COLOR_BLACK); // XXX 107 init_pair(EE_LIGHTGRAY, COLOR_WHITE, COLOR_BLACK); // XXX 108 init_pair(EE_BLUE, COLOR_BLUE, COLOR_BLACK); 109 init_pair(EE_CYAN, COLOR_CYAN, COLOR_BLACK); 110 init_pair(EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); 145 init_pair(1 + EE_BLACK, COLOR_BLACK, COLOR_BLACK); 146 init_pair(1 + EE_BLUE, COLOR_BLUE, COLOR_BLACK); 147 init_pair(1 + EE_GREEN, COLOR_GREEN, COLOR_BLACK); 148 init_pair(1 + EE_CYAN, COLOR_CYAN, COLOR_BLACK); 149 init_pair(1 + EE_RED, COLOR_RED, COLOR_BLACK); 150 init_pair(1 + EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); 151 init_pair(1 + EE_BROWN, COLOR_YELLOW, COLOR_BLACK); 152 init_pair(1 + EE_LIGHTGRAY, COLOR_WHITE, COLOR_BLACK); 153 init_pair(1 + EE_DARKGRAY, COLOR_BLACK, COLOR_BLACK); 154 init_pair(1 + EE_LIGHTBLUE, COLOR_BLUE, COLOR_BLACK); 155 init_pair(1 + EE_LIGHTGREEN, COLOR_GREEN, COLOR_BLACK); 156 init_pair(1 + EE_LIGHTCYAN, COLOR_CYAN, COLOR_BLACK); 157 init_pair(1 + EE_LIGHTRED, COLOR_RED, COLOR_BLACK); 158 init_pair(1 + EE_LIGHTMAGENTA, COLOR_MAGENTA, COLOR_BLACK); 159 init_pair(1 + EE_YELLOW, COLOR_YELLOW, COLOR_BLACK); 160 init_pair(1 + EE_WHITE, COLOR_WHITE, COLOR_BLACK); 161 162 for(i = 0; i < 8; i++) 163 { 164 _ee_attr[i] = COLOR_PAIR(1 + i); 165 _ee_attr[i + 8] = A_BOLD | COLOR_PAIR(1 + i); 166 } 111 167 112 168 #elif defined(USE_CONIO) … … 115 171 clrscr(); 116 172 gettextinfo(&ti); 117 _screen_buffer = malloc(ee_get_width() * ee_get_height() * 2); 118 ScreenRetrieve(_screen_buffer); 173 _ee_screen = malloc(2 * ti.screenwidth * ti.screenheight); 174 # if defined(SCREENUPDATE_IN_PC_H) 175 ScreenRetrieve(_ee_screen); 176 # else 177 /* FIXME */ 178 # endif 119 179 120 180 #endif … … 188 248 refresh(); 189 249 #elif defined(USE_CONIO) 190 ScreenUpdate(_screen_buffer); 250 # if defined(SCREENUPDATE_IN_PC_H) 251 ScreenUpdate(_ee_screen); 252 # else 253 /* FIXME */ 254 # endif 191 255 #endif 192 256 … … 215 279 endwin(); 216 280 #elif defined(USE_CONIO) 217 ScreenUpdate(_screen_buffer);218 281 _wscroll = 1; 219 282 textcolor((enum COLORS)WHITE); -
libcaca/trunk/libee/ee.h
r153 r159 32 32 * Colors 33 33 */ 34 #define EE_BLACK 1 35 #define EE_GREEN 2 36 #define EE_YELLOW 3 37 #define EE_WHITE 4 38 #define EE_RED 5 39 #define EE_GRAY 6 40 #define EE_LIGHTGRAY 7 41 #define EE_BLUE 8 42 #define EE_CYAN 9 43 #define EE_MAGENTA 10 34 enum ee_colors 35 { 36 EE_BLACK = 0, 37 EE_BLUE = 1, 38 EE_GREEN = 2, 39 EE_CYAN = 3, 40 EE_RED = 4, 41 EE_MAGENTA = 5, 42 EE_BROWN = 6, 43 EE_LIGHTGRAY = 7, 44 EE_DARKGRAY = 8, 45 EE_LIGHTBLUE = 9, 46 EE_LIGHTGREEN = 10, 47 EE_LIGHTCYAN = 11, 48 EE_LIGHTRED = 12, 49 EE_LIGHTMAGENTA = 13, 50 EE_YELLOW = 14, 51 EE_WHITE = 15 52 }; 53 54 extern char *ee_color_names[16]; 44 55 45 56 /* -
libcaca/trunk/libee/graphics.c
r157 r159 37 37 38 38 #include "ee.h" 39 #include "ee_internals.h" 39 40 40 41 static int ee_color = 0; 41 #if defined(USE_CONIO)42 static enum COLORS dos_colors[] = {43 0,44 BLACK,45 GREEN,46 YELLOW,47 WHITE,48 RED,49 DARKGRAY,50 LIGHTGRAY,51 BLUE,52 CYAN,53 MAGENTA54 };55 #endif56 42 57 43 void ee_set_color(int color) 58 44 { 45 if(color < 0 || color > 15) 46 return; 47 59 48 ee_color = color; 60 49 #if defined(USE_SLANG) 61 SLsmg_set_color(color );50 SLsmg_set_color(color + 1); 62 51 #elif defined(USE_NCURSES) 63 attrset( COLOR_PAIR(color));52 attrset(_ee_attr[color]); 64 53 #elif defined(USE_CONIO) 65 if(color >= 1 && color <= 10) 66 textcolor(dos_colors[color]); 54 textcolor(color); 67 55 #endif 68 56 } … … 73 61 } 74 62 75 extern char *_screen_buffer;76 77 63 void ee_putchar(int x, int y, char c) 78 64 { 65 if(x < 0 || x >= ee_get_width() || y < 0 || y >= ee_get_height()) 66 return; 67 79 68 #if defined(USE_SLANG) 80 SLsmg_gotorc(y, x);69 SLsmg_gotorc(y, x); 81 70 SLsmg_write_char(c); 82 71 #elif defined(USE_NCURSES) 83 move(y, x);72 move(y, x); 84 73 addch(c); 85 74 #elif defined(USE_CONIO) 86 if(x<0 || x>=ee_get_width() || y<0 || y>=ee_get_height()) 87 return; 88 _screen_buffer[2 * (x + y * ee_get_width())] = c; 89 _screen_buffer[2 * (x + y * ee_get_width()) + 1] = dos_colors[ee_color]; 90 // gotoxy(x+1,y+1); 75 _ee_screen[2 * (x + y * ee_get_width())] = c; 76 _ee_screen[2 * (x + y * ee_get_width()) + 1] = ee_color; 77 // gotoxy(x + 1, y + 1); 91 78 // putch(c); 92 79 #endif … … 95 82 void ee_putstr(int x, int y, char *s) 96 83 { 97 if(y<0 || y>=ee_get_height()) 84 int len; 85 86 if(y < 0 || y >= ee_get_height()) 98 87 return; 88 89 len = strlen(s); 90 91 if(x < 0) 92 { 93 len -= -x; 94 if(len < 0) 95 return; 96 s += -x; 97 x = 0; 98 } 99 99 100 #if defined(USE_SLANG) 100 SLsmg_gotorc(y, x);101 SLsmg_gotorc(y, x); 101 102 SLsmg_write_string(s); 102 103 #elif defined(USE_NCURSES) 103 move(y, x);104 move(y, x); 104 105 addstr(s); 105 106 #elif defined(USE_CONIO) 106 char *buf = _ screen_buffer+ 2 * (x + y * ee_get_width());107 char *buf = _ee_screen + 2 * (x + y * ee_get_width()); 107 108 while(*s) 108 109 { 109 110 *buf++ = *s++; 110 *buf++ = dos_colors[ee_color];111 *buf++ = ee_color; 111 112 } 112 // gotoxy(x +1,y+1);113 // gotoxy(x + 1, y + 1); 113 114 // cputs(s); 114 115 #endif … … 118 119 { 119 120 /* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ 120 int x = ee_get_width(), y = ee_get_height(); 121 int x = ee_get_width(); 122 int y = ee_get_height(); 121 123 char *empty_line = malloc((x + 1) * sizeof(char)); 122 124 -
libcaca/trunk/libee/io.c
r155 r159 23 23 #include "config.h" 24 24 25 #if def USE_SLANG25 #if defined(USE_SLANG) 26 26 # include <slang.h> 27 #elif USE_NCURSES27 #elif defined(USE_NCURSES) 28 28 # include <curses.h> 29 #elif USE_CONIO29 #elif defined(USE_CONIO) 30 30 # include <conio.h> 31 31 #else … … 34 34 35 35 #include "ee.h" 36 #include "ee_internals.h" 36 37 37 38 char ee_get_key(void) 38 39 { 39 #ifdef USE_SLANG 40 if(SLang_input_pending(0)) 41 { 42 return SLang_getkey(); 43 } 44 #elif USE_NCURSES 40 #if defined(USE_SLANG) 41 return SLang_input_pending(0) ? SLang_getkey() : 0; 42 43 #elif defined(USE_NCURSES) 45 44 char key = getch(); 45 return key != ERR ? key : 0; 46 46 47 if(key != ERR) 48 { 49 return key; 50 } 51 #elif USE_CONIO 47 #elif defined(USE_CONIO) 52 48 return _conio_kbhit() ? getch() : 0; 53 49 54 50 #endif 55 56 return 0;57 51 } 58 52 -
libcaca/trunk/libee/line.c
r155 r159 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG26 # include <slang.h>27 #elif USE_NCURSES28 # include <curses.h>29 #endif30 24 31 25 #ifdef HAVE_INTTYPES_H … … 38 32 39 33 #include "ee.h" 34 #include "ee_internals.h" 40 35 41 36 struct line -
libcaca/trunk/libee/math.c
r147 r159 23 23 #include "config.h" 24 24 25 #ifdef USE_SLANG26 # include <slang.h>27 #elif USE_NCURSES28 # include <curses.h>29 #endif30 31 25 #include <stdlib.h> 32 26 33 27 #include "ee.h" 28 #include "ee_internals.h" 34 29 35 30 int ee_rand(int min, int max) -
libcaca/trunk/libee/sprite.c
r153 r159 23 23 #include "config.h" 24 24 25 #ifdef USE_SLANG26 # include <slang.h>27 #elif USE_NCURSES28 # include <curses.h>29 #endif30 31 25 #include <stdio.h> 32 26 #include <stdlib.h> … … 34 28 35 29 #include "ee.h" 30 #include "ee_internals.h" 36 31 37 32 struct ee_frame -
libcaca/trunk/libee/triangle.c
r151 r159 23 23 #include "config.h" 24 24 25 #ifdef USE_SLANG26 # include <slang.h>27 #elif USE_NCURSES28 # include <curses.h>29 #endif30 31 25 #include <stdlib.h> 32 26 33 27 #include "ee.h" 28 #include "ee_internals.h" 34 29 35 30 void ee_draw_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) -
libcaca/trunk/src/Makefile.am
r153 r159 30 30 weapons.c \ 31 31 $(NULL) 32 ttyvaders_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) 32 ttyvaders_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm 33 33 -
libcaca/trunk/src/overlay.c
r153 r159 33 33 34 34 /* Draw life jauge */ 35 ee_set_color(EE_ GRAY);35 ee_set_color(EE_DARKGRAY); 36 36 ee_putstr(4, 1, dots30); 37 37 … … 56 56 57 57 /* Draw weapon jauge */ 58 ee_set_color(EE_ GRAY);58 ee_set_color(EE_DARKGRAY); 59 59 ee_putstr(42, 1, dots30 + 10); 60 60 -
libcaca/trunk/src/weapons.c
r153 r159 70 70 break; 71 71 case WEAPON_BOMB: 72 ee_set_color(EE_ GRAY);72 ee_set_color(EE_DARKGRAY); 73 73 ee_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); 74 74 ee_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); -
libcaca/trunk/test/demo.c
r153 r159 25 25 #include <math.h> 26 26 #include <string.h> 27 #include <stdio.h> 27 28 28 29 #include "ee.h" … … 32 33 static void demo_all(void); 33 34 35 static void demo_color(void); 34 36 static void demo_dots(void); 35 37 static void demo_lines(void); … … 77 79 quit = 1; 78 80 break; 81 case 'c': 82 ee_clear(); 83 demo = demo_color; 84 break; 79 85 case '0': 80 86 ee_clear(); … … 144 150 ee_clear(); 145 151 ee_set_color(EE_WHITE); 146 ee_draw_line(xo, yo, 1, yo, '.'); 147 ee_draw_line(1, yo, 1, 1, ':'); 148 ee_draw_line(xo, 1, xo, yo, ':'); 149 ee_draw_line(1, 1, xo, 1, '.'); 152 ee_draw_thin_box(1, 1, xo, yo); 150 153 151 154 ee_putstr((xo - strlen("libee demo")) / 2, 3, "libee demo"); … … 172 175 static int i = 0; 173 176 174 int j, xo, yo, x 1, y1, x2, y2, x3, y3;177 int j, xo, yo, xa, ya, xb, yb, xc, yc; 175 178 176 179 i++; … … 185 188 for(j = 0; j < 16; j++) 186 189 { 187 x 1= xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + M_PI*j/8);188 y 1= yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + M_PI*j/8);189 ee_draw_thin_line(xo, yo, x 1, y1);190 xa = xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + M_PI*j/8); 191 ya = yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + M_PI*j/8); 192 ee_draw_thin_line(xo, yo, xa, ya); 190 193 } 191 194 … … 200 203 yo = 2; 201 204 202 x 1= ee_get_width() / 8 + sin(0.03*i) * 5;203 y 1= ee_get_height() / 2 + cos(0.03*i) * 5;204 205 x 2= ee_get_width() - 10 - cos(0.02*i) * 10;206 y 2= ee_get_height() * 3 / 4 - 5 + sin(0.02*i) * 5;207 208 x 3= ee_get_width() / 4 - sin(0.02*i) * 5;209 y 3= ee_get_height() * 3 / 4 + cos(0.02*i) * 5;205 xa = ee_get_width() / 8 + sin(0.03*i) * 5; 206 ya = ee_get_height() / 2 + cos(0.03*i) * 5; 207 208 xb = ee_get_width() - 10 - cos(0.02*i) * 10; 209 yb = ee_get_height() * 3 / 4 - 5 + sin(0.02*i) * 5; 210 211 xc = ee_get_width() / 4 - sin(0.02*i) * 5; 212 yc = ee_get_height() * 3 / 4 + cos(0.02*i) * 5; 210 213 211 214 ee_set_color(EE_GREEN); 212 ee_fill_triangle(xo, yo, x 2, y2, x1, y1, '%');215 ee_fill_triangle(xo, yo, xb, yb, xa, ya, '%'); 213 216 ee_set_color(EE_YELLOW); 214 ee_draw_thin_triangle(xo, yo, x 2, y2, x1, y1);217 ee_draw_thin_triangle(xo, yo, xb, yb, xa, ya); 215 218 216 219 ee_set_color(EE_RED); 217 ee_fill_triangle(x 1, y1, x2, y2, x3, y3, '#');220 ee_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); 218 221 ee_set_color(EE_YELLOW); 219 ee_draw_thin_triangle(x 1, y1, x2, y2, x3, y3);222 ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc); 220 223 221 224 ee_set_color(EE_BLUE); 222 ee_fill_triangle(xo, yo, x 2, y2, x3, y3, '%');225 ee_fill_triangle(xo, yo, xb, yb, xc, yc, '%'); 223 226 ee_set_color(EE_YELLOW); 224 ee_draw_thin_triangle(xo, yo, x 2, y2, x3, y3);227 ee_draw_thin_triangle(xo, yo, xb, yb, xc, yc); 225 228 226 229 /* Draw a background triangle */ 227 x 1= 2;228 y 1= 2;229 230 x 2= ee_get_width() - 3;231 y 2= ee_get_height() / 2;232 233 x 3= ee_get_width() / 3;234 y 3= ee_get_height() - 3;230 xa = 2; 231 ya = 2; 232 233 xb = ee_get_width() - 3; 234 yb = ee_get_height() / 2; 235 236 xc = ee_get_width() / 3; 237 yc = ee_get_height() - 3; 235 238 236 239 ee_set_color(EE_CYAN); 237 ee_draw_thin_triangle(x 1, y1, x2, y2, x3, y3);240 ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc); 238 241 239 242 xo = ee_get_width() / 2 + cos(0.027*i) * ee_get_width() / 3; 240 243 yo = ee_get_height() / 2 - sin(0.027*i) * ee_get_height() / 2; 241 244 242 ee_draw_thin_line(x 1, y1, xo, yo);243 ee_draw_thin_line(x 2, y2, xo, yo);244 ee_draw_thin_line(x 3, y3, xo, yo);245 ee_draw_thin_line(xa, ya, xo, yo); 246 ee_draw_thin_line(xb, yb, xo, yo); 247 ee_draw_thin_line(xc, yc, xo, yo); 245 248 246 249 /* Draw a sprite on the pyramid */ … … 251 254 { 252 255 int delta = ee_rand(-5, 5); 253 ee_set_color(ee_rand( 1, 10));256 ee_set_color(ee_rand(0, 15)); 254 257 ee_putchar(ee_get_width() / 2 255 258 + cos(0.02*j) * (delta + ee_get_width() / 4), … … 276 279 { 277 280 /* Putpixel */ 278 ee_set_color(ee_rand( 1, 10));281 ee_set_color(ee_rand(0, 15)); 279 282 ee_putchar(ee_rand(0, xmax), ee_rand(0, ymax), '#'); 283 } 284 ee_refresh(); 285 } 286 287 static void demo_color(void) 288 { 289 int i; 290 char buf[BUFSIZ]; 291 292 ee_clear(); 293 for(i = 0; i < 16; i++) 294 { 295 sprintf(buf, "color %i (%s)\n", i, ee_color_names[i]); 296 ee_set_color(EE_WHITE); 297 ee_putstr(4, i + 3, buf); 298 ee_set_color(i); 299 ee_putstr(40, i + 3, "XXXXXXXXXX-XX--X----------"); 280 300 } 281 301 ee_refresh(); … … 286 306 int w = ee_get_width(); 287 307 int h = ee_get_height(); 288 int x 1, y1, x2, y2;308 int xa, ya, xb, yb; 289 309 290 310 if(force_clipping) 291 311 { 292 x 1 = ee_rand(- w, 2 * w); y1= ee_rand(- h, 2 * h);293 x 2 = ee_rand(- w, 2 * w); y2= ee_rand(- h, 2 * h);312 xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h); 313 xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h); 294 314 } 295 315 else 296 316 { 297 x 1 = ee_rand(0, w - 1); y1= ee_rand(0, h - 1);298 x 2 = ee_rand(0, w - 1); y2= ee_rand(0, h - 1);299 } 300 301 ee_set_color(ee_rand( 1, 10));317 xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1); 318 xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1); 319 } 320 321 ee_set_color(ee_rand(0, 15)); 302 322 if(thin) 303 ee_draw_thin_line(x 1, y1, x2, y2);323 ee_draw_thin_line(xa, ya, xb, yb); 304 324 else 305 ee_draw_line(x 1, y1, x2, y2, '#');325 ee_draw_line(xa, ya, xb, yb, '#'); 306 326 307 327 ee_refresh(); … … 312 332 int w = ee_get_width(); 313 333 int h = ee_get_height(); 314 int x 1, y1, x2, y2;334 int xa, ya, xb, yb; 315 335 316 336 if(force_clipping) 317 337 { 318 x 1 = ee_rand(- w, 2 * w); y1= ee_rand(- h, 2 * h);319 x 2 = ee_rand(- w, 2 * w); y2= ee_rand(- h, 2 * h);338 xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h); 339 xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h); 320 340 } 321 341 else 322 342 { 323 x 1 = ee_rand(0, w - 1); y1= ee_rand(0, h - 1);324 x 2 = ee_rand(0, w - 1); y2= ee_rand(0, h - 1);325 } 326 327 ee_set_color(ee_rand( 1, 10));328 ee_fill_box(x 1, y1, x2, y2, '#');343 xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1); 344 xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1); 345 } 346 347 ee_set_color(ee_rand(0, 15)); 348 ee_fill_box(xa, ya, xb, yb, '#'); 329 349 330 350 if(outline) 331 351 { 332 ee_set_color(ee_rand( 1, 10));333 ee_draw_thin_box(x 1, y1, x2, y2);352 ee_set_color(ee_rand(0, 15)); 353 ee_draw_thin_box(xa, ya, xb, yb); 334 354 } 335 355 … … 358 378 } 359 379 360 ee_set_color(ee_rand( 1, 10));380 ee_set_color(ee_rand(0, 15)); 361 381 ee_fill_ellipse(x, y, a, b, '#'); 362 382 363 383 if(outline) 364 384 { 365 ee_set_color(ee_rand( 1, 10));385 ee_set_color(ee_rand(0, 15)); 366 386 ee_draw_thin_ellipse(x, y, a, b); 367 387 } … … 374 394 int w = ee_get_width(); 375 395 int h = ee_get_height(); 376 int x 1, y1, x2, y2, x3, y3;396 int xa, ya, xb, yb, xc, yc; 377 397 378 398 if(force_clipping) 379 399 { 380 x 1 = ee_rand(- w, 2 * w); y1= ee_rand(- h, 2 * h);381 x 2 = ee_rand(- w, 2 * w); y2= ee_rand(- h, 2 * h);382 x 3 = ee_rand(- w, 2 * w); y3= ee_rand(- h, 2 * h);400 xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h); 401 xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h); 402 xc = ee_rand(- w, 2 * w); yc = ee_rand(- h, 2 * h); 383 403 } 384 404 else 385 405 { 386 406 387 x 1 = ee_rand(0, w - 1); y1= ee_rand(0, h - 1);388 x 2 = ee_rand(0, w - 1); y2= ee_rand(0, h - 1);389 x 3 = ee_rand(0, w - 1); y3= ee_rand(0, h - 1);390 } 391 392 ee_set_color(ee_rand( 1, 10));393 ee_fill_triangle(x 1, y1, x2, y2, x3, y3, '#');407 xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1); 408 xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1); 409 xc = ee_rand(0, w - 1); yc = ee_rand(0, h - 1); 410 } 411 412 ee_set_color(ee_rand(0, 15)); 413 ee_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); 394 414 395 415 if(outline) 396 416 { 397 ee_set_color(ee_rand( 1, 10));398 ee_draw_thin_triangle(x 1, y1, x2, y2, x3, y3);417 ee_set_color(ee_rand(0, 15)); 418 ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc); 399 419 } 400 420
Note: See TracChangeset
for help on using the changeset viewer.