Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
struct Brick { Rectangle rect{}; Color color{WHITE}; int hits{1}; // simple durability if you want to extend later bool alive() const { return hits > 0; } void render() const { DrawRectangleRec(rect, color); } }; std::vector
bricks; const int cols = 12; const int rows = 6; const float marginX = 16.0f; const float marginY = 60.0f; const float gap = 4.0f; const float bw = (WIDTH - marginX * 2 - gap * (cols - 1)) / cols; const float bh = 20.0f; for (int r = 0; r < rows; ++r) { for (int c = 0; c < cols; ++c) { float x = marginX + c * (bw + gap); float y = marginY + r * (bh + gap); Color color = Color{(unsigned char)(180 - r * 20), (unsigned char)(120 + r * 20), 255, 255}; bricks.push_back(Brick{Rectangle{x, y, bw, bh}, color, 1}); } } //OR: int index = 0; std::generate_n(std::back_inserter(bricks), rows * cols, [&]() { int r = index / cols; // row int c = index % cols; // col index++; float x = marginX + c * (bw + gap); float y = marginY + r * (bh + gap); Color color{ static_cast
(180 - r * 20), static_cast
(120 + r * 20), 255, 255 }; return Brick{ Rectangle{x, y, bw, bh}, color, 1 }; });
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)