LEL can now do hit detection on squares.

This commit is contained in:
Zed A. Shaw 2025-02-15 13:43:41 -05:00
parent aa149b6574
commit 7f9e200abe
4 changed files with 22 additions and 1 deletions

11
lel.cpp
View file

@ -69,6 +69,17 @@ namespace lel {
cur = {0, 0};
}
std::optional<std::string> Parser::hit(int x, int y) {
for(auto& [name, cell] : cells) {
if((x >= cell.x && x <= cell.x + cell.w) &&
(y >= cell.y && y <= cell.y + cell.h)) {
return name;
}
}
return std::nullopt;
}
Cell center(int width, int height, Cell &parent) {
Cell copy = parent;