Skip to content

Instantly share code, notes, and snippets.

View eXpl0it3r's full-sized avatar

Lukas Dürrenberger eXpl0it3r

View GitHub Profile
@eXpl0it3r
eXpl0it3r / Program.cs
Last active June 28, 2024 12:40
SFML.Net Mouse Behavior Test
using SFML.Graphics;
using SFML.System;
using SFML.Window;
var window = new RenderWindow(new VideoMode(800, 600), "SFML Test", Styles.None);
window.SetFramerateLimit(30);
var font = new Font("C:/Windows/Fonts/Arial.ttf");
var text = new Text();
@eXpl0it3r
eXpl0it3r / VisualSound.cpp
Last active April 27, 2024 17:33
VisualSound with SFML
#include <deque>
#include <mutex>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
class MusicVisualizer : public sf::Music, public sf::Drawable
{
public:
void update(const sf::Time& deltaTime);
@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
{