Skip to content

Instantly share code, notes, and snippets.

View eXpl0it3r's full-sized avatar

Lukas Dürrenberger eXpl0it3r

View GitHub Profile
@eXpl0it3r
eXpl0it3r / PausableClock.cpp
Created August 26, 2023 17:03
Pausable Clock
#include <SFML/Graphics.hpp>
class PausableClock
{
sf::Clock m_clock;
sf::Time m_elapsed;
bool m_isRunning = false;
float m_skewFactor = 1.f;
public:
@eXpl0it3r
eXpl0it3r / MessageBus01.cpp
Created December 3, 2022 12:40
A game engine designed by OpenAI
#include <bits/stdc++.h>
using namespace std;
// Entity class
class Entity
{
public:
// List of components associated with the entity
vector<class Component *> components;
#include <SFML/Window.hpp>
#include <iostream>
#include <Windows.h>
LONG_PTR originalsfmlcallback = 0x0;
LRESULT CALLBACK mycallback(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_DROPFILES)
{
find_package(zlib)
if (NOT zlib_FOUND)
message("Fetch zlib content instead...")
include(FetchContent)
FetchContent_Declare(
zlib
GIT_REPOSITORY "https://github.com/madler/zlib.git"
GIT_TAG "v1.2.11"
)
@eXpl0it3r
eXpl0it3r / main.cpp
Last active January 8, 2023 18:02
How to center SFML sf::Text objects
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
auto window = sf::RenderWindow{{800, 600, 32}, "SFML Window"};
window.setFramerateLimit(60);
auto font = sf::Font{};
if (!font.loadFromFile("OpenSans.ttf"))
@eXpl0it3r
eXpl0it3r / CMakeLists.txt
Created May 28, 2020 19:05
sfeMovie SFML 2.5 CMake Migration
cmake_minimum_required (VERSION 2.8.12)
# set a default build type if none was provided
# this has to be done before the project() instruction!
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
endif()
@eXpl0it3r
eXpl0it3r / StreamLogger.hpp
Last active June 21, 2023 23:48
Redirect Stream to spdlog Logger
#include <streambuf>
#include <ostream>
#include "spdlog/spdlog.h"
template<class Element = char, class Trait = std::char_traits<Element>>
class StreamLogger : public std::basic_streambuf<Element, Trait>
{
public:
StreamLogger(std::ostream& stream, std::shared_ptr<spdlog::logger> logger)
@eXpl0it3r
eXpl0it3r / client.cpp
Last active May 27, 2020 22:15
SFML UDP Server & Client
#include <SFML/Network.hpp>
#include <iostream>
#include <csignal>
#include <atomic>
#include <string>
using namespace std::string_literals;
namespace
{
@eXpl0it3r
eXpl0it3r / main.cpp
Last active January 14, 2019 19:50
SFML Cursor API
#include <SFML/Graphics.hpp>
struct Cursor
{
Cursor() :
changed{ false },
current{ sf::Cursor::Arrow }
{
arrow.loadFromSystem(sf::Cursor::Arrow);
hand.loadFromSystem(sf::Cursor::Hand);
@eXpl0it3r
eXpl0it3r / main.cpp
Created November 12, 2018 13:03
test
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window{ { 1280, 720 }, "Test"};
window.setFramerateLimit(60);
while(window.isOpen())
{
sf::Event event;