LEL can now do hit detection on squares.
This commit is contained in:
parent
aa149b6574
commit
7f9e200abe
4 changed files with 22 additions and 1 deletions
11
lel.cpp
11
lel.cpp
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue