Skip to content

Instantly share code, notes, and snippets.

@seanh
seanh / gist:1219425
Created September 15, 2011 14:44
Computing the "full bounding box" of a CCNode in Cocos2D. (Put this code in a CCNode subclass.)
/*!
Return the -boundingBox of another node, converted into this node's local
coordinate space.
*/
-(CGRect) boundingBoxConvertedToNodeSpace:(CCNode *)other
{
// Get the bottomLeft and topRight corners of the other node's bounding box
// in the other node's coordinate space.
CGRect boundingBox = [other boundingBox];
CGPoint bottomLeft = CGPointMake(boundingBox.origin.x, boundingBox.origin.y);
@pingec
pingec / PokemonCP.md
Last active August 6, 2016 18:13
Pokemon CP, IV etc,

Let's say we have 2 pokemons of the same type. Their CP will depend on the following values:

  • IV (IndividualStamina, IndividualAttack, IndividualDefense)
  • CpMultiplier
  • AdditionalCpMultiplier

These values, together with move types, weight, height are what makes your pokemon unique.

Mechanisms that change these values:

@jonathan-beebe
jonathan-beebe / alasset_to_phasset.swift
Created July 18, 2015 16:26
Convert ALAsset to iOS8+ PHAsset
import Photos
import AVFoundation
func ALAssetToPHAsset(asset:ALAsset) -> PHAsset {
var fetchOptions: PHFetchOptions = PHFetchOptions()
var url:NSURL = asset.valueForProperty(ALAssetPropertyAssetURL) as! NSURL
let fetchResult:PHFetchResult = PHAsset.fetchAssetsWithALAssetURLs([url], options: fetchOptions)
return fetchResult.firstObject as! PHAsset
}
@AndreiRudenko
AndreiRudenko / SpatialHash.hx
Last active May 13, 2019 19:01
SpatialHash uniform-grid implementation
// SpatialHash uniform-grid implementation
// Broad-phase algorithm for collision detection
// Andrei Rudenko // SpatialHash.hx (24.07.2016)
import luxe.Vector;
import luxe.utils.Maths;
class SpatialHash {
public var min(default, null):Vector;
@paniq
paniq / twistpool.c
Last active August 28, 2019 22:17
Twisting Pool Allocator
/*
Twisting Pool Allocator
=======================
written by Leonard Ritter (leonard.ritter@duangle.com)
This file is in the public domain
I don't know if I was the first one to stumble upon this technique, so
I can't guarantee there's no patent on it, but let's hope there's not,
use std::path::PathBuf;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::thread;
use std::os::raw::c_void;
use std::rc::Rc;
use std::cell::{Cell, RefCell};
use std::i16;
use std::time::Instant;
use failure::{err_msg, Error};
@vurtun
vurtun / api.md
Last active August 6, 2020 06:40
API Design: Modular Data-oriented processes

API Design: Modular Data-oriented processes (June-2017)

This is the second entry in my series about API design. While I wrote about granularity and request based APIs in my last post I want to write about API design and code architecture for modular data-oriented process this time. This is basically the write up of my findings while writing and finishing the core of my current GUI research quarks.

Actually sparking my interest for writing up my findings however was rasmusbarr@github (rasmusbarr@twitter) releasing his small data-oriented and SIMD-optimized 3D rigid body physics library. I noticed a lot of overlap in design between his physics and my GUI library and wanted to write up some general thoughts about what seems

@floooh
floooh / cmake_funcs.txt
Last active September 26, 2020 21:51
Fips generator example to copy files during build process
To invoke the generator from the cmake target you should define a helper macro in you project root's "fips-include.cmake" file:
macro(copy_files yml_file)
fips_generate(FROM ${yml_file}
TYPE filecopy
OUT_OF_SOURCE
ARGS "{ deploy_dir: \"${FIPS_PROJECT_DEPLOY_DIR}\" }")
endmacro()
In your cmake target definition you would then use this like:
@slime73
slime73 / sdl-metal-example.m
Last active September 9, 2021 10:53
SDL + Metal example
/**
* This software is in the public domain. Where that dedication is not recognized,
* you are granted a perpetual, irrevokable license to copy and modify this file
* as you see fit.
*
* Requires SDL 2.0.4.
* Devices that do not support Metal are not handled currently.
**/
#import <UIKit/UIKit.h>
@vurtun
vurtun / Library writing.txt
Created September 12, 2016 11:20
Library writing
LIBRARY WRITING REFERENCE LIST
===============================
1.) Designing and Evaluating Reusable Components (Casey Muratori: http://mollyrocket.com/casey/stream_0028.html)
----------------------------------------------------------------------------------------------------------------
_THE_ reference on API design up to this day on the internet. Nobody should write a library without having seen this.
I come back to this talk every N number of weeks it is that good.
2.) stb_howto (Sean Barrett: https://github.com/nothings/stb/blob/master/docs/stb_howto.txt)
--------------------------------------------------------------------------------------------
Sean Barretts single header libraries (https://github.com/nothings/stb) was the first time for me that I came across