c++ - Program not going into a loop? -
so i'm creating game friends, , coding part in take 2 cities plane travel , from, programme wasn't entering sec do loop:
case allegro_key_tab: { bool chosecities = false; int cityone = 0; int citytwo = 0; bool validchoice = false; while (!validchoice)//valid selection either of cities { { al_clear_to_color(black); drawmap(map); al_draw_text(smallertitlefont, al_map_rgb(0, 100, 0), width / 2, 0, allegro_align_centre, "choose first city!"); al_flip_display(); std::cout << cityone << " " << citytwo << std::endl; al_wait_for_event(event_queue, &ev); if (allegro_event_key_down) { switch (ev.keyboard.keycode) { case allegro_key_1: cityone = global::whitehorse; break; case allegro_key_2: cityone = global::vancouver; break; case allegro_key_3: cityone = global::victoria; break; case allegro_key_4: cityone = global::calgary; break; case allegro_key_5: cityone = global::edmonton; break; case allegro_key_6: cityone = global::yellowknife; break; case allegro_key_7: cityone = global::saskatoon; break; case allegro_key_8: cityone = global::regina; break; case allegro_key_9: cityone = global::winnipeg; break; case allegro_key_i: cityone = global::iqaluit; break; case allegro_key_t: cityone = global::toronto; break; case allegro_key_o: cityone = global::ottawa; break; case allegro_key_m: cityone = global::montreal; break; case allegro_key_q: cityone = global::quebec; break; case allegro_key_s: cityone = global::stjohns; break; }//switch }//if key downwards }while (cityone == 0); { al_clear_to_color(black); drawmap(map); al_draw_text(smallertitlefont, al_map_rgb(0, 100, 0), width / 2, 0, allegro_align_centre, "choose sec city!"); al_flip_display(); std::cout << cityone << " q" << citytwo << std::endl; al_wait_for_event(event_queue, &ev); if (allegro_event_key_down) { switch (ev.keyboard.keycode) { case allegro_key_1: citytwo = global::whitehorse; break; case allegro_key_2: citytwo = global::vancouver; break; case allegro_key_3: citytwo = global::victoria; break; case allegro_key_4: citytwo = global::calgary; break; case allegro_key_5: citytwo = global::edmonton; break; case allegro_key_6: citytwo = global::yellowknife; break; case allegro_key_7: citytwo = global::saskatoon; break; case allegro_key_8: citytwo = global::regina; break; case allegro_key_9: citytwo = global::winnipeg; break; case allegro_key_i: citytwo = global::iqaluit; break; case allegro_key_t: citytwo = global::toronto; break; case allegro_key_o: citytwo = global::ottawa; break; case allegro_key_m: citytwo = global::montreal; break; case allegro_key_q: citytwo = global::quebec; break; case allegro_key_s: citytwo = global::stjohns; break; }//switch }//if key downwards } while (citytwo == 0); validchoice = true; }//larger while loop (valid selection both cities) buydeskone(cityone); buydesktwo(citytwo); here's more relevant code:
namespace global { enum levelnames { easy, medium, hard }; enum mapnames { canada, america, europe }; enum citynames { whitehorse = 1, vancouver, victoria, calgary, edmonton, yellowknife, saskatoon, regina, winnipeg, iqaluit, toronto, ottawa, montreal, quebec, stjohns }; int money = 0; } so it's not entering sec do-while loop in first batch of code reason.
side notes: -we using allegro 5 -there code before case keyword irrelevant question (as when press tab enters first do-while loop , displays "choose first city!"
try adding default clause switch statement. or other reason not exiting first do loop. perhaps 1 of functions not returning.
c++ c++11 visual-studio-2013 allegro allegro5
No comments:
Post a Comment