Skip to content

Instantly share code, notes, and snippets.

View stillwwater's full-sized avatar

Lucas stillwwater

  • Microsoft
  • Canada
View GitHub Profile
spacing=1
id=1
nodes={}
rects={}
parent=nil
child=nil
function setpos(node)
local d=0
local p=node.p
@stillwwater
stillwwater / benchmark.h
Last active September 16, 2022 03:07
c++ benchmark library
// Copyright 2022 stillwwater@gmail.com
//
// Permission to use, copy, modify, and/or distribute this software for
// any purpose with or without fee is hereby granted, provided that the
// above copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
// AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
#define DEFER_CAT_(A, B) A ## B ## _
#define DEFER_CAT(A, B) DEFER_CAT_(A, B)
template <typename Func>
struct Defer {
Func fn;
Defer(Func fn_) : fn(fn_) {}
~Defer() { fn(); }
};
@stillwwater
stillwwater / test.h
Last active April 29, 2023 03:05
C/C++ test library
// Copyright (c) 2023 stillwwater@gmail.com
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
@stillwwater
stillwwater / pixelperfect.c
Created August 16, 2021 06:55
Pixel perfect camera in SDL2
#include "SDL.h"
#include "stb/stb_image.h"
#define CAMERA_BORDER 1
typedef struct {
SDL_Renderer *renderer;
SDL_Texture *target;
int width;
@stillwwater
stillwwater / export-atlas.lua
Created December 21, 2020 02:59
Aseprite exporter for texture atlas files
------------------------------------------------------------------------
-- Export texture atlas file format
--
-- The file format is as follows:
--
-- # version VERSION_NUMBER
-- # ASEPRITE_FILE
-- i IMAGE_FILE NUMBER_OF_FRAMES
-- s SPRITE_X SPRITE_Y SPRITE_W SPRITE_H SPRITE_PIVOT_X SPRITE_PIVOT_Y
-- a ANIM_NAME ANIM_START ANIM_END ANIM_DIRECTON ANIM_FRAME_TIME_SECONDS
" _
" (_)
" __ ___ _ __ ___ _ __ ___
" \ \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" (_)_/ |_|_| |_| |_|_| \___|
"
syntax on
set mouse=a " :O
@stillwwater
stillwwater / Pool.cs
Last active July 16, 2020 02:36
Better GameObject Pooling In Unity
using System.Collections.Generic;
using UnityEngine;
class Pool<T> where T : Component
{
readonly List<T> pool;
readonly T prefab;
readonly Transform parent;
int id;
@stillwwater
stillwwater / nebula-dark-term
Created April 24, 2020 07:35
Terminal colors for vim-nebula
! vim-nebula terminal colors
! theme
*.cursorColor: #c9cbd1
*.foreground: #c9cbd1
*.background: #0a121d
! black
*.color0: #273845
*.color8: #273845
@stillwwater
stillwwater / var2ini.pas
Created July 18, 2018 01:44
Converts .var files to INI, YAML, or .var with stripped comments.
{
Converts .var files to INI, YAML, or .var with stripped comments.
input:
"""
This string documents
the file.
"""
:name
key value # this is a comment