Advertisement
Misipuk

Lab___$

May 13th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include<graphics.h>
  2. #include<conio.h>
  3. #include<dos.h>
  4. #include<iostream>
  5. char ch;
  6. using namespace std;
  7. int main()
  8. {
  9.    double x=10,y=10;
  10.    int gd = DETECT, gm;
  11.    initgraph(&gd, &gm, "C:\\TC\\BGI");
  12.    //fillellipse(200,9,3,3);
  13.    //fillellipse(10,10,10,30);
  14.    while (1)
  15.    {
  16.      
  17.     setcolor(WHITE);
  18.      rectangle(x,y,x+45,y+20);
  19.      if (getch()=='w'){
  20.        cleardevice();
  21.        y-=3;
  22.         rectangle(x,y,x+45,y+20);
  23.      }
  24.   if (getch()=='s'){
  25.     cleardevice();
  26.       y+=3;
  27.        rectangle(x,y,x+45,y+20);
  28.       }
  29.   if (getch()=='d'){
  30.   cleardevice();      
  31.        x+=3;
  32.         rectangle(x,y,x+45,y+20);
  33.    }
  34.       if (getch()=='a'){
  35.         cleardevice();
  36.       x-=3;
  37.        rectangle(x,y,x+45,y+20);
  38.     }
  39.    
  40.     if (getch()=='r'){
  41.              setcolor(RED);
  42.   cleardevice();      
  43.        x+=3;
  44.         rectangle(x,y,x+45,y+20);
  45.    }
  46.    
  47.     if (getch()=='G'){
  48.              setcolor(GREEN);
  49.   cleardevice();      
  50.        x+=3;
  51.         rectangle(x,y,x+45,y+20);
  52.    }
  53.      
  54.    }
  55.    
  56.    getch();
  57.    closegraph();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement