This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <string.h> | |
#import <objc/objc-runtime.h> | |
#import <Foundation/Foundation.h> | |
#import "SimpleTestCase.h" | |
static void | |
PrintException(NSException *e) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "level0_bits.h" | |
float polyline_verts0_0[] = {1022.000, 37.945, 1008.000, 29.078, 1002.000, 26.508, ..., 57.195, 0.000, 66.867}; | |
polyline polyline0_0 = { | |
polyline_verts0_0, | |
473, | |
false, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////// RopeNode.h | |
#import "cocos2d.h" | |
#import "ObjectiveChipmunk.h" | |
struct RopeNodeParticle; | |
@interface RopeNode : CCNode { | |
ChipmunkBody *_body1, *_body2; | |
cpVect _offset1, _offset2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mach/mach.h> | |
#include <mach/mach_time.h> | |
double GetDoubleTime(void) | |
{ | |
mach_timebase_info_data_t base; | |
mach_timebase_info(&base); | |
return (double)mach_absolute_time()*((double)base.numer/(double)base.denom)*1.0e-9; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define this function somewhere | |
static void CallArbiterBlock(cpBody *body, cpArbiter *arbiter, void (^block)(cpArbiter *arbiter)){block(arbiter);} | |
// Then you can do this: | |
// __block makes the variable writable from within a block, otherwise they are read only. | |
__block cpVect impulseSum = cpvzero; | |
cpBodyEachArbiter(scaleStaticBody, (cpBodyArbiterIteratorFunc)CallArbiterBlock, ^(cpArbiter *arb){ | |
impulseSum = cpvadd(impulseSum, cpArbiterTotalImpulse(arb)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define CHIPMUNK_ARBITER_GET_SHAPES(arb, a, b) ChipmunkShape *a, *b; { \ | |
cpShape *shapeA, *shapeB; \ | |
cpArbiterGetShapes(arb, &shapeA, &shapeB); \ | |
a = shapeA->data; b = shapeB->data; \ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ObjectiveChipmunk.h" | |
void main(){ | |
cpArbiter arb = {}; | |
CHIPMUNK_ARBITER_GET_SHAPES(arb, shapeA, shapeB); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(ChipmunkPolyline *line in [[ChipmunkImageSampler samplerWithImageFile:@"TestImage.psd" isMask:TRUE flip:TRUE] marchSoft]){ | |
ChipmunkPolyline *simple = [line simplifyCurves:3]; | |
NSLog(@"count: %lu", simple.count - 1); | |
for(int i=0; i<simple.count - 1; i++){ | |
cpVect a = simple.verts[i]; | |
cpVect b = simple.verts[i+1]; | |
ChipmunkShape *shape = [space add:[ChipmunkSegmentShape segmentWithBody:space.staticBody from:a to:b radius:2]]; | |
shape.friction = 1.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ImageDemo.h" | |
@implementation ImageDemo | |
@synthesize space; | |
-(void)marchImage | |
{ | |
//Create a sampler for a mask image | |
ChipmunkImageSampler *sampler = [ChipmunkImageSampler samplerWithImageFile:@"TestImage.psd" isMask:TRUE]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "DeformableDemo.h" | |
// We'll start with a couple octaves of Worley's cellular noise as a base. | |
static cpFloat | |
CellularNoise(cpVect pos) | |
{ | |
static const uint8_t permute[] = { | |
151,160,137,91,90,15, | |
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, |