如何保存诅咒中占据一定空间的角色?

发布于 2024-10-01 07:51:14 字数 244 浏览 9 评论 0原文

我开始尝试用C++用curses制作一些简单的控制台游戏,我的第一个项目只是一个可以在其中走动的大房间。我想我将通过让程序保存方块的状态来实现步行角色正在行走,所以当他走到下一个方块时,它可以恢复那里的任何东西。问题是,我不知道如何将某个位置的角色保存到变量中,令我惊讶的是,我似乎找不到任何全面的诅咒文档。我正在寻找这样的函数:

int storage = mvsavechar(1,1);

是否存在这样的函数?

I'm beginning to try making some simple console games in C++ with curses, and my first project is just a large room to walk around in. I figure I'm gonna implement walking by having the program save the state of the square that the character is walking on, so when he walks onto the next square, it can restore whatever was there. Problem is, I don't know how to save the character at a certain position to a variable, and to my surprise I can't seem to find any comprehensive curses documentation. I'm looking for a function like this:

int storage = mvsavechar(1,1);

Does any such function exist?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

依 靠 2024-10-08 07:51:14

您正在寻找 mvinch()

int storage = mvinch(1, 1) & A_CHARTEXT;

You're looking for mvinch():

int storage = mvinch(1, 1) & A_CHARTEXT;
◇流星雨 2024-10-08 07:51:14

您需要将房间的数据存储在程序中的某种数据结构中。 Curses 是一个输出库。

You're going to need to store the data for the room in some sort of data structure in your program. Curses is an output library.

累赘 2024-10-08 07:51:14

我将屏幕状态存储在 80x24(或其他)字符数组中。但您可能会调整阵列的大小以匹配“大房间”的尺寸。如果房间非常大,您可以使用(例如)坐标和内容的链接列表来存储稀疏数组的等效项。

Curses 可能没有您想要的功能,因为早期的终端可能没有询问屏幕内容的能力。

我对诅咒了解不多,如果诅咒保留了屏幕内容的详细信息,那么您想要的可能是可能的 - 但这似乎不太可能。

I'd store screen state in a 80x24 (or whatever) char array. But probably you'd size the array to match the dimensions of your "large room". If the room were extremely large, you could store the equivalent of a sparse array by using (for example) a linked list of coordinates&contents.

Curses probably doesn't have the function you want because early terminals probably didn't have the capability of being interrogated about screen contents.

I don't know much about curses, what you want might be possible if curses maintained details of screen contents - but that seems very unlikely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文