Changeset 124
- Timestamp:
- Nov 10, 2003, 3:13:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ttyvaders/trunk/test/demo.c
r118 r124 30 30 static void display_menu(void); 31 31 32 static void demo_all(void); 33 32 34 static void demo_dots(void); 33 35 static void demo_lines(void); … … 38 40 static void demo_sprites(void); 39 41 40 int clipping = 0;42 int force_clipping = 0; 41 43 struct ee_sprite *sprite = NULL; 42 44 … … 74 76 quit = 1; 75 77 break; 78 case '0': 79 ee_clear(); 80 demo = demo_all; 81 break; 76 82 case '1': 77 83 ee_clear(); … … 134 140 135 141 ee_goto(4, 6); 142 ee_putstr("0: complete demo"); 143 ee_goto(4, 7); 136 144 ee_putstr("1: dots demo"); 137 ee_goto(4, 7);145 ee_goto(4, 8); 138 146 ee_putstr("2: lines demo"); 139 ee_goto(4, 8);147 ee_goto(4, 9); 140 148 ee_putstr("3: thin lines demo"); 141 ee_goto(4, 9);149 ee_goto(4, 10); 142 150 ee_putstr("4: circles demo"); 143 ee_goto(4, 1 0);151 ee_goto(4, 11); 144 152 ee_putstr("5: triangles demo"); 145 ee_goto(4, 1 1);153 ee_goto(4, 12); 146 154 ee_putstr("6: outlined triangles demo"); 147 ee_goto(4, 1 2);155 ee_goto(4, 13); 148 156 ee_putstr("7: sprites demo"); 149 157 150 158 ee_goto(4, yo - 2); 151 159 ee_putstr("q: quit"); 160 161 ee_refresh(); 162 } 163 164 static void demo_all(void) 165 { 166 static int i = 0; 167 168 int j, xo, yo, x1, y1, x2, y2, x3, y3; 169 170 i++; 171 172 ee_clear(); 173 174 /* Draw the sun */ 175 ee_color(EE_YELLOW); 176 xo = ee_get_width() / 4; 177 yo = ee_get_height() / 4 + 5 * sin(0.03*i); 178 179 for(j = 0; j < 16; j++) 180 { 181 x1 = xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + M_PI*j/8); 182 y1 = yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + M_PI*j/8); 183 ee_draw_thin_line(xo, yo, x1, y1); 184 } 185 186 ee_color(EE_WHITE); 187 for(j = 15 + sin(0.03*i) * 8; j--;) 188 { 189 ee_draw_circle(xo, yo, j, '#'); 190 } 191 192 ee_color(EE_YELLOW); 193 ee_draw_circle(xo, yo, 15 + sin(0.03*i) * 8, '#'); 194 195 /* Draw the pyramid */ 196 xo = ee_get_width() * 5 / 8; 197 yo = 2; 198 199 x1 = ee_get_width() / 8 + sin(0.03*i) * 5; 200 y1 = ee_get_height() / 2 + cos(0.03*i) * 5; 201 202 x2 = ee_get_width() - 10 - cos(0.02*i) * 10; 203 y2 = ee_get_height() * 3 / 4 - 5 + sin(0.02*i) * 5; 204 205 x3 = ee_get_width() / 4 - sin(0.02*i) * 5; 206 y3 = ee_get_height() * 3 / 4 + cos(0.02*i) * 5; 207 208 ee_color(EE_GREEN); 209 ee_fill_triangle(xo, yo, x2, y2, x1, y1, '%'); 210 ee_color(EE_YELLOW); 211 ee_draw_thin_line(xo, yo, x2, y2); 212 ee_draw_thin_line(x2, y2, x1, y1); 213 ee_draw_thin_line(x1, y1, xo, yo); 214 215 ee_color(EE_RED); 216 ee_fill_triangle(x1, y1, x2, y2, x3, y3, '#'); 217 ee_color(EE_YELLOW); 218 ee_draw_thin_line(x1, y1, x2, y2); 219 ee_draw_thin_line(x2, y2, x3, y3); 220 ee_draw_thin_line(x3, y3, x1, y1); 221 222 ee_color(EE_BLUE); 223 ee_fill_triangle(xo, yo, x2, y2, x3, y3, '%'); 224 ee_color(EE_YELLOW); 225 ee_draw_thin_line(xo, yo, x2, y2); 226 ee_draw_thin_line(x2, y2, x3, y3); 227 ee_draw_thin_line(x3, y3, xo, yo); 228 229 /* Draw a background triangle */ 230 x1 = 2; 231 y1 = 2; 232 233 x2 = ee_get_width() - 3; 234 y2 = ee_get_height() / 2; 235 236 x3 = ee_get_width() / 3; 237 y3 = ee_get_height() - 3; 238 239 ee_color(EE_BLUE); 240 // ee_fill_triangle(x1, y1, x2, y2, x3, y3, '.'); 241 ee_color(EE_CYAN); 242 ee_draw_thin_line(x1, y1, x3, y3); 243 ee_draw_thin_line(x2, y2, x1, y1); 244 ee_draw_thin_line(x3, y3, x2, y2); 245 246 xo = ee_get_width() / 2 + cos(0.027*i) * ee_get_width() / 3; 247 yo = ee_get_height() / 2 - sin(0.027*i) * ee_get_height() / 2; 248 249 ee_draw_thin_line(x1, y1, xo, yo); 250 ee_draw_thin_line(x2, y2, xo, yo); 251 ee_draw_thin_line(x3, y3, xo, yo); 252 253 /* Draw a sprite behind the pyramid */ 254 ee_draw_sprite(xo, yo, sprite); 255 256 /* Draw a trail behind the foreground sprite */ 257 for(j = i - 60; j < i; j++) 258 { 259 int delta = ee_rand(-5, 5); 260 ee_color(ee_rand(1, 10)); 261 ee_goto(ee_get_width() / 2 262 + cos(0.02*j) * (delta + ee_get_width() / 4), 263 ee_get_height() / 2 264 + sin(0.02*j) * (delta + ee_get_height() / 3)); 265 ee_putchar('#'); 266 } 267 268 /* Draw foreground sprite */ 269 ee_draw_sprite(ee_get_width() / 2 + cos(0.02*i) * ee_get_width() / 4, 270 ee_get_height() / 2 + sin(0.02*i) * ee_get_height() / 3, 271 sprite); 152 272 153 273 ee_refresh(); … … 177 297 /* Draw lines */ 178 298 ee_color(ee_rand(1, 10)); 179 if( clipping)299 if(force_clipping) 180 300 { 181 301 ee_draw_line(ee_rand(- w, 2 * w), ee_rand(- h, 2 * h), … … 197 317 /* Draw lines */ 198 318 ee_color(ee_rand(1, 10)); 199 if( clipping)319 if(force_clipping) 200 320 { 201 321 ee_draw_thin_line(ee_rand(- w, 2 * w), ee_rand(- h, 2 * h), … … 216 336 217 337 /* Draw circles */ 218 if( clipping)338 if(force_clipping) 219 339 { 220 340 ee_color(ee_rand(1, 10)); … … 250 370 /* Draw lines */ 251 371 ee_color(ee_rand(1, 10)); 252 if( clipping)372 if(force_clipping) 253 373 { 254 374 ee_fill_triangle(ee_rand(- w, 2 * w), ee_rand(- h, 2 * h), … … 269 389 int w = ee_get_width(); 270 390 int h = ee_get_height(); 391 int x1, y1, x2, y2, x3, y3; 271 392 272 393 /* Draw lines */ 273 394 ee_color(ee_rand(1, 10)); 274 if(clipping) 275 { 276 ee_fill_triangle(ee_rand(- w, 2 * w), ee_rand(- h, 2 * h), 277 ee_rand(- w, 2 * w), ee_rand(- h, 2 * h), 278 ee_rand(- w, 2 * w), ee_rand(- h, 2 * h), '#'); 395 if(force_clipping) 396 { 397 x1 = ee_rand(- w, 2 * w); 398 y1 = ee_rand(- h, 2 * h); 399 x2 = ee_rand(- w, 2 * w); 400 y2 = ee_rand(- h, 2 * h); 401 x3 = ee_rand(- w, 2 * w); 402 y3 = ee_rand(- h, 2 * h); 279 403 } 280 404 else 281 405 { 282 int x1, y1, x2, y2, x3, y3;283 406 284 407 x1 = ee_rand(0, w - 1); … … 288 411 x3 = ee_rand(0, w - 1); 289 412 y3 = ee_rand(0, h - 1); 290 291 ee_fill_triangle(x1, y1, x2, y2, x3, y3, '#'); 292 293 ee_color(ee_rand(1, 10)); 294 ee_draw_thin_line(x1, y1, x2, y2); 295 ee_draw_thin_line(x2, y2, x3, y3); 296 ee_draw_thin_line(x3, y3, x1, y1); 297 } 413 } 414 415 ee_fill_triangle(x1, y1, x2, y2, x3, y3, '#'); 416 417 ee_color(ee_rand(1, 10)); 418 ee_draw_thin_line(x1, y1, x2, y2); 419 ee_draw_thin_line(x2, y2, x3, y3); 420 ee_draw_thin_line(x3, y3, x1, y1); 421 298 422 ee_refresh(); 299 423 } … … 301 425 static void demo_sprites(void) 302 426 { 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 427 ee_draw_sprite(ee_rand(0, ee_get_width() - 1), 428 ee_rand(0, ee_get_height() - 1), sprite); 336 429 ee_refresh(); 337 430 }
Note: See TracChangeset
for help on using the changeset viewer.