1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:37:34 +00:00

Snake: Make initialization from GML fallible

Replace the C_OBJECT factory functions with a custom try_create() which
loads the various bitmaps. Any failures there are now propagated.
This commit is contained in:
Sam Atkins 2022-12-29 17:31:34 +00:00 committed by Tim Flynn
parent b32f5dbcff
commit 2069a5a2a0
3 changed files with 11 additions and 9 deletions

View file

@ -14,9 +14,11 @@
namespace Snake {
class Game : public GUI::Frame {
C_OBJECT(Game);
C_OBJECT_ABSTRACT(Game);
public:
static ErrorOr<NonnullRefPtr<Game>> try_create();
virtual ~Game() override = default;
void start();
@ -28,7 +30,7 @@ public:
Function<bool(u32)> on_score_update;
private:
Game();
explicit Game(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps);
virtual void paint_event(GUI::PaintEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override;