mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:47:35 +00:00
Pong: Switch to global tracking
When I play Pong, I don't really pay attention to whether my mouse is in the Pong window. That means that sometimes, annoyingly, the window loses my mouse, and I lose control of the paddle. Gasp! D: This commit teaches Pong the wonders of global mouse tracking, thus enabling the player to focus solely on the game.
This commit is contained in:
parent
4f2bcebe74
commit
9c3da7a3e3
2 changed files with 7 additions and 4 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/MouseTracker.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
|
@ -17,7 +18,8 @@
|
|||
|
||||
namespace Pong {
|
||||
|
||||
class Game final : public GUI::Widget {
|
||||
class Game final : public GUI::Widget
|
||||
, GUI::MouseTracker {
|
||||
C_OBJECT(Game);
|
||||
|
||||
public:
|
||||
|
@ -32,8 +34,8 @@ private:
|
|||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void keyup_event(GUI::KeyEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
virtual void track_mouse_move(Gfx::IntPoint const&) override;
|
||||
|
||||
void reset();
|
||||
void reset_ball(int serve_to_player);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue