This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T, int N> | |
class AnonymousPool { | |
private: | |
uint32_t mCount; | |
T mRecords[N]; | |
public: | |
AnonymousPool() : mCount(0) { | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
// CustomBehaviour is just a trivial subclass of MonoBehaviour with a bunch | |
// of static finger-friendly helper-functions :P | |
public class PooledObject : CustomBehaviour { | |
// subclass this to treat a behaviour as the basis | |
// of a poolable object. Stores simple metadata | |
// related to pooling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float u = clamp(player.deathCountdown/PLAYER_DEATH_SECONDS); | |
u = 1.f - easeOut4(1.f - u); | |
setTransform(translationMatrix(vec( | |
8.f * sinf(7.f * M_TAU * u), | |
16.f* cosf(13.f * M_TAU * u) | |
))); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
// Is this mad? The idea is to make a "slot" for an object but have manual initialization/finalization, | |
// rather than being constrained to C++'s semantics. Useful, e.g., in Object Pools. Is there a simpler | |
// way to get this effect? | |
template<typename T> | |
union Slot { | |
T inst; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import random | |
nonSwitcherMoney = 0 | |
switcherMoney = 0 | |
def random_amount_of_money(): return 1 + 999 * random.random() | |
def coin_flip(): return random.random() > 0.5 | |
# do a million trials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "GameBase.h" | |
// Event Book Pool - Apply this to any pool that implements the alloc/release contract | |
// to have it automatically call enable/disable methods just before the first slot is allocated | |
// and just after the last slot is released. | |
template<typename T> | |
class EventHookPool : public T { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using Dbg = System.Diagnostics.Debug; | |
public class PoolingExample : MonoBehaviour { | |
PoolingExample next; | |
PoolingExample prefab; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Little Polygon/Sprites (Lerp)" | |
{ | |
Properties | |
{ | |
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} | |
_Color ("Tint", Color) = (1,1,1,1) | |
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0 | |
} | |
SubShader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <iostream> | |
#include <iomanip> | |
#define DECLARE_HAS_MEMBER(member) \ | |
\ | |
template < class T > \ | |
class HasMember_##member \ | |
{ \ | |
private: \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<typename T> | |
size_t numeric_handle() { | |
static int x; | |
return (size_t)(&x); | |
} | |
int main(int argc, char* argv[]) { | |
using namespace std; |
OlderNewer