Skip to content

tb_peek_event() buffers inputs with sleep_for() c++11 #133

@Mutaru16bit

Description

@Mutaru16bit

I'm not sure if this behavior of tb_peek_event() is intentional or not. I encountered it while attempting to make Tetris using termbox and trying to implement a time function and any inputs would stack rather than update on loop.

It can be replicated like this:

simply hold space and release when it shows 1.

#include <termbox.h>
#include <thread>
#include <chrono>
int main(void)
{
int i;
tb_init();
tb_cell c = {};
tb_event e = {};
while(i < 4)
{
tb_clear();
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
tb_peek_event(&e, 0);
if(e.key == TB_KEY_SPACE)
{
i++;
}
c.ch = 48 + i;
tb_put_cell(0,0,&c);
tb_present();
}
tb_shutdown();
return(0);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions