Skip to content

Instantly share code, notes, and snippets.

View MarioLiebisch's full-sized avatar

Mario Liebisch MarioLiebisch

View GitHub Profile
@MarioLiebisch
MarioLiebisch / Win32 Clipboard access
Created September 3, 2014 14:55
Snippet from a custom SFML extension for direct clipboard access.
////////////////////////////////////////////////////////////
ClipboardImpl& ClipboardImpl::operator >> (sf::String& data)
{
data = "";
if (!OpenClipboard(NULL))
return *this;
if (IsClipboardFormatAvailable(CF_UNICODETEXT))
{
@MarioLiebisch
MarioLiebisch / CMakeLists.txt
Last active August 20, 2018 08:46
A minimal CMakeLists.txt file for a SFML project
cmake_minimum_required(VERSION 3.10)
project(my_sfml_project)
# Find SFML and the given components
find_package(SFML 2.5 COMPONENTS graphics window system)
# Add the SFML include dir
include_directories(${SFML_INCLUDE_DIR})
@MarioLiebisch
MarioLiebisch / outline.cpp
Created December 22, 2014 16:09
SFML Wall Drawing Example
#include <SFML/Graphics.hpp>
#include <vector>
struct wall {
float x1, y1, x2, y2;
wall(float x1, float y1, float x2, float y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
@MarioLiebisch
MarioLiebisch / gist:e7b5202db7387b3a9698
Created June 5, 2015 09:58
Basic Procedural Dungeon Generation (e.g. for Rougelikes)

#Basic Procedural Random Dungeon Generation

  • Create one set holding used rooms.
  • Create one set holding open ends.
  • Place a random room, add it two both sets and flag it as the entrance.
  • Repeat as long as you don't have your intended number of rooms:
    • Randomly pick a used room ("current room").
    • Pick a random direction.
    • If the chosen direction is the border of the map, continue the loop.
  • Remove the current room from the open ends.
@MarioLiebisch
MarioLiebisch / .htaccess
Created November 10, 2015 18:49
Redirect all http traffic to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/https/
RewriteCond %{SCRIPT_NAME} !^/https/
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
@MarioLiebisch
MarioLiebisch / getnumbered.cmd
Created November 24, 2015 18:52
Windows batch: Get the next free numbered file name
@echo off
REM Initialize the first/lowest number
set NUMBER=0
REM Jump point: return here if the current file exists
:LOOP
REM Leave the loop in case the file doesn't exist
if not exist backup-%NUMBER%.zip goto DONE
REM Increment the counter
set /a NUMBER+=1
@MarioLiebisch
MarioLiebisch / main.cpp
Created May 21, 2016 11:07
Simple SFML Game class
#include <SFML/Graphics.hpp>
class Game {
private:
// Add all your variables you need, your "globals".
sf::RenderWindow window;
sf::Texture texture;
sf::Sprite sprite;
unsigned int lives;
// ...
@MarioLiebisch
MarioLiebisch / parallaxShader.cpp
Created July 17, 2016 19:17
SFML Example to render a repeated parallax background using a vertex shader for movement.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Parallax Example",
sf::Style::Titlebar | sf::Style::Close);
window.setVerticalSyncEnabled(true);
sf::Texture texture;
if (!texture.loadFromFile("resources/background.jpg"))
@MarioLiebisch
MarioLiebisch / parallaxShaderF.cpp
Created July 18, 2016 08:47
Drawing a parallax background using a fragment shader.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1024, 768), "Parallax Example",
sf::Style::Titlebar | sf::Style::Close | sf::Style::Fullscreen);
window.setVerticalSyncEnabled(true);
sf::Texture texture;
// This is a texture 1024x1024 with three backgrounds stacked one over the other from front to back
@MarioLiebisch
MarioLiebisch / run.cmd
Created November 30, 2016 11:32
A quick and simple batch file to run small tests using SFML. Just execute `run <name>` where `<name>´ is the base name of your cpp file.
@echo off
cls
g++ -o %1.exe %1.cpp -std=c++11 -static-libstdc++ -static-libgcc -DSFML_STATIC -lsfml-network-s -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lwinmm -lopengl32 -lgdi32 -ljpeg -lws2_32 && %1