Advertisement
Guest User

My RGR

a guest
Dec 11th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <conio.h>
  2. #include <graphics.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. void Draw (int x,int y){
  7.     setcolor(8);
  8.     // Îòðèñîâêà îêíà
  9.     moveto(x+6,y+8);
  10.     lineto(x+10,y+8);
  11.     lineto(x+10,y+14);
  12.     lineto(x+6,y+14);
  13.     lineto(x+6,y+8);
  14.     moveto(x+8,y+8);
  15.     lineto(x+8,y+14);
  16.     moveto(x+8,y+10);
  17.     lineto(x+10,y+10);
  18.     // Îòðèñîâêà ñòåí
  19.     moveto(x+2,y+6);
  20.     lineto(x+14,y+6);
  21.     lineto(x+14,y+16);
  22.     lineto(x+2,y+16);
  23.     lineto(x+2,y+6);
  24.     // Îòðèñîâêà êðûøè
  25.     moveto(x,y+8);
  26.     lineto(x+8,y);
  27.     lineto(x+16,y+8);
  28. }
  29. void Move() {
  30.     int x=5,y=10;
  31.     initwindow(500,500);
  32.     while(1){
  33.         Draw(x,y);
  34.         switch (getch()) {
  35.             case 72: y-=2; break; // Ââåðõ
  36.             case 75: x-=2; break; // Âëåâî
  37.             case 77: x+=2; break; // Âïðàâî
  38.             case 80: y+=2; break; // Âíèç
  39.         }
  40.         cleardevice();
  41.     }
  42. }
  43. /*void AutoMove() {
  44.     int x=5,y=10;
  45.     initwindow(500,500);
  46.     srand(time(NULL));
  47.     Draw(x,y);
  48.     while (1) {
  49.         switch (rand()%1) {
  50.             case 0:
  51.                 Draw(x,y);
  52.                 delay(5);
  53.                 x++;
  54.                 cleardevice();
  55.             case 1:
  56.                 Draw(x,y);
  57.                 delay(5);
  58.                 y++;
  59.                 cleardevice();
  60.         }
  61.        
  62.     }
  63. }*/
  64. main() {
  65.     initwindow(325,105);
  66.     setcolor(15);
  67.     outtextxy(5,10,"1. Ñâîáîäíîå äâèæåíèå îáúåêòà");
  68.     outtextxy(5,42,"2. Äâèæåíèå îáúåêòà ñ ïîìîùüþ êëàâèàòóðû");
  69.     outtextxy(5,74,"3. Âûõîä èç ïðîãðàììû");
  70.     while(1){
  71.         switch(getch()){
  72.  //           case 49: AutoMove(); break;
  73.             case 50: Move(); break;
  74.             case 51: closegraph();
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement