diff options
author | jacopograndi <jak.sk8@hotmail.it> | 2021-08-29 13:57:41 +0200 |
---|---|---|
committer | jacopograndi <jak.sk8@hotmail.it> | 2021-08-29 13:57:41 +0200 |
commit | ace5c3f3093c50ff7fa6f8b281a377e3788abbd5 (patch) | |
tree | 8a52803dc2b777822e9b1cab148bec8798bfeadf /game/view.cpp | |
parent | a8bcacc95045102e67f2feabbdddf79535837554 (diff) |
adding techs
Diffstat (limited to 'game/view.cpp')
-rw-r--r-- | game/view.cpp | 61 |
1 files changed, 50 insertions, 11 deletions
diff --git a/game/view.cpp b/game/view.cpp index 6599a0e..d00fd2a 100644 --- a/game/view.cpp +++ b/game/view.cpp @@ -19,49 +19,88 @@ void View::process (Gst &gst, vec2 cam, vec2 mouse, int *mheld) { for (int i=0; i<moves.size() && !found; i++) { int x = moves[i] % gr.sizex; int y = moves[i] / gr.sizex; + int valid = 1; + for (Entity &e : gst.entities) { + if (e.x == x && e.y == y && e.info->unit == 1) { + valid = 0; + } + } + if (!valid) continue; vec2 pos { (float)x*32, (float)y*32 }; if (pos.x < absmouse.x && absmouse.x < pos.x+32 && pos.y < absmouse.y && absmouse.y < pos.y+32) { cursor_ground = moves[i]; - found = true; } } + found = true; + } + + if (attacks.size() > 0 && !found) { + for (int i=0; i<attacks.size() && !found; i++) { + int x = attacks[i] % gr.sizex; + int y = attacks[i] / gr.sizex; + vec2 pos { (float)x*32, (float)y*32 }; + if (pos.x < absmouse.x && absmouse.x < pos.x+32 + && pos.y < absmouse.y && absmouse.y < pos.y+32) + { + cursor_ground = attacks[i]; + } + } + found = true; + } + + if (menu_train.active && !found) { + int selected = menu_train.mouse_option(mouse); + if (selected != -1) { + opt = selected; found = true; + } else { + back = 1; found = 1; + } + } + + if (menu_build.active && !found) { + int selected = menu_build.mouse_option(mouse); + if (selected != -1) { + opt = selected; found = true; + } else { + back = 1; found = 1; + } } if (menu_unit.active && !found) { int selected = menu_unit.mouse_option(mouse); if (selected != -1) { - opt = selected; - found = true; + opt = selected; found = true; } else { - back = 1; - found = 1; + back = 1; found = 1; } } if (menu_day.active && !found) { int selected = menu_day.mouse_option(mouse); if (selected != -1) { - opt = selected; - found = true; + opt = selected; found = true; } else { - back = 1; - found = 1; + back = 1; found = 1; } } for (int i=0; i<entities.size() && !found; i++) { if (entities[i].done) continue; - if (entities[i].owner != gst.day) continue; + if (entities[i].owner != gst.turn) continue; vec2 pos { (float)entities[i].x*32, (float)entities[i].y*32 }; if (pos.x < absmouse.x && absmouse.x < pos.x+32 && pos.y < absmouse.y && absmouse.y < pos.y+32) { cursor_entity = i; - found = true; + if (entities[i].info->unit == 1) { + found = true; + } } } + if (cursor_entity != -1) found = true; + for (int y=0; y<gr.sizey && !found; y++) { for (int x=0; x<gr.sizex && !found; x++) { vec2 pos { (float)x*32, (float)y*32 }; |