Skip to content
Snippets Groups Projects
Commit 271f13f3 authored by Susa Márk's avatar Susa Márk
Browse files

Upload New File

parent a1d847d8
No related branches found
No related tags found
No related merge requests found
#include "amoebawidget.hpp"
using namespace genv;
AmoebaWidget::AmoebaWidget(int cellSize, int cellPadding)
: cellSize(cellSize), cellPadding(cellPadding) {}
void AmoebaWidget::draw(const GameLogic& game, int pos_x, int pos_y, int width, int height) const {
clearArea(pos_x, pos_y, width, height);
for (int i = 0; i < GameLogic::pathSize; ++i) {
for (int j = 0; j < GameLogic::pathSize; ++j) {
int x = pos_x + j * (cellSize + cellPadding);
int y = pos_y + i * (cellSize + cellPadding);
gout << move_to(x, y) << color(200, 200, 200) << box(cellSize, cellSize);
char cell = game.getCell(j, i);
if (cell == 'X') {
gout << color(255, 0, 0);
gout << move_to(x + cellSize / 4, y + cellSize / 4) << line(cellSize / 2, cellSize / 2);
gout << move_to(x + cellSize / 4, y + cellSize * 3 / 4) << line(cellSize / 2, -cellSize / 2);
} else if (cell == 'O') {
gout << color(0, 0, 255);
gout << move_to(x + cellSize / 3, y + cellSize / 4) << text("O");
}
}
}
}
void AmoebaWidget::clearArea(int pos_x, int pos_y, int width, int height) const {
gout << color(0, 0, 0) << move_to(0, 0) << box(900, 800);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment