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
static cpBool | |
PlayerTerrainBegin(cpArbiter *arb, cpSpace *space, void *data) | |
{ | |
CP_ARBITER_GET_SHAPES(arb, playerShape, terrainShape); | |
GameObject *player = cpShapeGetUserData(playerShape); | |
GameObject *terrain = cpShapeGetUserData(terrainShape); | |
cpBool retvalA = player.collidedWith(terrain); |
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
/* Copyright (c) 2007 Scott Lembcke | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be included in |
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
#! /usr/bin/env ruby | |
system "scp -P 2222 #{ARGV[0]} localhost:#{ARGV[1]}" |
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 CP_USE_DOUBLES 1 | |
#if CP_USE_DOUBLES | |
/// Chipmunk's floating point type. | |
/// Can be reconfigured at compile time. | |
typedef double cpFloat; | |
#define cpfsqrt sqrt | |
#define cpfsin sin | |
#define cpfcos cos | |
#define cpfacos acos |
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
cpFloat moment = cpMomentForPoly(mass, NUM_VERTS, verts, cpvzero); | |
body = cpSpaceAddBody(space, cpBodyNew(mass, moment)); | |
shape = cpSpaceAddShape(space, cpPolyShapeNew(body, NUM_VERTS, verts, cpvzero)); | |
/* | |
So cpPolyShapeNew() now always call cpConvexHull() internally to ensure that you are creating convex shapes. Great! Woo! Whatever. | |
The issue was that cpMomentForPoly() does not. | |
* If the vertexes had the correct winding, but were concave, it would give you the correct moment for the concave polygon, but not the convex one used for the collider. This seems like it would be reasonable. |
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
// This is a little annoying: | |
cpVect *hullVerts = (cpVect *)calloc(NUM_VERTS, sizeof(cpVect)); | |
int hullCount = cpConvexHull(NUM_VERTS, verts, hullVerts, NULL, 0.0); | |
cpFloat mass = 1.0; | |
cpFloat moment = cpMomentForPoly(mass, hullCount, hullVerts, cpvzero); | |
body = cpSpaceAddBody(space, cpBodyNew(mass, moment)); | |
shape = cpSpaceAddShape(space, cpPolyShapeNew(body, hullCount, hullVerts, cpvzero)); |
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
@interface NotCrappyAssertionHandler : NSAssertionHandler @end | |
@implementation NotCrappyAssertionHandler | |
-(void)handleFailureInFunction:(NSString *)functionName file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format, ... | |
{ | |
NSLog(@"*** Assertion failure in %@(), %@:%d", functionName, fileName, line); | |
va_list args; | |
va_start(args, format); | |
NSLogv([@"*** Assertion message: " stringByAppendingString:format], args); |
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
SAMPLE_RATE = 44100 | |
DURATION = 2 | |
def tone(freq, phase, t) | |
Math.sin(t*freq*2.0*Math::PI + phase) | |
end | |
sum = 0.0; | |
(DURATION*SAMPLE_RATE).to_i.times{|sample| |
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
TILE_SIZE = 10 | |
TILES_WIDE = love.graphics.getWidth()/TILE_SIZE | |
TILES_HIGH = love.graphics.getHeight()/TILE_SIZE | |
LENGTH_INCREMENT = 5 | |
TRUD_INCREMENT = 5 | |
ACCUMULATOR = 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 "ChipmunkCocosBody.h" | |
@implementation ChipmunkCocosBody | |
@synthesize syncedNodes = _syncedNodes; | |
static void | |
UpdatePosition(cpBody *body, cpFloat dt) | |
{ |