Skip to content

Instantly share code, notes, and snippets.

@kuujoo
kuujoo / flags.h
Created August 9, 2022 19:25
Use enum class for flags
// Usage:
// collision::Mask m = collision::Mask::JumpThrough | collision::Mask::Solid;
//
// if ( (m & collision::Mask::Solid) != 0)
// {
// ....
// }
//
namespace collision
@kuujoo
kuujoo / EnumSelector.cs
Last active July 16, 2022 17:52
ImGui enum selector in C#
public static class ImGuiUtils
{
static bool EnumSelector<T>(string name, int idOffset, ref T selection)
{
bool change = false;
int idx = idOffset;
var enumType = typeof(T);
if (ImGui.BeginCombo(name, Enum.GetName(enumType, selection)))
{
var enumValues = Enum.GetValues(enumType);
@kuujoo
kuujoo / action.h
Last active October 15, 2021 19:08
C# Style actions in C++
/**
pxl::Action<int, int, bool> a;
a += [](int p0, int p1, bool p3)
{
};
auto id = a.bind([](int p0, int p1, bool p3)
{