简体   繁体   中英

How to draw coordinates in ncurses c++

座标

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'));
}

How about seperating the model. eg 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. :).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM