{"id":13731337,"url":"https://github.com/dabbertorres/Swift2","last_synced_at":"2025-05-08T04:33:08.232Z","repository":{"id":18793785,"uuid":"22007595","full_name":"dabbertorres/Swift2","owner":"dabbertorres","description":"A SFML-backed game framework.","archived":false,"fork":false,"pushed_at":"2015-11-16T01:03:54.000Z","size":22816,"stargazers_count":8,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-14T11:48:25.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"angular/bower-angular-i18n","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dabbertorres.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}},"created_at":"2014-07-19T10:42:32.000Z","updated_at":"2019-09-20T21:27:35.000Z","dependencies_parsed_at":"2022-07-26T23:46:08.802Z","dependency_job_id":null,"html_url":"https://github.com/dabbertorres/Swift2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FSwift2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FSwift2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FSwift2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FSwift2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dabbertorres","download_url":"https://codeload.github.com/dabbertorres/Swift2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224702315,"owners_count":17355533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-08-03T02:01:27.685Z","updated_at":"2024-11-14T22:30:59.795Z","avatar_url":"https://github.com/dabbertorres.png","language":"C++","readme":"# Swift2\nGame framework powered by SFML, OpenGL, Lua, and tinyxml2\n\n# To Use\nCreate a new class, and publically inherit from swift::Game.\n\nYou'll need to call swift::Game's constructor with 2 arguments, the first, the title of your game.\nThe second, the engine ticks per second you want your game to run at. This is essentially the \"updates per second\".\n\nThen, you'll have to implement a few functions:\n```c++\nvoid start(int c, char** argv);\nvoid loadAssets();\nvoid loadMods();\nvoid initState();\nvoid initScripting();\n```\n\nHere's a few examples of these functions:\n```c++\nclass MyGame: public swift::Game\n{\n\tMyGame() : Game(\"My Game\", 30)\n\t{}\n\n\tvoid start(int c, char** args)\n\t{\n\t\t// give the path to your settings file here.\n\t\t// virtual function, in case you want to handle or add settings\n\t\tloadSettings(\"./data/settings.ini\");\n\n\t\t// does what it says it does.\n\t\t// virtual as well\n\t\thandleLaunchOps(c, args);\n\n\t\t// give the path to your dictionary of choice.\n\t\t// If you're only supporting one language, go ahead and give a direct path\n\t\t// otherwise, the 'language' string will be set via the loadSettings function\n\t\tdictionary.loadFile(\"./data/dictionaries\" + language + \".dic\");\n\n\t\t// loads your asset folders.\n\t\t// pure virtual\n\t\tloadAssets();\n\n\t\t// loads mods in your mod folder\n\t\t// pure virtual\n\t\tloadMods();\n\n\t\t// grab your favorite font that was loaded earlier in loadAssets()\n\t\tdefaultFont = *assets.getFont(\"./data/fonts/segoeuisl.ttf\");\n\n\t\t// pretty simple, sets up the window, based off of settings.\n\t\tsetupWindow();\n\n\t\t// starts up the state system\n\t\tinitState();\n\n\t\t// starts up the scripting system\n\t\tinitScripting();\n\t}\n\n\tvoid TheGame::loadAssets()\n\t{\n\t\tassets.setSmooth(smoothing);\n\t\tassets.loadResourceFolder(\"./data/anims\");\n\t\tassets.loadResourceFolder(\"./data/textures\");\n\t\tassets.loadResourceFolder(\"./data/fonts\");\n\t\tassets.loadResourceFolder(\"./data/music\");\n\t\tassets.loadResourceFolder(\"./data/scripts\");\n\t\tassets.loadResourceFolder(\"./data/sounds\");\n\t\t\n\t\t// make log file a little prettier\n\t\tswift::log \u003c\u003c '\\n';\n\t}\n\t\n\tvoid TheGame::loadMods()\n\t{\n\t\t// find all mods\n\t\tmods.loadMods(\"./data/mods\");\n\n\t\t// this would be where you normally conditionally load up mods\n\t\tfor(auto\u0026 m : mods.getMods())\n\t\t{\n\t\t\tassets.loadMod(m.second.mod);\n\t\t}\n\t}\n\t\n\tvoid TheGame::initState()\n\t{\n\t\t// state setup\n\t\tstates.push(new GameMenu(window, assets, soundPlayer, musicPlayer, settings, dictionary, states));\n\t}\n\t\n\tvoid TheGame::initScripting()\n\t{\n\t\tGameScript::setAssetManager(assets);\n\t\tGameScript::setClock(GameTime);\n\t\tGameScript::setWindow(window);\n\t\tGameScript::setSettings(settings);\n\t\tGameScript::setKeyboard(keyboard);\n\t}\t\n};\n```\n\nNot too bad, eh? Well, at least I don't think so. Of course, you can just modify everything anyways if you need something special.\n\nAfterwards, get a main function going that looks something like this:\n```c++\n#include \"MyGame.hpp\"\n\nint main(int argc, char** argv)\n{\n\tMyGame game;\n\n\tgame.start();\n\n\tgame.gameLoop();\n\n\treturn 0;\n}\n```\n\nCompile, link, run, and it should work! Mostly, that is. Won't do too much though. \n\nFrom there, to add actual functionality and State to your game, you'll need to inherit from swift::State, to create different States for your game to be in, if you want Lua Scripting support, inherit from swift::AssetManager and swift::Script, and to make a \"World\" for your game to happen in, inherit from swift::World. I'll add more examples for those soon!\n\nThen, at that point, it's (almost) time to create content and code your game! Woo!\n","funding_links":[],"categories":["Engines"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabbertorres%2FSwift2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabbertorres%2FSwift2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabbertorres%2FSwift2/lists"}