mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
FlappyBug: Support mouse clicks for flapping
This change allows to play the game using the mouse.
This commit is contained in:
parent
a099a77e82
commit
913b1fad25
Notes:
sideshowbarker
2024-07-18 00:41:16 +09:00
Author: https://github.com/pmhpereira Commit: https://github.com/SerenityOS/serenity/commit/913b1fad25f Pull-request: https://github.com/SerenityOS/serenity/pull/11030 Reviewed-by: https://github.com/bgianfo
@ -85,16 +85,26 @@ void Game::keydown_event(GUI::KeyEvent& event)
|
||||
GUI::Application::the()->quit();
|
||||
break;
|
||||
default:
|
||||
if (ready_to_start()) {
|
||||
m_active = true;
|
||||
}
|
||||
if (m_active) {
|
||||
m_bug.flap();
|
||||
}
|
||||
player_input();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Game::mousedown_event(GUI::MouseEvent&)
|
||||
{
|
||||
player_input();
|
||||
}
|
||||
|
||||
void Game::player_input()
|
||||
{
|
||||
if (ready_to_start()) {
|
||||
m_active = true;
|
||||
}
|
||||
if (m_active) {
|
||||
m_bug.flap();
|
||||
}
|
||||
}
|
||||
|
||||
void Game::tick()
|
||||
{
|
||||
auto queue_update = [&]() {
|
||||
|
@ -32,12 +32,14 @@ private:
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
void tick();
|
||||
void reset();
|
||||
void game_over();
|
||||
bool ready_to_start() const;
|
||||
void player_input();
|
||||
|
||||
struct Bug {
|
||||
const float x { 50 };
|
||||
|
Loading…
Reference in New Issue
Block a user