在控制台中上移一行 (Pascal)

发布于 2024-09-25 09:17:21 字数 212 浏览 5 评论 0原文

当其他人都在学习 Pascal 的基础知识时,我正坐在大学里制作一个圆圈和十字游戏。我可以将表示棋盘的 2D 数组打印到终端中,但我想要做的是每次玩家添加零或十字或移动光标时更新棋盘。为此,我想用新板覆盖旧板。有没有办法将控制台光标向上移动一行(顺便说一下Windoze控制台),或者我可以清除Pascal中的整个终端吗?

谢谢,

詹姆斯

Ps。这不是家庭作业。

I'm sitting at college making a noughts and crosses game while everyone else is learning the basics of Pascal. I can print the 2D array denoting the board into the terminal just fine, but what I want to do is update the board everytime a player adds a nought or cross, or moves their cursor around. To do this, I want to over-write the old board with the new one. Is there a way to move the console cursor up one line (Windoze console by the way), or can I clear the entire terminal in Pascal?

Thanks,

James

Ps. This is NOT homework.

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

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

发布评论

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

评论(1

听,心雨的声音 2024-10-02 09:17:21

根据您使用的 Pascal 风格,您也许可以使用 gotoxy()。通常这将在 Pascal UNIT 中,例如 CRT,因此您需要在程序开始时使用 USES CRT;,例如

PROGRAM main;

USES CRT;

BEGIN
  gotoxy(10, 10);
  writeln('Hello world!');
END.

Depending on what flavour of Pascal you are using you may be able to use gotoxy(). Typically this will be in a Pascal UNIT such as CRT, so you'll need a USES CRT; at the start of your program, e.g.

PROGRAM main;

USES CRT;

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