diff options
Diffstat (limited to 'Userland/Games/FlappyBug/main.cpp')
-rw-r--r-- | Userland/Games/FlappyBug/main.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Userland/Games/FlappyBug/main.cpp b/Userland/Games/FlappyBug/main.cpp new file mode 100644 index 0000000000..1112889366 --- /dev/null +++ b/Userland/Games/FlappyBug/main.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021, Mim Hufford <mim@hotmail.co.uk> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "Game.h" +#include <LibGUI/Application.h> +#include <LibGUI/Icon.h> +#include <LibGUI/Menu.h> +#include <LibGUI/Menubar.h> +#include <LibGUI/Window.h> +#include <unistd.h> + +int main(int argc, char** argv) +{ + if (pledge("stdio rpath wpath cpath recvfd sendfd cpath unix", nullptr) < 0) { + perror("pledge"); + return 1; + } + + auto app = GUI::Application::construct(argc, argv); + + if (pledge("stdio rpath wpath cpath recvfd sendfd", nullptr) < 0) { + perror("pledge"); + return 1; + } + + if (unveil("/res", "r") < 0) { + perror("unveil"); + return 1; + } + + if (unveil(nullptr, nullptr) < 0) { + perror("unveil"); + return 1; + } + + auto window = GUI::Window::construct(); + window->resize(FlappyBug::Game::game_width, FlappyBug::Game::game_height); + auto app_icon = GUI::Icon::default_icon("app-flappybug"); + window->set_icon(app_icon.bitmap_for_size(16)); + window->set_title("Flappy Bug"); + window->set_double_buffering_enabled(false); + window->set_resizable(false); + window->set_main_widget<FlappyBug::Game>(); + window->show(); + + auto menubar = GUI::Menubar::construct(); + + auto& game_menu = menubar->add_menu("&Game"); + game_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the()->quit(); + })); + + auto& help_menu = menubar->add_menu("&Help"); + help_menu.add_action(GUI::CommonActions::make_about_action("Flappy Bug", app_icon, window)); + + window->set_menubar(move(menubar)); + + return app->exec(); +} |