| 18 | #include "util.hpp" |
| 19 | |
| 20 | void RenderBackgroundAnimation(ShapeRenderer* r) { |
| 21 | float aspect = SceneManager::GetInstance()->GetScreenAspect(); |
| 22 | static const int BG_RECTS = 50; |
| 23 | static const float RECT_W = 0.3f; |
| 24 | static const float RECT_H = 0.1f; |
| 25 | static float rectX[BG_RECTS]; |
| 26 | static float rectY[BG_RECTS]; |
| 27 | static bool rectsInitted = false; |
| 28 | int i; |
| 29 | |
| 30 | if (!rectsInitted) { |
| 31 | for (i = 0; i < BG_RECTS; i++) { |
| 32 | rectX[i] = aspect * (Random(100) / 100.0f); |
| 33 | rectY[i] = Random(100) / 100.0f; |
| 34 | } |
| 35 | rectsInitted = true; |
| 36 | } |
| 37 | |
| 38 | glClear(GL_COLOR_BUFFER_BIT); |
| 39 | |
| 40 | for (i = 0; i < BG_RECTS; i++) { |
| 41 | float c = 0.1f + 0.1f * (i % 4); |
| 42 | r->SetColor(c, c, c); |
| 43 | r->RenderRect(rectX[i], rectY[i], RECT_W, RECT_H); |
| 44 | |
| 45 | rectX[i] -= (0.01f + 0.01f * (i % 4)); |
| 46 | if (rectX[i] < -RECT_W * 0.5f) { |
| 47 | rectX[i] = aspect + RECT_W * 0.5f; |
| 48 | rectY[i] = Random(100) / 100.0f; |
| 49 | } |
| 50 | } |
| 51 | } |
no test coverage detected