Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <climits>
- #include <iostream>
- #include <ctime>
- #include <cmath>
- #include <graphics.h>
- #include <windows.h>
- #include <sys/time.h>
- #include <thread>
- using namespace std;
- const int width = 1000;
- const int height = 600;
- int func(int x) {
- return sin(x * 0.02) * 50;
- }
- int random(int min, int max) {
- return min + rand() % (max - min);
- }
- const int rect_count = 20;
- struct rectangle
- {
- int width;
- int height;
- int x, y;
- } rectangles[rect_count];
- int main() {
- initwindow(width, height);
- int i = 0;
- bool page = 0;
- bool fl = 1;
- srand(time(NULL));
- for(int i = 0; i < rect_count; i++) {
- rectangles[i].width = random(10, 70);
- rectangles[i].height = random(10, 70);
- rectangles[i].x = random(0, width - rectangles[i].width);
- rectangles[i].y = random(0, height - rectangles[i].height);
- }
- while (true) {
- setactivepage(page = !page);
- setfillstyle(SOLID_FILL, COLOR(47, 47, 47));
- bar(0, 0, width, height);
- setfillstyle(SOLID_FILL, COLOR(255, 0, 0));
- for(int i = 0; i < rect_count; i++) {
- if(rectangles[i].x <= 0)
- rectangles[i].x += 6;
- rectangles[i].x += random(-5, 6);
- if(rectangles[i].y <= 0)
- rectangles[i].y += 6;
- rectangles[i].y += random(-5, 6);
- rectangle( rectangles[i].x,
- rectangles[i].y,
- rectangles[i].x + rectangles[i].width,
- rectangles[i].y + rectangles[i].height);
- }
- delay(1);
- setvisualpage(page);
- }
- }
Add Comment
Please, Sign In to add comment