diff options
author | jacopograndi <jak.sk8@hotmail.it> | 2021-08-19 18:46:51 +0200 |
---|---|---|
committer | jacopograndi <jak.sk8@hotmail.it> | 2021-08-19 18:46:51 +0200 |
commit | a8bcacc95045102e67f2feabbdddf79535837554 (patch) | |
tree | 5781dd4cb2fe66b67deab84ff4641b7e21b9c174 /game/menu.cpp |
forgot to make repo until now
Diffstat (limited to 'game/menu.cpp')
-rw-r--r-- | game/menu.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/game/menu.cpp b/game/menu.cpp new file mode 100644 index 0000000..76913b5 --- /dev/null +++ b/game/menu.cpp @@ -0,0 +1,29 @@ +#include "menu.h" + +void Menu::close () { + active = false; +} + +void Menu::open (vec2 res) { + active = true; + pos = vec2 { (float)res.x, (float)res.y }; + float height = options.size() * 20; + size = vec2 { 120, height+10 }; + pos *= 0.5f; + pos -= size/2; +} + +int Menu::mouse_option (vec2 mouse) { + int i=0; + for (Option opt : options) { + vec2 off { 10, 10.0f + i*20 }; + vec2 sizeopt { 100, 20 }; + off += pos; + if (off.x < mouse.x && mouse.x < off.x+sizeopt.x + && off.y < mouse.y && mouse.y < off.y+sizeopt.y ) { + return opt.id; + } + i++; + } + return -1; +}
\ No newline at end of file |