{"id":18286486,"url":"https://github.com/v0idzdev/sfml-template","last_synced_at":"2026-06-19T16:04:56.930Z","repository":{"id":92011033,"uuid":"495941013","full_name":"v0idzdev/sfml-template","owner":"v0idzdev","description":"Simple template for SFML projects.","archived":false,"fork":false,"pushed_at":"2022-05-24T19:15:51.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T04:39:31.185Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/v0idzdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-24T18:22:20.000Z","updated_at":"2022-05-24T19:00:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"f83ec356-5755-470f-ab1c-59afc07bec33","html_url":"https://github.com/v0idzdev/sfml-template","commit_stats":null,"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/v0idzdev/sfml-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0idzdev%2Fsfml-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0idzdev%2Fsfml-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0idzdev%2Fsfml-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0idzdev%2Fsfml-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v0idzdev","download_url":"https://codeload.github.com/v0idzdev/sfml-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0idzdev%2Fsfml-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34538480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T13:20:36.349Z","updated_at":"2026-06-19T16:04:56.882Z","avatar_url":"https://github.com/v0idzdev.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SFML Project Template\nThis is a simple template for starting SFML projects.\n\n## Guide\n**[Installation](#installation)**\n\n**[Compilation](#compilation)**\n* [Adding Files](#adding-files-optional)\n* [SFML Headers](#adding-files-optional)\n* [Changing Folder Names](#changing-folder-names)\n\n**[Game Class](#game-class)**\n* [Class Members](#class-members)\n* [Update and Draw](#update-and-draw)\n* [Init Methods](#init-methods)\n* [Accessors](#accessors)\n* [Constructor and Destructor](#constructor-and-destructor)\n\n## Installation\nSimply run the following terminal commands:\n```bash\ngit clone https://github.com/matthewflegg/sfml-template.git\ncd sfml-template\n```\nYou can also just create a template from the repository or clone this repo a different way. Regardless of how you do it, everything else will work the same way.\n\n## Compilation\nCompilation is done via a shell script. Unfortunately, I haven't got round to writing a script for Windows yet. On Linux or macOS, run the following commands:\n```bash\nchmod +x build.sh\n./build.sh\n```\n\nTo run your game, run:\n```bash\n./bin/game\n```\n\n#### Adding Files (Optional)\nYou should add header files in the `inc` directory. Place their corresponding source files in `src`.\n\nWhen you add a new source file open `build.sh`. Add a new line to the `cpp` string. Here's an example:\n\nBefore:\n```bash\ncpp=\"\\\n     $root/$src/game.cc\"\n```\nAfter:\n```bash\ncpp=\"\\\n     $root/$src/game.cc \\\n     $root/$src/enemy.cc\"\n```\n\nYou shouldn't include any header files in the script. For more information, read the comments, these outline the steps to compile the project.\n\n#### SFML Headers (Optional)\nYou can remove any SFML headers that you haven't included. For instance, let's remove `SFML/Network.hpp`:\n\nBefore:\n```bash\nlib=\"\\\n     -lsfml-audio \\\n     -lsfml-graphics \\\n     -lsfml-network \\\n     -lsfml-system \\\n     -lsfml-window\"\n ```\n \n After:\n```bash\nlib=\"\\\n     -lsfml-audio \\\n     -lsfml-graphics \\\n     -lsfml-system \\\n     -lsfml-window\"\n ```\n \n#### Changing Folder Names\nIf you change the names of any directories, make sure you change their corresponding variable in `build.sh`. For example, let's change `src` to `source` and `inc` to `include`:\n\nBefore:\n```bash\nsrc=\"src\"\ninc=\"inc\"\n```\n\nAfter:\n```bash\nsrc=\"source\"\ninc=\"include\"\n```\n \n## Game Class\nThe game class is relatively straightforward to use. It includes update and render methods, and well as a `sf::RenderWindow*` and `sf::VideoMode`. You shouldn't need to edit `main.cc`.\n\n#### Class Members\nThe game class includes three private members. These are:\n\n```cpp\nsf::RenderWindow* window;  // Pointer to the render window used to draw to the screen\nsf::VideoMode videoMode;   // Contains the resolution\nsf::Event event;           // Used to store the value of events when `pollEvents` is called\n```\n\n#### Update and Draw\nThis is the same as most games you'll find. Just put your update logic in `update()`, and your drawing logic in `draw()`. \n\n```cpp\nvoid Game::update() {\n    pollEvents();\n\n    // TODO: Add update logic here\n}\n\nvoid Game::render() {\n    window-\u003eclear(sf::Color::Black);\n\n    // TODO: Add drawing code here\n\n    window-\u003edisplay();\n}\n```\n\n#### Init Methods\nHere you'll find methods to set up the window and other variables. The usual event polling code you'd find in an SFML project is placed within `pollEvents` for organisation.\n\n```cpp\nvoid Game::initVariables() {\n    window = nullptr;  // It's always good to initialize your variables\n}\n\nvoid Game::initWindow() {\n    // You can change the window settings here, such as the title and resolution\n    videoMode = sf::VideoMode(800, 600);\n    window = new sf::RenderWindow(videoMode, \"Game\", sf::Style::Titlebar | sf::Style::Close);\n}\n\nvoid Game::pollEvents() {\n    // You can change or add events here, such as player input\n    while (window-\u003epollEvent(event)) {\n        if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))\n            window-\u003eclose();\n    }\n}\n```\n\n#### Accessors\nGame has an accessor that returns a bool indicating if the window is open. This is used in `main.cc`.\n\n```cpp\nconst bool Game::running() const {\n    return window-\u003eisOpen();\n}\n```\n\n#### Constructor and Destructor\nGame also includes a constructor and destructor. Do **not** remove the `delete window` statement, as `window` is dynamically allocated.\n\n```cpp\nGame::Game() {\n    initVariables();\n    initWindow();\n}\n\nGame::~Game() {\n    delete window;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv0idzdev%2Fsfml-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv0idzdev%2Fsfml-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv0idzdev%2Fsfml-template/lists"}