Skip to content

Commit

Permalink
fix(snake): no need for app.new_input
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeromos Kovács committed Dec 1, 2024
1 parent 2df7aab commit 9720e76
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions examples/snake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ struct App {
Dir dir = Dir::Right;
Input input;
bool quit = false;
bool new_input = true;

static Snake default_snake() {
auto mid = Coord::screen_size() / 2;
Expand Down Expand Up @@ -273,7 +272,6 @@ void handle_read() {
while (!app.quit && app.input != 'q' && app.input != 'Q' && app.input != SpecKey::CtrlC &&
app.input != SpecKey::CtrlD && app.input != SpecKey::CtrlZ) {
app.input = Input::read();
app.new_input = true;
std::this_thread::sleep_for(std::chrono::milliseconds(8));
}
app.quit = true;
Expand All @@ -283,10 +281,6 @@ void handle_read() {
void run() {
app.apple.print(APPLE_TEXT);
do {
if (!app.new_input) {
continue;
}

// get direction
auto prev_dir = app.dir;
app.dir = from_input(app.input, prev_dir);
Expand Down

0 comments on commit 9720e76

Please sign in to comment.