Skip to content

Instantly share code, notes, and snippets.

@jonbro
jonbro / .gitignore
Created November 4, 2014 21:18
unity .gitignore
*.sln
*.userprefs
*.csproj
*.pidb
*.unityproj
.DS_Store
/Library/FailedAssetImports.txt
/Library/cache/
/Library/previews/
/Library/ScriptAssemblies
@jonbro
jonbro / gist:beee59cbbf0475234dd0
Created November 5, 2014 23:16
propertydrawereditor
// C# example.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomPropertyDrawer(typeof(ActionInput))]
public class ActionInputDrawer : PropertyDrawer {
public int rows = 1;
// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
[Serializable]
public class ActionInput{
public enum ActionType
{
ENTER_TRIGGER,
EXIT_TRIGGER,
STAY_TRIGGER,
OBJECT_ACTIVE,
PRESS_KEY
}
@jonbro
jonbro / readme.txt
Last active August 29, 2015 14:12 — forked from anonymous/readme.txt
Play this game by pasting the script in http://www.???.com/editor.html
void fill_audio(void *udata, Uint8 *stream, int len)
{
int fLen = len/sizeof(float);
/* Mix as much data as possible */
// copy the output to the stream
for(int i=0;i<fLen;i+=2){
// =======================
//
// my c code goes here
import snow.platform.native.audio.openal.SoundStream;
import snow.audio.Audio;
import snow.types.Types;
import snow.io.typedarray.Uint8Array;
import snow.io.typedarray.Float32Array;
import snow.Log;
import luxe.Input;
class Main extends luxe.Game {
@jonbro
jonbro / gist:9fd4772a14d786486e9b
Last active August 29, 2015 14:17
generative audio in luxe/snow
import snow.platform.native.audio.openal.SoundStream;
import snow.audio.Audio;
import snow.types.Types;
import snow.io.typedarray.Uint8Array;
import snow.io.typedarray.Uint16Array;
import snow.io.typedarray.Int16Array;
import snow.io.typedarray.Float32Array;
import snow.Log;
import luxe.Rectangle;
void lipsynth_module_sine_update(void *self, lipsynth_context *ctx, lipsynth_AudioMemory *outputBuffer){
lipsynth_module_sine* module = self;
// fill up the output buffer with a sine wave!
for(int i=0;i<ctx->bufferLength/2;i++){
// must be called before any parameters are read
if(module->_(lipsynth_Module_update_parameters)(self, ctx)){
if(module->_(lipsynth_Module_has_parameter_value)(self, ctx, NOTE)){
int noteVal = module->_(lipsynth_Module_get_parameter_value)(self, ctx, NOTE);
module->freqVal = pow(2.0, (noteVal)/12.0f)*440.0f;
}
#include "module_sine.h"
typedef enum {
NOTE,
VOL
} lipsynth_sine_params;
int lipsynth_module_sine_destroy(void *self){
return 1;
}
void lipsynth_module_sine_update(void *self, lipsynth_context *ctx, lipsynth_AudioMemory *outputBuffer){
// types
typedef struct lipsynth_Module lipsynth_Module;
struct lipsynth_Module {
// blah blah a bunch of values and pointers and stuff
// the only one that I am getting confused about
int module_registration;
};