Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <graphics.h>
- #include <time.h>
- using namespace std;
- class Pont
- {
- protected:
- int x,y,szin;
- public:
- Pont(int xx=0,int yy=0,int sz=MAGENTA)
- {
- x=xx;
- y=yy;
- szin=sz;
- }
- void beolvas();
- void kirajzol()
- {
- putpixel(x,y,szin);
- }
- void torol()
- {
- putpixel(x,y,BLACK);
- }
- void fel(int h)
- {
- y-=h;
- }
- void le(int h)
- {
- y+=h;
- }
- void jobb(int h)
- {
- x+=h;
- }
- void bal(int h)
- {
- x-=h;
- }
- void szinv(int sz)
- {
- szin=sz;
- }
- };
- void Pont::beolvas()
- {
- cout<<"Addja ma 300 dollart!(Es koordinatakat+szin):";
- cin>>x>>y>>szin;
- }
- class Kor:public Pont
- {
- private:
- int r;
- public:
- Kor(int xx=0,int yy=0,int sz=MAGENTA,int rr=50):Pont(xx,yy,sz)
- {
- r=rr;
- }
- void kirajzol();
- void torol();
- };
- void Kor::kirajzol()
- {
- setcolor(szin);
- circle(x,y,r);
- }
- void Kor::torol()
- {
- setcolor(BLACK);
- circle(x,y,r);
- }
- int main()
- {
- int gdriver=DETECT, gmode;
- initgraph(&gdriver, &gmode, "");
- srand(time(NULL));
- Kor k(getmaxx()/2,getmaxy()/2,rand()%15+1,50);
- k.kirajzol();
- int kilep=1,h=5;
- while(kilep)
- {
- if(GetAsyncKeyState(VK_UP)) k.fel(h);
- if(GetAsyncKeyState(VK_DOWN)) k.le(h);
- if(GetAsyncKeyState(VK_LEFT)) k.bal(h);
- if(GetAsyncKeyState(VK_RIGHT)) k.jobb(h);
- if(GetAsyncKeyState('R')) kilep=0;
- k.kirajzol();
- Sleep(10);
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement