MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Paint

Method Paint

Applications/Minesweeper/main.cpp:147–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 }
146
147 void Paint(surface_t* surface){
148 for(int y = 0; y < mapSize.y; y++){
149 for(int x = 0; x < mapSize.x; x++){
150 Tile& tile = tiles[y][x];
151
152 if(tile.hidden){
153 if(tile.flagged){
154 Lemon::Graphics::surfacecpy(surface, &resources, {fixedBounds.x + x * 16, fixedBounds.y + y * 16}, {16, 16, 16, 16}); // Flagged tile
155 } else {
156 Lemon::Graphics::surfacecpy(surface, &resources, {fixedBounds.x + x * 16, fixedBounds.y + y * 16}, {0, 16, 16, 16}); // Hidden tile
157 }
158 } else {
159 if(tile.flagged){
160 if(tile.type == MineTile){
161 Lemon::Graphics::surfacecpy(surface, &resources, {fixedBounds.x + x * 16, fixedBounds.y + y * 16}, {16, 16, 16, 16}); // Flagged tile
162 } else {
163 Lemon::Graphics::surfacecpy(surface, &resources, {fixedBounds.x + x * 16, fixedBounds.y + y * 16}, {16 * 3, 16, 16, 16}); // Revealed, player fucked up and flagged tile that is not a mine
164 }
165 } else {
166 if(tile.type == MineTile){
167 Lemon::Graphics::surfacecpy(surface, &resources, {fixedBounds.x + x * 16, fixedBounds.y + y * 16}, {16 * 2, 16, 16, 16}); // Mine tile
168 } else if(tile.type == EmptyTile){
169 Lemon::Graphics::surfacecpy(surface, &resources, {fixedBounds.x + x * 16, fixedBounds.y + y * 16}, {16 * tile.surroundingMines, 0, 16, 16}); // Empty/numbered tile
170 }
171 }
172 }
173 }
174 }
175 }
176
177 void OnMouseUp(vector2i_t pos){
178 pos -= fixedBounds.pos;

Callers 3

GameOverMethod · 0.45
CheckWinMethod · 0.45
mainFunction · 0.45

Calls 1

surfacecpyFunction · 0.85

Tested by

no test coverage detected