Skip to content

Instantly share code, notes, and snippets.

Avatar

zloedi zloedi

  • Sofia Bulgaria
View GitHub Profile
@zloedi
zloedi / minimal size mingw exe example Makefile
Last active Mar 20, 2021
mingw minimal windows exe using SDL (exe size ~9K)
View minimal size mingw exe example Makefile
# Thanks goes to https://nullprogram.com/blog/2016/01/31/ -- Small, Freestanding Windows Executables
no_crt.exe: main.c
x86_64-w64-mingw32-gcc -o no_crt.exe main.c -pedantic-errors \
-std=c99 -Wall -Wextra \
-O3 \
-fno-tree-loop-distribute-patterns \
-fno-stack-protector -mno-stack-arg-probe \
-mconsole -DM_CONSOLE \
-I/usr/local/x86_64-w64-mingw32/include \
`sdl2-config --static-libs` \
@zloedi
zloedi / minilist.h
Last active Aug 27, 2020
Single header C library to turn your buffer into a generic doubly linked list, by sacrificing the first few elements. Provides some typesafety through the ML_Add() macro.
View minilist.h
// Copyright (c) 2020 Stoiko Todorov
// This work is licensed under the terms of the MIT license.
// For a copy, see https://opensource.org/licenses/MIT.
// This lib turns an array into a linked list by sacrificing the first
// few elements of the array
#ifndef ML_TYPE
// by default max numItems is 65535, redefine ML_TYPE if needed
#define ML_TYPE unsigned short
@zloedi
zloedi / nav_flood.h
Created Oct 5, 2019
Tiny single header flood fill pathfinder
View nav_flood.h
// #define FLOOD_NAV_IMPLEMENTATION before #include "nav_flood.h" to unwrap the implementation
// #define NAV_FOUR_WAY before #include "nav_flood.h" for four-way flood implementation
#define NAV_FREE 0x0fffffff
#define NAV_BLOC 0x40000000
// Internal struct used to hold flood front
typedef struct {
int capMask;
int *buf;
@zloedi
zloedi / DebugExtensions.cs
Last active Apr 5, 2019
Unity Debug.DrawImage and Debug.DrawText routines in single file/static class.
View DebugExtensions.cs
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
public static class DebugEx
{
public static float CharactersOffset = -4;
@zloedi
zloedi / roguelike_FOV.c
Last active Aug 6, 2021
Efficient roguelike grid FOV / shadowcasting / line of sight in a single C function inspired by https://docs.microsoft.com/en-us/archive/blogs/ericlippert/shadowcasting-in-c-part-one
View roguelike_FOV.c
// Copyright (c) 2021 Stoiko Todorov
// This work is licensed under the terms of the MIT license.
// For a copy, see https://opensource.org/licenses/MIT.
// What this function does:
// Rasterizes a single Field Of View octant on a grid, similar to the way
// field of view / line of sight / shadowcasting is implemented in some
// roguelikes.
// Uses rays to define visible volumes instead of tracing lines from origin
// to pixels.