Skip to content

Instantly share code, notes, and snippets.

@rraallvv
rraallvv / gist:2921697
Created June 13, 2012 03:40
Read a File From Cocoa Application Bundle
// How To Read a File From Your Application Bundle
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyFile" ofType:@"txt"];
NSData *myData = [NSData dataWithContentsOfFile:filePath];
if (myData) {
// do something useful
}
@rraallvv
rraallvv / gist:2929389
Created June 14, 2012 09:58
Save NSDictionary to plist file
// save NSDictionary to plist file
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:@"myfile.plist"];
NSLog(@"%@", plistPath);
[myNSDictionary writeToFile:plistPath atomically: YES];
@rraallvv
rraallvv / gist:2954726
Created June 19, 2012 15:16
Convert NSString to char array
NSString *s = @"Some string";
const char *c = [s UTF8String];
@rraallvv
rraallvv / nanosvg.c
Created June 19, 2012 16:15
nanosvg definitions
//
// Copyright (c) 2009 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
@rraallvv
rraallvv / nanosvg.h
Created June 19, 2012 16:16
nanosvg header
//
// Copyright (c) 2009 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
@rraallvv
rraallvv / gist:2955078
Created June 19, 2012 16:23
nanosvg description
Project web page http://code.google.com/p/nanosvg/
Overview
Nanosvg is simple stupid SVG parser for game prototypes and the likes. It is not meant to be a full fledged SVG parser, but just the bare bones to read the vector data from a SVG file. The parser supports many of the SVG shapes and most of the path commands (except arc).
If you're looking for nice and free vector drawing program capable of saving SVG files take a look at Inkscape.
Example Usage
// Load
@rraallvv
rraallvv / gist:2958298
Created June 20, 2012 05:37
Convert retrieved toucheds to CGPoint
-(CGPoint) dispatchTouches:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* touch = [touches anyObject];
return [[CCDirector sharedDirector] convertToGL:[touch locationInView:[touch view]]];
}
@rraallvv
rraallvv / gist:2972592
Created June 22, 2012 12:54
Storing integer into NSValue
int theInt = 123;
// storing value
NSValue* valObj;
valObj = [NSValue value:&myVal withObjCType:@encode(int*)];
// retrieving value
[valObj getValue:&valPtr];
@rraallvv
rraallvv / gist:3949643
Created October 24, 2012 23:45
BroadPhase Snippet
if ( proxy0->m_clientObject == cylinderBody )
{
return ( proxy1->m_clientObject == cylinderBody ); // cylinder must only collide with cylinder
}
if ( proxy0->m_clientObject == boxBody )
{
return ( proxy1->m_clientObject == sphereBody ); // box must only collide with sphere
}
@rraallvv
rraallvv / physicsExporter
Last active December 19, 2015 10:39
Blender 3D physics exporter
import bpy
import bge
#bge.constraints.setGravity(0, 0, 0);
path = bpy.path.abspath("//")
filename = bpy.path.display_name_from_filepath(bpy.data.filepath)
bge.constraints.exportBulletFile(path+filename+".bullet")