Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<graphics.h>
- #include<conio.h>
- #include<dos.h>
- #include<iostream>
- char ch;
- using namespace std;
- int main()
- {
- double x=10,y=10;
- int gd = DETECT, gm;
- initgraph(&gd, &gm, "C:\\TC\\BGI");
- //fillellipse(200,9,3,3);
- //fillellipse(10,10,10,30);
- while (1)
- {
- setcolor(WHITE);
- rectangle(x,y,x+45,y+20);
- if (getch()=='w'){
- cleardevice();
- y-=3;
- rectangle(x,y,x+45,y+20);
- }
- if (getch()=='s'){
- cleardevice();
- y+=3;
- rectangle(x,y,x+45,y+20);
- }
- if (getch()=='d'){
- cleardevice();
- x+=3;
- rectangle(x,y,x+45,y+20);
- }
- if (getch()=='a'){
- cleardevice();
- x-=3;
- rectangle(x,y,x+45,y+20);
- }
- if (getch()=='r'){
- setcolor(RED);
- cleardevice();
- x+=3;
- rectangle(x,y,x+45,y+20);
- }
- if (getch()=='G'){
- setcolor(GREEN);
- cleardevice();
- x+=3;
- rectangle(x,y,x+45,y+20);
- }
- }
- getch();
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement