How to draw coordinates in ncurses c++

瘦欲@ 提交于 2019-12-12 04:11:40

问题


Hi Guys, using the following codes i was able to create a coordinate map system. but i an stuck at getting the coordinates marked. now i will get (x,y) from the user and i need to mark it inside the map with " * ". the user would be give several (x,y) coordinates and i need to mark. I am unable to do so. I understand i need to modify the loop but if i modify it gets totally messy. Please advice. i am using the ncurses.

mvaddstr(3 - 2, 3 + 5, "Main Board");
mvaddstr(3 - 1, 3 - 3, numbers); 
for (y = 0; y < 7; ++y) {
    mvaddch(3 + y, 3 - 3, (chtype) (y + '0'));
    attron(COLOR_PAIR(COLOR_RED));
    addch(' ');
    for (x = 0; x < 7; x++) {
       (void) addstr(" . ");            
    }
    (void) attrset(0);
    (void) addch(' ');
    (void) addch((chtype) (y + '0'));
}

回答1:


How about seperating the model. e.g. Keep the state in a different object or struct and create a function to draw the model. It might be easier to maintain and change. :).



来源:https://stackoverflow.com/questions/12768544/how-to-draw-coordinates-in-ncurses-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!