Facebook
From Botched Dormouse, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 260
  1. #include <allegro.h>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <windows.h>
  5.  
  6. #define HEIGHT 640
  7. #define WIDTH 480
  8.  
  9. void draw(int h, int w);
  10. void draw_random();
  11.  
  12. int main()
  13. {
  14.     allegro_init();
  15.     srand(time(NULL));
  16.  
  17.     set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
  18.     install_keyboard();
  19.  
  20.     clear_to_color(screen,makecol(255,255,255));
  21.  
  22.     draw(0,0);
  23.     Sleep(3000);
  24.     clear_to_color(screen,makecol(255,255,255));
  25.     draw_random();
  26.  
  27.     while((readkey()& 0xff) != 27);
  28.         allegro_exit();
  29.     return 0;
  30. }
  31. END_OF_MAIN()
  32.  
  33. void draw(int h, int w)
  34. {
  35.     circle(screen,screen->w/2,screen->h/2,100, makecol(40,40,40));
  36.  
  37.     rect(screen,(screen->w/3),(screen->h/3),(screen->w/1.5),(screen->h/1.5), makecol(80,80,80));
  38.  
  39.     triangle(screen,(screen->w/3), (screen->h/2), (screen->w/2), (screen->h/4), (screen->w/1.5), (screen->h/2), makecol(120,120,120));
  40.  
  41.     line(screen, screen->w/4, screen->h/4.5, screen->w/1.25, screen->h/4.5, makecol(200,200,200));
  42.  
  43.     line(screen, screen->w/4, screen->h/1.25, screen->w/1.25, screen->h/1.25, makecol(200,200,200));
  44.  
  45.     line(screen, screen->w/4, screen->h/1.25, screen->w/4, screen->h/4.5, makecol(200,200,200));
  46.  
  47.     line(screen, screen->w/1.25, screen->h/1.25, screen->w/1.25, screen->h/4.5, makecol(200,200,200));
  48.  
  49. }
  50.  
  51. void draw_random()
  52. {
  53.     int x1 = rand()%screen->w;
  54.     int y1 = rand()%screen->h;
  55.  
  56.     int random = rand()%screen->h/3;
  57.  
  58.     circle(screen, rand()%screen->w, rand()%screen->h, rand()%320, makecol(rand()%255,rand()%255,rand()%255));
  59.  
  60.     line(screen, rand()%screen->w, rand()%screen->h, rand()%screen->w, rand()%screen->h, makecol(rand()%255,rand()%255,rand()%255));
  61.  
  62.     rect(screen, x1, y1, x1+random , y1+random, makecol(rand()%255,rand()%255,rand()%255));
  63.  
  64.     triangle(screen, x1, y1, x1+random, y1, (x1+random/2), (y1+random), makecol(rand()%255,rand()%255,rand()%255));
  65. }
  66.