diff options
author | Pedro Pereira <pmh.pereira@gmail.com> | 2021-11-21 10:46:04 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-11-21 16:40:14 +0000 |
commit | efe5f37b04b094d183350b35d38719403660b518 (patch) | |
tree | 7d9cd0b0e7180503d923c30c158316f76546afc2 /Userland/Demos | |
parent | 7b923d1376bb3fddd5049f220208b4abcf3cf415 (diff) | |
download | serenity-efe5f37b04b094d183350b35d38719403660b518.zip |
Starfield: Modify speed by Plus or Minus keypresses
Although this is supposed to be a screensaver, it makes all the sense in
the world that it should support modifying the speed interactively. :^)
Diffstat (limited to 'Userland/Demos')
-rw-r--r-- | Userland/Demos/Starfield/Starfield.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Userland/Demos/Starfield/Starfield.cpp b/Userland/Demos/Starfield/Starfield.cpp index cd6ed50924..bdee1528f0 100644 --- a/Userland/Demos/Starfield/Starfield.cpp +++ b/Userland/Demos/Starfield/Starfield.cpp @@ -85,9 +85,19 @@ void Starfield::mousedown_event(GUI::MouseEvent&) GUI::Application::the()->quit(); } -void Starfield::keydown_event(GUI::KeyEvent&) +void Starfield::keydown_event(GUI::KeyEvent& event) { - GUI::Application::the()->quit(); + switch (event.key()) { + case Key_Plus: + m_speed++; + break; + case Key_Minus: + if (--m_speed < 1) + m_speed = 1; + break; + default: + GUI::Application::the()->quit(); + } } void Starfield::paint_event(GUI::PaintEvent& event) |