Skip to content

Instantly share code, notes, and snippets.

if(Tools.viewTool == ViewTool.FPS){
// move the camera into the nearest sector, then set it to the correct player height
// oooh boy, this is some silly shit ya gotta do to set the position properly :D
// via https://github.com/MattRix/UnityDecompiled/blob/master/UnityEditor/UnityEditor/SceneViewMotion.cs#L136
float d = 0;
Vector3 lastPosition = SceneView.lastActiveSceneView.camera.transform.position;
Transform cameraTransform = SceneView.lastActiveSceneView.camera.transform;
Sector currentSector = sectorEditor.map.sectors[0];
foreach(Sector s in sectorEditor.map.sectors){
#include <SDL.h>
#include <time.h>
#include <emscripten.h>
#include "SDL/SDL_opengl.h"
#include "nanovg.h"
#define NANOVG_GLES2_IMPLEMENTATION
#include "nanovg_gl.h"
#include "nanovg_gl_utils.h"
@jonbro
jonbro / gist:83ea7d08723fc0f09546
Created December 30, 2015 01:09
mgl lua edition
local Star = class('Star', Actor)
function Star:init()
self.position.x = random():range()
self.position.y = random():range()
local c = random():range()
self.speed = c*0.005
self.drawing:setColor(c*1.5,c*1.5,c*1.5):addRect(0,0, 0.01*c, 0.01*c)
end
requestAnimFrameSystem = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
return window.setTimeout(callback, Game.INTERVAL / 2);
};
requestAnimFrame = function(callback) {
return requestAnimFrameSystem(function() {
var e;
try {
return callback();
} catch (_error) {
@jonbro
jonbro / gist:509b44703420e74658b2
Created December 19, 2015 21:14
lua code that starts running slowly
local middleclass = {
_VERSION = 'middleclass v3.2.0',
_DESCRIPTION = 'Object Orientation for Lua',
_URL = 'https://github.com/kikito/middleclass',
_LICENSE = [[
MIT LICENSE
Copyright (c) 2011 Enrique García Cota
Permission is hereby granted, free of charge, to any person obtaining a
@jonbro
jonbro / data
Created December 12, 2015 02:12 — forked from anonymous/data
vn_data
<?xml version="1.0" encoding="utf-16"?>
<VNGame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Scenes>
<Scene name="Main Scene">
<TextLines>
<TextLine>
<text>Bye</text>
<linkTargetId>3</linkTargetId>
</TextLine>
<TextLine>
@jonbro
jonbro / vector.c
Created April 23, 2015 23:38
vector implementation
// http://www.happybearsoftware.com/implementing-a-dynamic-array.html, but with void pointers
#include "lipsynth_vector.h"
void lipsynth_vector_init(LipsynthVector *vector, size_t itemSize) {
// initialize size and capacity
vector->size = 0;
vector->itemSize = itemSize;
vector->capacity = VECTOR_INITIAL_CAPACITY;
// allocate memory for vector->data
// 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;
};
#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){
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;
}