如何在ncurses C中绘制坐标 [英] How to draw coordinates in ncurses c++

查看:88
本文介绍了如何在ncurses C中绘制坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,使用以下代码,我能够创建一个坐标图系统. 但我坚持要获得坐标标记. 现在,我将从用户处获得(x,y),我需要在地图内用"*"标记它. 用户将得到几个(x,y)坐标,我需要标记. 我无法这样做.我了解我需要修改循环,但是如果我修改了它,则会变得非常混乱.请指教.我正在使用ncurses.

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. 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. :).

这篇关于如何在ncurses C中绘制坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆