--- /dev/null
+#import <Foundation/Foundation.h>
+#include <Box2D/Box2D.h>
+
+
+@interface World : NSObject {
+
+@private
+ b2World* _world;
+ float _timestep;
+ int _velocityIterations;
+ int _positionIterations;
+}
+
+@property (nonatomic, readonly) b2World* world;
+@property (nonatomic, assign) float timestep;
+@property (nonatomic, assign) int velocityIterations;
+@property (nonatomic, assign) int positionIterations;
+
+
+- (World*) init;
+- (World*) initWithTimestep:(float)hz;
+- (World*) initWithTimestep:(float)hz gravityX:(float)x Y:(float)y;
+
+- (void) step;
+
+
+@end
--- /dev/null
+#import "World.h"
+
+
+@implementation World
+
+@synthesize world = _world;
+@synthesize timestep = _timestep;
+@synthesize velocityIterations = _velocityIterations;
+@synthesize positionIterations = _positionIterations;
+
+
+- (World*) init {
+ return [self initWithTimestep:60.0f];
+}
+
+- (World*) initWithTimestep:(float)hz {
+ return [self initWithTimestep:hz gravityX:0.0f Y:0.0f];
+}
+
+- (World*) initWithTimestep:(float)hz gravityX:(float)x Y:(float)y {
+ if ((self = [super init])) {
+ b2Vec2 gravity = b2Vec2(x,y);
+ bool doSleep = true;
+ _world = new b2World(gravity, doSleep);
+
+ _timestep = 1.0f/hz;
+ _velocityIterations = 10;
+ _positionIterations = 10;
+ }
+ return self;
+}
+
+- (void) dealloc {
+ // TODO: track and release all known bodies etc
+ delete _world;
+ [super dealloc];
+}
+
+- (void) step {
+ self.world->Step(self.timestep, self.velocityIterations, self.positionIterations);
+}
+
+@end
49966919136930E8006E8125 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49966914136930E8006E8125 /* OpenAL.framework */; };
4996691A136930E8006E8125 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49966915136930E8006E8125 /* OpenGLES.framework */; };
4996691B136930E8006E8125 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49966916136930E8006E8125 /* QuartzCore.framework */; };
+ 49DA67D4137847A7004841E9 /* World.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DA67D2137847A7004841E9 /* World.h */; };
+ 49DA67D5137847A7004841E9 /* World.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49DA67D3137847A7004841E9 /* World.mm */; };
49F2D9C413764666000B6B8C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B013764666000B6B8C /* main.m */; };
49F2D9C513764666000B6B8C /* RootAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B513764666000B6B8C /* RootAppDelegate.m */; };
49F2D9C613764666000B6B8C /* Game.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B813764666000B6B8C /* Game.m */; };
49966914136930E8006E8125 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
49966915136930E8006E8125 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
49966916136930E8006E8125 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ 49DA67D2137847A7004841E9 /* World.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = World.h; sourceTree = "<group>"; };
+ 49DA67D3137847A7004841E9 /* World.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = World.mm; sourceTree = "<group>"; };
49F2D99B137645DF000B6B8C /* box2d-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "box2d-ios.xcodeproj"; path = "libs/box2d/box2d-ios.xcodeproj"; sourceTree = "<group>"; };
49F2D9B013764666000B6B8C /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
49F2D9B213764666000B6B8C /* prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prefix.pch; sourceTree = "<group>"; };
49F2D9B113764666000B6B8C /* physics */ = {
isa = PBXGroup;
children = (
+ 49DA67D2137847A7004841E9 /* World.h */,
+ 49DA67D3137847A7004841E9 /* World.mm */,
);
path = physics;
sourceTree = "<group>";
49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */,
49F2DAF213765004000B6B8C /* GLES-Render.h in Headers */,
49F2DB341376632E000B6B8C /* Unit.h in Headers */,
+ 49DA67D4137847A7004841E9 /* World.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
49F2DADE13764ED6000B6B8C /* SPUtils.m in Sources */,
49F2DAF313765004000B6B8C /* GLES-Render.mm in Sources */,
49F2DB351376632E000B6B8C /* Unit.m in Sources */,
+ 49DA67D5137847A7004841E9 /* World.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};