{"id":17961672,"url":"https://github.com/expl0it3r/examples","last_synced_at":"2025-03-25T04:31:17.081Z","repository":{"id":4804612,"uuid":"5957937","full_name":"eXpl0it3r/Examples","owner":"eXpl0it3r","description":"Smaller or bigger examples that I've written or will write in the future in C++.","archived":false,"fork":false,"pushed_at":"2024-01-23T08:19:05.000Z","size":343,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T08:48:18.306Z","etag":null,"topics":["examples","hacktoberfest","sfml","zlib"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eXpl0it3r.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}},"created_at":"2012-09-25T23:01:32.000Z","updated_at":"2025-02-03T16:11:29.000Z","dependencies_parsed_at":"2023-07-05T20:03:26.024Z","dependency_job_id":null,"html_url":"https://github.com/eXpl0it3r/Examples","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/eXpl0it3r%2FExamples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXpl0it3r%2FExamples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXpl0it3r%2FExamples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXpl0it3r%2FExamples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eXpl0it3r","download_url":"https://codeload.github.com/eXpl0it3r/Examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245401360,"owners_count":20609161,"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":["examples","hacktoberfest","sfml","zlib"],"created_at":"2024-10-29T11:10:04.695Z","updated_at":"2025-03-25T04:31:17.047Z","avatar_url":"https://github.com/eXpl0it3r.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Examples\n\nEvery now and then I sit down and try out some features of some library, C++ itself or with SFML.\nInstead of letting those code fragments go to waste somewhere on my disk or get lost in the depth\nof the SFML forum, I decided to put them openly and centralized here on GitHub for everyone to see,\nshare and learn from them.\n\nKeep in mind that the code is provided as-is and isn't necessarily suited for your final product,\nas not a lot of thought was put into performance or code design.\n\n## zlib\n\n### [gzip Decompression](https://github.com/eXpl0it3r/Examples/blob/master/zlib/GzipDecompression.cpp)\n\nzlib is a small and useful library which allows the compression and decompression of data.\nBy applying some settings it's possible to let zlib decompress a gzip file, which this examples\ndemonstrates by loading a file into memory and output the decompressed data to standard output.\n\n## SFML\n\n### [Center Text](https://github.com/eXpl0it3r/Examples/blob/master/SFML/CenterText.cpp)\n\nOne of the most common questions you'll run into on the SFML forum is how to center a `sf::Text`\nobject inside a shape, or more commonly, a button. Because `sf::Text` aligns itself to the baseline\ninstead of the visual top/bottom, it tends to be more confusing that working with shapes and\nsprites. In order to get it working properly, you have to take into account the `LocalBounds` as\nis shown in the given example.\n\n![Center Text](https://i.imgur.com/J1xQNzm.png)\n\n### [Fading Dots](https://github.com/eXpl0it3r/Examples/blob/master/SFML/FadingDots.cpp)\n\nThis was originally created as a test for [this thread](https://en.sfml-dev.org/forums/index.php?topic=9350.0)\n(or was it [this one](https://en.sfml-dev.org/forums/index.php?topic=9139.0)?), but since I kind of\nliked the result I adjusted a few things and uploaded it.\n\n![Fading Dots](https://i.imgur.com/7UZEi3s.png)\n\n### [Flashlight](https://github.com/eXpl0it3r/Examples/blob/master/SFML/Flashlight.cpp)\n\nOut of nowhere came suddenly all those requests (starting with [this one](https://en.sfml-dev.org/forums/index.php?topic=9210.0))\nfor subjective blending and I think, I could help a few people with my example on how to achieve\nwhat they wanted.\n\n![Flashlight 1](https://i.imgur.com/B6g0Ba5.png) ![Flashlight 2](https://i.imgur.com/N7xn8v6.png)\n\n### [Hue Shift](https://github.com/eXpl0it3r/Examples/blob/master/SFML/HueShift.cpp)\n\nAlthough I can't find the original SFML thread about this, I found the\n[StackOverflow question](https://stackoverflow.com/questions/11458552/cycle-r-g-b-vales-as-hue/)\nwhich was IIRC created before the forum thread. This effect can definitely give a nice ambiance,\nbut it probably could need some retouching. Since the picture do not tell much: Starting off with\none color the example automatically iterates through the whole RGB color spectrum in a smooth way.\n\n![Hue Shift](https://i.imgur.com/3PSekfp.gif)\n\n### [Lightning](https://github.com/eXpl0it3r/Examples/tree/master/SFML/Lightning)\n\nI had once read a tutorial in connection with SFML on how to create some nice 'laser' effect.\nUnfortunately I don't remember which blog/site this was on, because he was using some texture\nmoving which made everything look even better. While doing a search to possible find that tutorial\nagain, I found another similar piece of code [on the forum](https://en.sfml-dev.org/forums/index.php?topic=3189.0),\nadapted it for SFML 2 and made a nicer class out of it.\n\n![Lightning](https://i.imgur.com/XJdze9h.png)\n\n### [Mixing SoundBuffers](https://github.com/eXpl0it3r/Examples/blob/master/SFML/MixingSoundBuffers.cpp)\n\nThe other day in #learnprogramming on freenode someone was trying to implement a way to mix two\naudio files without actually playing them back. I wondered how something like that would work with\nSFML and thus went ahead an wrote a small example. A quick Google search on audio sample mixing\nbrought me to [this site](https://atastypixel.com/how-to-mix-audio-samples-properly-on-ios/)\nand lead me to the current implementation.\n\n### [Road](https://github.com/eXpl0it3r/Examples/blob/master/SFML/Road.cpp)\n\nI'm not sure if there ever existed a forum post or if the whole conversation happened on IRC,\nbut someone wanted to make a 'scrolling' road and since I really liked that idea, I went ahead\nand implemented an example. The code here is particularly not that nice, so keep that in mind\nwhen adapting it.\n\n![Road](https://i.imgur.com/3dtHMNk.png)\n\n### [Rotating Triangle](https://github.com/eXpl0it3r/Examples/blob/master/SFML/RotatingTriangle.cpp)\n\nOne of the age old questions by game development beginners is along the lines of \"How do I rotate\nmy player to face X?\". This short example answers that question, by rotating a triangle\n(`sf::CircleShape` with three points) to wherever the mouse pointer is on the window.\n\n![Rotating Triangle](https://i.imgur.com/ntONvU2.png)\n\n### [Rotating Vertices](https://github.com/eXpl0it3r/Examples/blob/master/SFML/RotatingVertices.cpp)\n\nThis example answers the same question as the 'Rotating Triangle' one, but it uses a `sf::VertexArray`\nin combination with a `sf::Transformable`. It's a good foundation to see how one could start to\nimplement an entity class deriving from `sf::Transformable` and `sf::Drawable`.\n\n![Rotating Vertices](https://i.imgur.com/cvmMryW.png)\n\n### [Simple AABB](https://github.com/eXpl0it3r/Examples/blob/master/SFML/SimpleAABB.cpp)\n\nEvery month there's at least one question on simple collision detection testing the last 'bigger'\none with in [this forum thread](https://en.sfml-dev.org/forums/index.php?topic=9352.0), which\nlead to this example. I've even implemented some _very_ simple physics, which will fail in most\nsituations, but you can at least move around and jump.\n\n![AABB](https://i.imgur.com/imYEzXa.png)\n\n### [Sound Recording](https://github.com/eXpl0it3r/Examples/blob/master/SFML/SoundRecording.cpp)\n\nEven though SFML has a [tutorial](https://www.sfml-dev.org/tutorials/2.5/audio-recording.php)\nand an [example](https://github.com/SFML/SFML/tree/master/examples/sound_capture) on sound\nrecording, I wanted to have my own small demonstration of said feature with recording device\nselection and mono/stereo options.\n\n## License\n\nAll examples are under the zlib/png license and thus free to use. See the\n[LICENSE](https://github.com/eXpl0it3r/Examples/blob/master/LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpl0it3r%2Fexamples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpl0it3r%2Fexamples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpl0it3r%2Fexamples/lists"}