Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <graphics.h>
- #include<iostream>
- using namespace std;
- class Circle{
- private:
- int x, y, radius, color;
- public:
- Circle(int _x, int _y, int r, int c )
- {
- x = _x; y=_y; radius = r; color = c;
- }
- int getColor()
- {
- return color;
- }
- int getRadius()
- {
- return radius;
- }
- void setColor(int c)
- {
- color = c;
- }
- void setRadius(int r)
- {
- radius = r;
- }
- ~Circle()
- {
- }
- void draw()
- {
- setcolor(color);
- circle(x,y, radius);
- }
- void undraw()
- {
- setcolor(BLACK);
- circle(x,y, radius);
- }
- void move(int dx, int dy)
- {
- x += dx;
- y += dy;
- }
- };
- int main( )
- {
- initwindow(800, 300, "First Sample");
- Circle c1(150, 80, 80, YELLOW);
- Circle c2(200, 100, 50, COLOR(0,0,255));
- Circle c(50, 80, 50, YELLOW);
- for (int i=0; i<150; i++)
- {
- c.draw();
- delay(100);
- c.undraw();
- c.move(10,0);
- if (kbhit()) break;
- }
- //circle(100, 50, 40);
- while (!kbhit( ))
- {
- delay(200);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement