Skip to content

Commit

Permalink
Disable VSync in windowed mode as well to reduce input latency.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramirisu committed Aug 29, 2024
1 parent 1d1ca39 commit 370c505
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ A Classic Tetris (NES Tetris) clone written in bevy/rust.

## Keybindings

| Action | Keyboard | Controller (NES) | Note |
| :--------------------------------- | :------: | :--------------: | :-------------------------------------------------------------------- |
| Move Up | | | |
| Move Down | | | |
| Move Left | | | |
| Move Right | | | |
| Rotate Clockwisely | X | A | |
| Rotate Counterclockwisely | Z | B | |
| Start/Pause/Resume | Enter | Start | |
| Soft Reset | Esc | Select | |
| Windowed/FullScreen (Desktop Only) | F11 | | FullScreen Mode will disable VSync automatically to maximize the FPS. |
| Action | Keyboard | Controller (NES) |
| :--------------------------------------------- | :------: | :--------------: |
| Move Up || |
| Move Down || |
| Move Left || |
| Move Right || |
| Rotate Clockwisely | X | A |
| Rotate Counterclockwisely | Z | B |
| Start/Pause/Resume | Enter | Start |
| Soft Reset | Esc | Select |
| Toggle Windowed/FullScreen Mode (Desktop Only) | F11 | |

## License

Expand Down
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use bevy::{color::palettes::css::GREEN, prelude::*, window::WindowResolution};
use bevy::{
color::palettes::css::GREEN,
prelude::*,
window::{PresentMode, WindowResolution},
};

#[cfg(not(target_arch = "wasm32"))]
use bevy::window::{PresentMode, WindowMode};
use bevy::window::WindowMode;

mod app_state;
mod controller;
Expand All @@ -21,6 +25,7 @@ fn main() {
.set(WindowPlugin {
primary_window: Some(Window {
resolution: WindowResolution::new(1280.0, 1000.0),
present_mode: PresentMode::AutoNoVsync,
..default()
}),
..default()
Expand Down Expand Up @@ -77,11 +82,9 @@ fn handle_input_system(
match window.mode {
WindowMode::Windowed => {
window.mode = WindowMode::Fullscreen;
window.present_mode = PresentMode::AutoNoVsync;
}
WindowMode::Fullscreen => {
window.mode = WindowMode::Windowed;
window.present_mode = PresentMode::AutoVsync;
}
_ => (),
}
Expand Down

0 comments on commit 370c505

Please sign in to comment.