amethyst / amethyst/bracket-lib

First Q key press is dropped

Open
#253 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.7k
Forks
126
PR merge metrics
No merged PRs in 30d

Description

EDIT EDIT: If I change the exit character from Q to A, then A somehow gets swallowed, this is so weird.

EDIT: Should point out on Windows 11 using WSL2 as my dev environment.

In the following code the first Q is always ignored. I can always get the first of any other character output, but I have to hit Q twice before prints and exits.

Cargo Version:
```
cargo 1.57.0 (b2e52d7ca 2021-10-21)
```

Here is the bracket-lib as reported in my Cargo.lock
```
[[package]]
name = "bracket-lib"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0fb005e908ce2e553277e554c32ab06d8b12bea38660da98f2e77e662dea617"
dependencies = [
"bracket-algorithm-traits",
"bracket-color",
"bracket-geometry",
"bracket-noise",
"bracket-pathfinding",
"bracket-random",
"bracket-terminal",
]
```

```
use bracket_lib::prelude::*;

struct State;

impl GameState for State {
fn tick(&mut self, ctx: &mut BTerm) {
ctx.cls();

if let Some(key) = ctx.key {
println!("Key={:#?}", key);
match key {
VirtualKeyCode::Q => ctx.quitting = true,
_ => {}
};
}
}
}

fn main() {
let state = State;

let ctx = BTermBuilder::simple80x50()
.build()
.expect("Should have worked?");

main_loop(ctx, state).expect("Something happened.");
}
```

In the following I hit A,B,C, etc. once and they displayed, when I hit Q the first is ignored and the second results in the output below and the program terminating as expected.

![image](https://user-images.githubusercontent.com/1381210/147891236-0e5d5e99-5fe5-44bb-bad3-d76c46147b19.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.