控制台闪烁 [英] Console Flicker

查看:187
本文介绍了控制台闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在控制台模式下创建一个基于文本的小型游戏.我想通过添加一些动画(例如动画文本和框来为其打开和关闭进行动画处理)来给它加点趣味.为此,我创建了一个缓冲区(如果是CHAR_INFO,则为数组)并将所有内容写入该数组,并且每次更新一次(屏幕每秒更新30次),我使用WriteConsoleOutput来显示缓冲区.这样效果很好,动画看起来真的很棒.但是,屏幕闪烁存在问题.当我每秒多次调用WriteConsoleOutput时,似乎会发生这种情况,并且您可以看到屏幕上不断更新的行.有什么方法可以消除这种闪烁?我已经在互联网上搜寻了3天,没有运气就读过有关此问题的电子邮件.我已经看到了许多文本模式应用程序,例如Turbo Vision甚至是Edit,它们可以毫无问题地非常快速地显示很多字符,所以我知道这是可能的,但不知道如何去做.我试过创建2个屏幕缓冲区,然后切换写入一个,然后显示另一个,反之亦然(在2个之间切换,这样我就可以写到一个离屏的缓冲区,并在完成时显示它),但是即使在两个还有2个屏幕缓冲区.我该如何停止呢?

注意:当应用程序以全屏模式运行时,不会发生闪烁.

感谢您提出任何建议.

I'm creating a small text based game in console mode.  I want to spice it up a little by having a few animations like animated text and boxes that animate their opening and closing.  To do this I have created a buffer (an array if CHAR_INFOs) and write everything to that array and once per update (the screen updates at 30 times per second) I use WriteConsoleOutput to display the buffer.  This works great and the animations look real nice.  However there is a problem with the screen flickering.  This seems to happen when I call WriteConsoleOutput too many times a second and you can see lines going through the screen as it updates.  Is there any way to eliminate this flicker?  I've been searching the internet for 3 days reading and emailing about this with no luck.  I have seen many text mode applications that like Turbo Vision and even Edit that can display lots of characters very quicly with no problem so I know it's possible, but have no idea how to do it.  I've tried creating 2 screen buffers and switching writing to one and display the other and vice versa (switching between the 2 so I could write to an off screen one and display it when it is finished) but the flickering occurs even when switching between 2 screen buffers as well.  How can I stop this?

Note: The flicker does not occur when the app is run in full screen mode.

Thanks for any advice.

推荐答案

我不在Visual Basic中编程,但是我在BASIC中编程,而我目前正在开发的基于Sprite的2d游戏也遇到了同样的麻烦. BASIC程序和Visual Basic控制台应用程序几乎是同一回事.

I don't program in Visual Basic, but I do in BASIC, and I'm having the same trouble with a sprite based 2d game I'm developing at the moment. BASIC programs and Visual Basic console apps are the same thing just about.


这篇关于控制台闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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