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:
parent
b32f5dbcff
commit
2069a5a2a0
3 changed files with 11 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue