Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sf::RenderWindow Okno(sf::VideoMode( 1000, 800, 32 ) ,"Test");
- int liczba=5;
- class kk
- {
- public:
- sf::CircleShape circle;
- sf::Color kolor;
- display()
- {
- Okno.draw(circle);
- }
- move()
- {
- circle.setPosition(250,250);
- }
- kk()
- {
- kolor.r=rand() % 256;
- kolor.g=rand() % 256;
- kolor.b=rand() % 256;
- circle.setRadius(rand() % 100);
- circle.setFillColor(kolor);
- circle.setPosition(rand() % 800,rand() % 800);
- circle.setRadius(25);
- }
- };
- int adres;
- kk *dodaj(kk *tablica)
- {
- kk * circles2=new kk[liczba+1];
- liczba+=1;
- for(int a=0; a!=liczba-1; a++)
- {
- circles2[a]=tablica[a];
- }
- kk *circles=new kk[liczba];
- for(int a=0; a!=liczba; a++)
- {
- circles[a]=circles2[a];
- }
- delete[] circles2;
- return circles;
- }
- int test(kk *tab, kk* circles)
- {
- for(int a=0; a!=liczba; a++)
- {
- circles[a]=tab[a];
- }
- }
- bool lever;
- int main()
- {
- srand((int)time(0));
- //std::vector<kk> circles(liczba);
- //kk *circles=new kk[liczba];
- kk circles[55];
- while(Okno.isOpen())
- {
- //licznikwhite+=1;
- //licznikblack+=1;
- sf::Event zdarzenie;
- while( Okno.pollEvent( zdarzenie ) )
- {
- if( zdarzenie.type == sf::Event::Closed )
- {
- Okno.close();
- }
- if (zdarzenie.type == sf::Event::KeyPressed)
- {
- if (zdarzenie.key.code == sf::Keyboard::Escape)
- {
- lever=true;
- }
- }
- }
- Okno.clear(sf::Color::White);
- for(int a=0; a!=liczba; a++)
- {
- circles[a].display();
- }
- circles[3].move();
- if(lever==true)
- {
- //liczba+=1;
- delete[] circles;
- kk *circles=new kk[liczba];
- test(dodaj(circles), circles);
- lever=false;
- /*kk * circles2=new kk[liczba+1];
- liczba+=1;
- for(int a=0; a!=liczba-1; a++)
- {
- circles2[a]=circles[a];
- }
- delete[] circles;
- kk *circles=new kk[liczba];
- for(int a=0; a!=liczba; a++)
- {
- circles[a]=circles2[a];
- }
- delete[] circles2;
- lever=false;*/
- }
- //gniazdo.send(obraz, sizeof(obraz));
- //pakiet.clear();
- Okno.display();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment