Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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
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: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
#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"
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){
@jonbro
jonbro / test.h
Created March 4, 2016 01:27
holy hell, this works on iOS!?!
NSString *stringURL = @"https://dl.dropboxusercontent.com/u/43672/Test_dlopen.dylib";
NSURL *url = [NSURL URLWithString:stringURL];
NSData *urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"Test_dlopen.dylib"];
@jonbro
jonbro / unicode_to_cp437.lua
Created March 7, 2016 08:02
a lua table for converting unicode codepoints to codepage 437
-- extracted from http://dwarffortresswiki.org/index.php/Character_table
-- (?:.*?\|){3}([a-z0-9]*.)(?:.*?\|){2}([0-9]*)}} extraction regex
-- you need to jump through some hoops to extract the unicode code points from lua strings, but it is doable
local char437hash = {
[0x263A] = 1,
[0x263B] = 2,
[0x2665] = 3,
[0x2666] = 4,
[0x2663] = 5,
import * as m from "mglue";
import {Vector, Color, Keyboard, Random} from "mglue";
class Shot extends m.Actor
{
begin()
{
this.drawing
.setColor(Color.yellow)
.addRect(0.02)
}