From f93fb5058fb9c416c4a3227929e7d4c3c149170b Mon Sep 17 00:00:00 2001 From: dsc Date: Mon, 16 May 2011 12:38:23 -0700 Subject: [PATCH] QQ --- src/game/Active.h | 11 - src/game/Displayable.h | 8 - src/game/Game.h | 22 -- src/game/Game.mm | 64 ------ src/game/QQActive.h | 11 + src/game/QQDisplayable.h | 8 + src/game/QQGame.h | 22 ++ src/game/QQGame.mm | 64 ++++++ src/game/actor/Actor.h | 19 -- src/game/actor/Actor.mm | 18 -- src/game/actor/QQActor.h | 19 ++ src/game/actor/QQActor.mm | 18 ++ src/game/actor/QQUnit.h | 21 ++ src/game/actor/QQUnit.mm | 52 +++++ src/game/actor/Unit.h | 21 -- src/game/actor/Unit.mm | 52 ----- src/physics/QQWorld.h | 31 +++ src/physics/QQWorld.mm | 54 +++++ src/physics/World.h | 31 --- src/physics/World.mm | 54 ----- src/physics/debug/GLESDebugDraw.h | 58 ----- src/physics/debug/GLESDebugDraw.mm | 149 ------------- src/physics/debug/PhysicsDebugView.h | 67 ------ src/physics/debug/PhysicsDebugView.mm | 299 -------------------------- src/physics/debug/QQGLESDebugDraw.h | 58 +++++ src/physics/debug/QQGLESDebugDraw.mm | 149 +++++++++++++ src/physics/debug/QQPhysicsDebugView.h | 67 ++++++ src/physics/debug/QQPhysicsDebugView.mm | 299 ++++++++++++++++++++++++++ src/render/animation/AnimationContainer.h | 21 -- src/render/animation/AnimationContainer.mm | 116 ---------- src/render/animation/QQAnimationContainer.h | 21 ++ src/render/animation/QQAnimationContainer.mm | 116 ++++++++++ src/ui/AppDelegate.h | 16 -- src/ui/AppDelegate.mm | 52 ----- src/ui/QQAppDelegate.h | 16 ++ src/ui/QQAppDelegate.mm | 52 +++++ src/ui/QQViewport.h | 26 +++ src/ui/QQViewport.mm | 36 +++ src/ui/Viewport.h | 26 --- src/ui/Viewport.mm | 36 --- src/ui/iPad/AppDelegate_iPad.h | 16 -- src/ui/iPad/AppDelegate_iPad.mm | 18 -- src/ui/iPad/QQAppDelegate_iPad.h | 16 ++ src/ui/iPad/QQAppDelegate_iPad.mm | 18 ++ src/ui/iPad/en.lproj/MainWindow_iPad.xib | 12 +- src/ui/iPhone/AppDelegate_iPhone.h | 16 -- src/ui/iPhone/AppDelegate_iPhone.mm | 18 -- src/ui/iPhone/QQAppDelegate_iPhone.h | 16 ++ src/ui/iPhone/QQAppDelegate_iPhone.mm | 18 ++ src/ui/iPhone/en.lproj/MainWindow_iPhone.xib | 12 +- tanks.xcodeproj/project.pbxproj | 184 ++++++++-------- 51 files changed, 1312 insertions(+), 1312 deletions(-) delete mode 100644 src/game/Active.h delete mode 100644 src/game/Displayable.h delete mode 100644 src/game/Game.h delete mode 100644 src/game/Game.mm create mode 100644 src/game/QQActive.h create mode 100644 src/game/QQDisplayable.h create mode 100644 src/game/QQGame.h create mode 100644 src/game/QQGame.mm delete mode 100644 src/game/actor/Actor.h delete mode 100644 src/game/actor/Actor.mm create mode 100644 src/game/actor/QQActor.h create mode 100644 src/game/actor/QQActor.mm create mode 100644 src/game/actor/QQUnit.h create mode 100644 src/game/actor/QQUnit.mm delete mode 100644 src/game/actor/Unit.h delete mode 100644 src/game/actor/Unit.mm create mode 100644 src/physics/QQWorld.h create mode 100644 src/physics/QQWorld.mm delete mode 100644 src/physics/World.h delete mode 100644 src/physics/World.mm delete mode 100644 src/physics/debug/GLESDebugDraw.h delete mode 100644 src/physics/debug/GLESDebugDraw.mm delete mode 100644 src/physics/debug/PhysicsDebugView.h delete mode 100644 src/physics/debug/PhysicsDebugView.mm create mode 100644 src/physics/debug/QQGLESDebugDraw.h create mode 100644 src/physics/debug/QQGLESDebugDraw.mm create mode 100644 src/physics/debug/QQPhysicsDebugView.h create mode 100644 src/physics/debug/QQPhysicsDebugView.mm delete mode 100644 src/render/animation/AnimationContainer.h delete mode 100644 src/render/animation/AnimationContainer.mm create mode 100644 src/render/animation/QQAnimationContainer.h create mode 100644 src/render/animation/QQAnimationContainer.mm delete mode 100644 src/ui/AppDelegate.h delete mode 100644 src/ui/AppDelegate.mm create mode 100644 src/ui/QQAppDelegate.h create mode 100644 src/ui/QQAppDelegate.mm create mode 100644 src/ui/QQViewport.h create mode 100644 src/ui/QQViewport.mm delete mode 100644 src/ui/Viewport.h delete mode 100644 src/ui/Viewport.mm delete mode 100644 src/ui/iPad/AppDelegate_iPad.h delete mode 100644 src/ui/iPad/AppDelegate_iPad.mm create mode 100644 src/ui/iPad/QQAppDelegate_iPad.h create mode 100644 src/ui/iPad/QQAppDelegate_iPad.mm delete mode 100644 src/ui/iPhone/AppDelegate_iPhone.h delete mode 100644 src/ui/iPhone/AppDelegate_iPhone.mm create mode 100644 src/ui/iPhone/QQAppDelegate_iPhone.h create mode 100644 src/ui/iPhone/QQAppDelegate_iPhone.mm diff --git a/src/game/Active.h b/src/game/Active.h deleted file mode 100644 index b9514a1..0000000 --- a/src/game/Active.h +++ /dev/null @@ -1,11 +0,0 @@ - -/** - * Anything that takes a turn is Active. - */ -@protocol Active - -@property (nonatomic, getter=isActive) BOOL active; - -- (void) act; - -@end \ No newline at end of file diff --git a/src/game/Displayable.h b/src/game/Displayable.h deleted file mode 100644 index 852bf95..0000000 --- a/src/game/Displayable.h +++ /dev/null @@ -1,8 +0,0 @@ -#import "Sparrow.h" - - -@protocol Displayable - -@property (nonatomic, retain, readonly) SPDisplayObject* shape; - -@end \ No newline at end of file diff --git a/src/game/Game.h b/src/game/Game.h deleted file mode 100644 index 3232ced..0000000 --- a/src/game/Game.h +++ /dev/null @@ -1,22 +0,0 @@ -#import "Sparrow.h" - -#import "game/actor/Unit.h" -#import "physics/World.h" - - -@interface Game : SPStage { - - long ticks; - -@private - Unit* _unit; - World* _world; -} - -@property (nonatomic, retain) World* world; - -- (void) onEnterFrame:(SPEnterFrameEvent*)event; - -+ (Game*) current; - -@end diff --git a/src/game/Game.mm b/src/game/Game.mm deleted file mode 100644 index 9f8aa0b..0000000 --- a/src/game/Game.mm +++ /dev/null @@ -1,64 +0,0 @@ -#import "Game.h" -#import "game/actor/Unit.h" - - - -static Game* _currentGame = NULL; - - - -@interface Game () -@property (nonatomic, retain) Unit* unit; -@end - - -@implementation Game -@synthesize world = _world; -@synthesize unit = _unit; - - -- (id) init { - if (_currentGame) { - [self release]; - [NSException raise:@"TooManyGames" format:@"cannot instantiate more than one Game at a time!"]; - } - - if ( (self = [super init]) ){ - _currentGame = self; - ticks = 0l; - - _world = [[World alloc] init]; - [self addEventListener:@selector(onEnterFrame:) atObject:self forType:SP_EVENT_TYPE_ENTER_FRAME]; - - _unit = [[Unit alloc] init]; - // [self addEventListener:@selector(onTouch:) atObject:_unit forType:SP_EVENT_TYPE_TOUCH]; - // if (_unit.shape) [self addChild:_unit.shape]; - } - return self; -} - -- (void) dealloc { - // [self setUnit:nil]; - // [self setWorld:nil]; - [_unit release]; - [_world release]; - _currentGame = NULL; - [super dealloc]; -} - -- (void) onEnterFrame:(SPEnterFrameEvent*)event { - ticks++; - if ((ticks % 100) == 0) - NSLog(@"[%ld] Time passed since last 100 frames: %f", ticks, event.passedTime); - [self.world step]; -} - -+ (Game*) current { - if (!_currentGame) - [[[Game alloc] init] // init assigns to singleton, but singleton is a weakref, - autorelease]; // XXX: so game will still be released if not retained... - return _currentGame; -} - - -@end \ No newline at end of file diff --git a/src/game/QQActive.h b/src/game/QQActive.h new file mode 100644 index 0000000..62a0681 --- /dev/null +++ b/src/game/QQActive.h @@ -0,0 +1,11 @@ + +/** + * Anything that takes a turn is QQActive. + */ +@protocol QQActive + +@property (nonatomic, getter=isActive) BOOL active; + +- (void) act; + +@end \ No newline at end of file diff --git a/src/game/QQDisplayable.h b/src/game/QQDisplayable.h new file mode 100644 index 0000000..ef6f1ef --- /dev/null +++ b/src/game/QQDisplayable.h @@ -0,0 +1,8 @@ +#import "Sparrow.h" + + +@protocol QQDisplayable + +@property (nonatomic, retain, readonly) SPDisplayObject* shape; + +@end \ No newline at end of file diff --git a/src/game/QQGame.h b/src/game/QQGame.h new file mode 100644 index 0000000..0857ebc --- /dev/null +++ b/src/game/QQGame.h @@ -0,0 +1,22 @@ +#import "Sparrow.h" + +#import "game/actor/QQUnit.h" +#import "physics/QQWorld.h" + + +@interface QQGame : SPStage { + + long ticks; + +@private + QQUnit* _unit; + QQWorld* _world; +} + +@property (nonatomic, retain) QQWorld* world; + +- (void) onEnterFrame:(SPEnterFrameEvent*)event; + ++ (QQGame*) current; + +@end diff --git a/src/game/QQGame.mm b/src/game/QQGame.mm new file mode 100644 index 0000000..a43d26a --- /dev/null +++ b/src/game/QQGame.mm @@ -0,0 +1,64 @@ +#import "QQGame.h" +#import "game/actor/QQUnit.h" + + + +static QQGame* _currentGame = NULL; + + + +@interface QQGame () +@property (nonatomic, retain) QQUnit* unit; +@end + + +@implementation QQGame +@synthesize world = _world; +@synthesize unit = _unit; + + +- (id) init { + if (_currentGame) { + [self release]; + [NSException raise:@"TooManyGames" format:@"cannot instantiate more than one QQGame at a time!"]; + } + + if ( (self = [super init]) ){ + _currentGame = self; + ticks = 0l; + + _world = [[QQWorld alloc] init]; + [self addEventListener:@selector(onEnterFrame:) atObject:self forType:SP_EVENT_TYPE_ENTER_FRAME]; + + _unit = [[QQUnit alloc] init]; + // [self addEventListener:@selector(onTouch:) atObject:_unit forType:SP_EVENT_TYPE_TOUCH]; + // if (_unit.shape) [self addChild:_unit.shape]; + } + return self; +} + +- (void) dealloc { + // [self setUnit:nil]; + // [self setWorld:nil]; + [_unit release]; + [_world release]; + _currentGame = NULL; + [super dealloc]; +} + +- (void) onEnterFrame:(SPEnterFrameEvent*)event { + ticks++; + if ((ticks % 100) == 0) + NSLog(@"[%ld] Time passed since last 100 frames: %f", ticks, event.passedTime); + [self.world step]; +} + ++ (QQGame*) current { + if (!_currentGame) + [[[QQGame alloc] init] // init assigns to singleton, but singleton is a weakref, + autorelease]; // XXX: so game will still be released if not retained... + return _currentGame; +} + + +@end \ No newline at end of file diff --git a/src/game/actor/Actor.h b/src/game/actor/Actor.h deleted file mode 100644 index ab2f513..0000000 --- a/src/game/actor/Actor.h +++ /dev/null @@ -1,19 +0,0 @@ -#import "game/Active.h" -#import "game/Displayable.h" -#import "physics/World.h" - -@class Game; - - -@interface Actor : NSObject { - -@private - BOOL _active; -} - -@property (nonatomic, readonly) Game* game; -@property (nonatomic, readonly) World* world; - - - -@end diff --git a/src/game/actor/Actor.mm b/src/game/actor/Actor.mm deleted file mode 100644 index ba63e62..0000000 --- a/src/game/actor/Actor.mm +++ /dev/null @@ -1,18 +0,0 @@ -#import "Actor.h" -#import "game/Game.h" - - -@implementation Actor - -@synthesize active; - -- (Game*) game { return Game.current; } -- (World*) world { return self.game.world; } - -- (SPDisplayObject*) shape { return nil; } - -- (void) act { - // stub -} - -@end diff --git a/src/game/actor/QQActor.h b/src/game/actor/QQActor.h new file mode 100644 index 0000000..abe284c --- /dev/null +++ b/src/game/actor/QQActor.h @@ -0,0 +1,19 @@ +#import "game/QQActive.h" +#import "game/QQDisplayable.h" +#import "physics/QQWorld.h" + +@class QQGame; + + +@interface QQActor : NSObject { + +@private + BOOL _active; +} + +@property (nonatomic, readonly) QQGame* game; +@property (nonatomic, readonly) QQWorld* world; + + + +@end diff --git a/src/game/actor/QQActor.mm b/src/game/actor/QQActor.mm new file mode 100644 index 0000000..944b26c --- /dev/null +++ b/src/game/actor/QQActor.mm @@ -0,0 +1,18 @@ +#import "QQActor.h" +#import "game/QQGame.h" + + +@implementation QQActor + +@synthesize active; + +- (QQGame*) game { return QQGame.current; } +- (QQWorld*) world { return self.game.world; } + +- (SPDisplayObject*) shape { return nil; } + +- (void) act { + // stub +} + +@end diff --git a/src/game/actor/QQUnit.h b/src/game/actor/QQUnit.h new file mode 100644 index 0000000..710e1e9 --- /dev/null +++ b/src/game/actor/QQUnit.h @@ -0,0 +1,21 @@ +#import "Sparrow.h" +#import "render/QQSparrowExtensions.h" + +#import "game/actor/QQActor.h" +#import "physics/QQWorld.h" + + +@interface QQUnit : QQActor { + +@private + SPDisplayObject* _shape; +} + +@property (nonatomic, retain, readwrite) SPDisplayObject* shape; + +- (id) initWithFile:(NSString*)fileName atX:(float)x y:(float)y; +- (id) initWithShape:(SPDisplayObject*)aShape; + +- (void) onTouch:(SPTouchEvent*)event; + +@end diff --git a/src/game/actor/QQUnit.mm b/src/game/actor/QQUnit.mm new file mode 100644 index 0000000..0ea8b62 --- /dev/null +++ b/src/game/actor/QQUnit.mm @@ -0,0 +1,52 @@ +#import "Sparrow.h" +#import "QQUnit.h" + + +@implementation QQUnit + +@synthesize shape = _shape; + +- (id) init { + return [self initWithShape:[[SPQuad quadWithWidth:32 height:32 color:0xff0000] setPositionX:50 y:50]]; +} + +- (id) initWithFile:(NSString*)fileName atX:(float)x y:(float)y { + return [self initWithShape:[[[[SPImage alloc] initWithContentsOfFile:fileName] autorelease] setPositionX:x y:y]]; +} + +- (id) initWithShape:(SPDisplayObject*)aShape { + if ((self = [super init])) { + self.shape = aShape; + [self.game addEventListener:@selector(onTouch:) atObject:self forType:SP_EVENT_TYPE_TOUCH]; + } + return self; +} + +- (void) dealloc { + [self.game removeEventListener:@selector(onTouch:) atObject:self forType:SP_EVENT_TYPE_TOUCH]; + [self.game removeChild:_shape]; + [_shape release]; + [super dealloc]; +} + +- (void) setShape:(SPDisplayObject*)newShape { + if (_shape != newShape) { + [self.game removeChild:_shape]; + [_shape release]; + _shape = [newShape retain]; + [self.game addChild:_shape]; + } +} + +- (void) onTouch:(SPTouchEvent*)event { + NSLog(@"%@ onTouch! shape=%@ parent=%@", self, self.shape, self.shape.parent); + SPTouch* touch = [[event touchesWithTarget:self.shape.parent] anyObject]; + if (touch) { + SPPoint* touchPosition = [touch locationInSpace:self.shape.parent]; + self.shape.x = touchPosition.x - self.shape.width / 2.0f; + self.shape.y = touchPosition.y - self.shape.height / 2.0f; + } +} + + +@end diff --git a/src/game/actor/Unit.h b/src/game/actor/Unit.h deleted file mode 100644 index c6650c2..0000000 --- a/src/game/actor/Unit.h +++ /dev/null @@ -1,21 +0,0 @@ -#import "Sparrow.h" -#import "render/QQSparrowExtensions.h" - -#import "game/actor/Actor.h" -#import "physics/World.h" - - -@interface Unit : Actor { - -@private - SPDisplayObject* _shape; -} - -@property (nonatomic, retain, readwrite) SPDisplayObject* shape; - -- (id) initWithFile:(NSString*)fileName atX:(float)x y:(float)y; -- (id) initWithShape:(SPDisplayObject*)aShape; - -- (void) onTouch:(SPTouchEvent*)event; - -@end diff --git a/src/game/actor/Unit.mm b/src/game/actor/Unit.mm deleted file mode 100644 index f37dd31..0000000 --- a/src/game/actor/Unit.mm +++ /dev/null @@ -1,52 +0,0 @@ -#import "Sparrow.h" -#import "Unit.h" - - -@implementation Unit - -@synthesize shape = _shape; - -- (id) init { - return [self initWithShape:[[SPQuad quadWithWidth:32 height:32 color:0xff0000] setPositionX:50 y:50]]; -} - -- (id) initWithFile:(NSString*)fileName atX:(float)x y:(float)y { - return [self initWithShape:[[[[SPImage alloc] initWithContentsOfFile:fileName] autorelease] setPositionX:x y:y]]; -} - -- (id) initWithShape:(SPDisplayObject*)aShape { - if ((self = [super init])) { - self.shape = aShape; - [self.game addEventListener:@selector(onTouch:) atObject:self forType:SP_EVENT_TYPE_TOUCH]; - } - return self; -} - -- (void) dealloc { - [self.game removeEventListener:@selector(onTouch:) atObject:self forType:SP_EVENT_TYPE_TOUCH]; - [self.game removeChild:_shape]; - [_shape release]; - [super dealloc]; -} - -- (void) setShape:(SPDisplayObject*)newShape { - if (_shape != newShape) { - [self.game removeChild:_shape]; - [_shape release]; - _shape = [newShape retain]; - [self.game addChild:_shape]; - } -} - -- (void) onTouch:(SPTouchEvent*)event { - NSLog(@"%@ onTouch! shape=%@ parent=%@", self, self.shape, self.shape.parent); - SPTouch* touch = [[event touchesWithTarget:self.shape.parent] anyObject]; - if (touch) { - SPPoint* touchPosition = [touch locationInSpace:self.shape.parent]; - self.shape.x = touchPosition.x - self.shape.width / 2.0f; - self.shape.y = touchPosition.y - self.shape.height / 2.0f; - } -} - - -@end diff --git a/src/physics/QQWorld.h b/src/physics/QQWorld.h new file mode 100644 index 0000000..6087703 --- /dev/null +++ b/src/physics/QQWorld.h @@ -0,0 +1,31 @@ +#include +#import "physics/debug/QQGLESDebugDraw.h" + + +@interface QQWorld : NSObject { + +@private + float _timestep; + int _velocityIterations; + int _positionIterations; + + b2World* _world; + QQGLESDebugDraw debugDraw; +} + +@property (nonatomic, readonly) b2World* world; +@property (nonatomic, assign) float timestep; +@property (nonatomic, assign) int velocityIterations; +@property (nonatomic, assign) int positionIterations; + + +- (QQWorld*) init; +- (QQWorld*) initWithTimestep:(float)hz; +- (QQWorld*) initWithTimestep:(float)hz gravityX:(float)x y:(float)y; + +- (void) setGravityX:(float)x y:(float)y; + +- (void) step; + + +@end diff --git a/src/physics/QQWorld.mm b/src/physics/QQWorld.mm new file mode 100644 index 0000000..e6c3d71 --- /dev/null +++ b/src/physics/QQWorld.mm @@ -0,0 +1,54 @@ +#import "QQWorld.h" + + + +@implementation QQWorld + +@synthesize world = _world; +@synthesize timestep = _timestep; +@synthesize velocityIterations = _velocityIterations; +@synthesize positionIterations = _positionIterations; + + +- (QQWorld*) init { + return [self initWithTimestep:60.0f]; +} + +- (QQWorld*) initWithTimestep:(float)hz { + return [self initWithTimestep:hz gravityX:0.0f y:0.0f]; +} + +- (QQWorld*) initWithTimestep:(float)hz gravityX:(float)x y:(float)y { + if ((self = [super init])) { + _timestep = 1.0f/hz; + _velocityIterations = 10; + _positionIterations = 10; + + b2Vec2 gravity = b2Vec2(x,y); + bool doSleep = true; + _world = new b2World(gravity, doSleep); + // _world->SetDebugDraw(&debugDraw); + } + return self; +} + +- (void) dealloc { + // TODO: track and release all known bodies etc + delete _world; + [super dealloc]; +} + +- (void) step { + _world->Step(self.timestep, self.velocityIterations, self.positionIterations); + // _world->DrawDebugData(); +} + +- (void) setGravityX:(float)x y:(float)y { + _world->SetGravity(b2Vec2(x,y)); +} + + + + + +@end diff --git a/src/physics/World.h b/src/physics/World.h deleted file mode 100644 index c0663fa..0000000 --- a/src/physics/World.h +++ /dev/null @@ -1,31 +0,0 @@ -#include -#import "physics/debug/GLESDebugDraw.h" - - -@interface World : NSObject { - -@private - float _timestep; - int _velocityIterations; - int _positionIterations; - - b2World* _world; - GLESDebugDraw debugDraw; -} - -@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) setGravityX:(float)x y:(float)y; - -- (void) step; - - -@end diff --git a/src/physics/World.mm b/src/physics/World.mm deleted file mode 100644 index 0beb32b..0000000 --- a/src/physics/World.mm +++ /dev/null @@ -1,54 +0,0 @@ -#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])) { - _timestep = 1.0f/hz; - _velocityIterations = 10; - _positionIterations = 10; - - b2Vec2 gravity = b2Vec2(x,y); - bool doSleep = true; - _world = new b2World(gravity, doSleep); - // _world->SetDebugDraw(&debugDraw); - } - return self; -} - -- (void) dealloc { - // TODO: track and release all known bodies etc - delete _world; - [super dealloc]; -} - -- (void) step { - _world->Step(self.timestep, self.velocityIterations, self.positionIterations); - // _world->DrawDebugData(); -} - -- (void) setGravityX:(float)x y:(float)y { - _world->SetGravity(b2Vec2(x,y)); -} - - - - - -@end diff --git a/src/physics/debug/GLESDebugDraw.h b/src/physics/debug/GLESDebugDraw.h deleted file mode 100644 index 6131196..0000000 --- a/src/physics/debug/GLESDebugDraw.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -* -* 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 -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef GLES_DEBUG_DRAW_H -#define GLES_DEBUG_DRAW_H - -#import -#import -#import -#import - -#include - -struct b2AABB; - -// This class implements debug drawing callbacks that are invoked -// inside b2World::Step. -class GLESDebugDraw : public b2DebugDraw -{ -public: - void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - - void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - - void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); - - void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); - - void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); - - void DrawTransform(const b2Transform& xf); - - void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color); - - void DrawString(int x, int y, const char* string, ...); - - void DrawAABB(b2AABB* aabb, const b2Color& color); -}; - - -#endif diff --git a/src/physics/debug/GLESDebugDraw.mm b/src/physics/debug/GLESDebugDraw.mm deleted file mode 100644 index ab02a83..0000000 --- a/src/physics/debug/GLESDebugDraw.mm +++ /dev/null @@ -1,149 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -* -* 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 -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "GLESDebugDraw.h" - - -#include -#include - -#include - -void GLESDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) -{ - glColor4f(color.r, color.g, color.b,1); - glVertexPointer(2, GL_FLOAT, 0, vertices); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); -} - -void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) -{ - glVertexPointer(2, GL_FLOAT, 0, vertices); - - glColor4f(color.r, color.g, color.b,0.5f); - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); - - glColor4f(color.r, color.g, color.b,1); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); -} - -void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) -{ - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - GLfloat glVertices[vertexCount*2]; - for (int32 i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x; - glVertices[i*2+1]=v.y; - theta += k_increment; - } - - glColor4f(color.r, color.g, color.b,1); - glVertexPointer(2, GL_FLOAT, 0, glVertices); - - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); -} - -void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) -{ - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - GLfloat glVertices[vertexCount*2]; - for (int32 i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x; - glVertices[i*2+1]=v.y; - theta += k_increment; - } - - glColor4f(color.r, color.g, color.b,0.5f); - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); - glColor4f(color.r, color.g, color.b,1); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); - - // Draw the axis line - DrawSegment(center,center+radius*axis,color); -} - -void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) -{ - glColor4f(color.r, color.g, color.b,1); - GLfloat glVertices[] = { - p1.x,p1.y,p2.x,p2.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_LINES, 0, 2); -} - -void GLESDebugDraw::DrawTransform(const b2Transform& xf) -{ - b2Vec2 p1 = xf.position, p2; - const float32 k_axisScale = 0.4f; - - p2 = p1 + k_axisScale * xf.R.col1; - DrawSegment(p1,p2,b2Color(1,0,0)); - - p2 = p1 + k_axisScale * xf.R.col2; - DrawSegment(p1,p2,b2Color(0,1,0)); -} - -void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) -{ - glColor4f(color.r, color.g, color.b,1); - glPointSize(size); - GLfloat glVertices[] = { - p.x,p.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_POINTS, 0, 1); - glPointSize(1.0f); -} - -void GLESDebugDraw::DrawString(int x, int y, const char *string, ...) -{ - - /* Unsupported as yet. Could replace with bitmap font renderer at a later date */ -} - -void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& c) -{ - - glColor4f(c.r, c.g, c.b,1); - - GLfloat glVertices[] = { - aabb->lowerBound.x, aabb->lowerBound.y, - aabb->upperBound.x, aabb->lowerBound.y, - aabb->upperBound.x, aabb->upperBound.y, - aabb->lowerBound.x, aabb->upperBound.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_LINE_LOOP, 0, 8); - -} diff --git a/src/physics/debug/PhysicsDebugView.h b/src/physics/debug/PhysicsDebugView.h deleted file mode 100644 index 57209d7..0000000 --- a/src/physics/debug/PhysicsDebugView.h +++ /dev/null @@ -1,67 +0,0 @@ -#import -#import -#import -#import - -#include - -#import "physics/PhysicsView.h" - -/* -This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. -The view content is basically an EAGL surface you render your OpenGL scene into. -Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. -*/ -@interface PhysicsDebugView : PhysicsView {} - -@property (nonatomic, readonly, getter=isRunning) BOOL running; -@property (nonatomic, assign) NSTimeInterval animationInterval; - - -- (void) startAnimation; -- (void) stopAnimation; - -@end - - -// Render Settings -struct Settings { - - Settings() : - hz(60.0f), - velocityIterations(10), - positionIterations(4), - drawStats(0), - drawShapes(1), - drawJoints(1), - drawAABBs(0), - drawPairs(0), - drawContactPoints(0), - drawContactNormals(0), - drawContactForces(0), - drawFrictionForces(0), - drawCOMs(0), - enableWarmStarting(1), - enableContinuous(1), - pause(0), - singleStep(0) - {} - - float32 hz; - int32 velocityIterations; - int32 positionIterations; - int32 drawShapes; - int32 drawJoints; - int32 drawAABBs; - int32 drawPairs; - int32 drawContactPoints; - int32 drawContactNormals; - int32 drawContactForces; - int32 drawFrictionForces; - int32 drawCOMs; - int32 drawStats; - int32 enableWarmStarting; - int32 enableContinuous; - int32 pause; - int32 singleStep; -}; diff --git a/src/physics/debug/PhysicsDebugView.mm b/src/physics/debug/PhysicsDebugView.mm deleted file mode 100644 index be4444b..0000000 --- a/src/physics/debug/PhysicsDebugView.mm +++ /dev/null @@ -1,299 +0,0 @@ -#import -#import - -#import "PhysicsDebugView.h" - - -#define USE_DEPTH_BUFFER 0 -#define kAccelerometerFrequency 30 -#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10 - - - -// A class extension to declare private methods -@interface PhysicsDebugView () { - -@private - World* _world; - BOOL _running; - - NSTimer* animationTimer; - NSTimeInterval animationInterval; - BOOL panning; - - // Position offset and scale - float sceneScale; - CGPoint positionOffset; - - CGPoint lastWorldTouch; - CGPoint lastScreenTouch; - - b2MouseJoint* mouseJoint; - b2Vec2 mouseWorld; - int32 stepCount; - - - /// OpenGL /// - - /* The pixel dimensions of the backbuffer */ - GLint backingWidth; - GLint backingHeight; - - EAGLContext *context; - - /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ - GLuint viewRenderbuffer, viewFramebuffer; - - /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ - GLuint depthRenderbuffer; - -} - -@property (nonatomic, retain) EAGLContext *context; -@property (nonatomic, assign) NSTimer *animationTimer; - -- (BOOL) createFramebuffer; -- (void) destroyFramebuffer; - -@end - - - - -@implementation PhysicsDebugView - -@synthesize world = _world; -@synthesize running = _running; - -@synthesize context; -@synthesize animationTimer; -@synthesize animationInterval; - - -// You must implement this method -+ (Class)layerClass { - return [CAEAGLLayer class]; -} - - -//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: -- (id)initWithCoder:(NSCoder*)coder { - - if ((self = [super initWithCoder:coder])) { - // Get the layer - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - - if (!context || ![EAGLContext setCurrentContext:context]) { - [self release]; - return nil; - } - - _running = NO; - animationInterval = 1.0 / 60.0; - sceneScale = 10.0f; - positionOffset = CGPointMake(0, 0); - lastWorldTouch = CGPointMake(0, 0); - - [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; - [[UIAccelerometer sharedAccelerometer] setDelegate:self]; - } - - return self; -} - -- (void) dealloc { - [self stopAnimation]; - - if ([EAGLContext currentContext] == context) { - [EAGLContext setCurrentContext:nil]; - } - - [context release]; - [super dealloc]; -} - - -/// Accessors /// - -- (void) setAnimationTimer:(NSTimer*)newTimer { - [animationTimer invalidate]; - animationTimer = newTimer; -} - -- (void) setAnimationInterval:(NSTimeInterval)interval { - animationInterval = interval; - if (animationTimer) { - [self stopAnimation]; - [self startAnimation]; - } -} - - -/// Methods /// - -- (void) startAnimation { - _running = YES; - self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; -} - -- (void) stopAnimation { - _running = NO; - self.animationTimer = nil; -} - -- (CGPoint) screenSpaceToWorldSpace:(CGPoint) screenLocation { - screenLocation.x -= 160; - screenLocation.y -= 240; - screenLocation.x /= 160; - screenLocation.y /= 160; - screenLocation.x *= sceneScale; - screenLocation.y *= -sceneScale; - - screenLocation.x -= positionOffset.x; - screenLocation.y -= positionOffset.y; - - return screenLocation; -} - - -/// Events /// - -- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { - panning = false; - for (UITouch *touch in touches) { - CGPoint touchLocation = [touch locationInView:self]; - CGPoint worldPosition = [self screenSpaceToWorldSpace:touchLocation]; - //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); - lastScreenTouch = touchLocation; - lastWorldTouch = worldPosition; - - // test->MouseDown(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); - // if (!test->m_mouseJoint) panning=true; - } -} - -- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { - for (UITouch *touch in touches) { - CGPoint touchLocation = [touch locationInView:self]; - CGPoint worldPosition = [self screenSpaceToWorldSpace:touchLocation]; - //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); - - - CGPoint screenDistanceMoved = CGPointMake(touchLocation.x-lastScreenTouch.x,touchLocation.y-lastScreenTouch.y); - if (panning) { - screenDistanceMoved.x /= 160; - screenDistanceMoved.y /= 160; - screenDistanceMoved.x *= sceneScale; - screenDistanceMoved.y *= -sceneScale; - positionOffset.x += screenDistanceMoved.x; - positionOffset.y += screenDistanceMoved.y; - } - - lastScreenTouch = touchLocation; - lastWorldTouch = worldPosition; - // test->MouseMove(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); - } -} - -- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event { - // test->MouseUp(b2Vec2(lastWorldTouch.x, lastWorldTouch.y)); -} - -- (void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration { - // Only run for valid values - if (acceleration.y != 0 && acceleration.x != 0) { - if (self.world) [self.world setGravityX:acceleration.x Y:acceleration.y]; - } -} - - - - -/// OpenGL /// - -- (void) drawView { - [EAGLContext setCurrentContext:context]; - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); - glViewport(0, 0, backingWidth, backingHeight); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrthof(-sceneScale, sceneScale, -sceneScale*1.5f, sceneScale*1.5f, -1.0f, 1.0f); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(positionOffset.x, positionOffset.y,0); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnableClientState(GL_VERTEX_ARRAY); - - [self.world step]; - - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); - [context presentRenderbuffer:GL_RENDERBUFFER_OES]; -} - - -- (void) layoutSubviews { - [EAGLContext setCurrentContext:context]; - [self destroyFramebuffer]; - [self createFramebuffer]; - [self drawView]; -} - - -- (BOOL) createFramebuffer { - - glGenFramebuffersOES(1, &viewFramebuffer); - glGenRenderbuffersOES(1, &viewRenderbuffer); - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); - [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); - - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); - - if (USE_DEPTH_BUFFER) { - glGenRenderbuffersOES(1, &depthRenderbuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); - glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); - } - - if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { - NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); - return NO; - } - - return YES; -} - - -- (void) destroyFramebuffer { - - glDeleteFramebuffersOES(1, &viewFramebuffer); - viewFramebuffer = 0; - glDeleteRenderbuffersOES(1, &viewRenderbuffer); - viewRenderbuffer = 0; - - if(depthRenderbuffer) { - glDeleteRenderbuffersOES(1, &depthRenderbuffer); - depthRenderbuffer = 0; - } -} - -@end diff --git a/src/physics/debug/QQGLESDebugDraw.h b/src/physics/debug/QQGLESDebugDraw.h new file mode 100644 index 0000000..058ac90 --- /dev/null +++ b/src/physics/debug/QQGLESDebugDraw.h @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +* +* 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 +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef GLES_DEBUG_DRAW_H +#define GLES_DEBUG_DRAW_H + +#import +#import +#import +#import + +#include + +struct b2AABB; + +// This class implements debug drawing callbacks that are invoked +// inside b2World::Step. +class QQGLESDebugDraw : public b2DebugDraw +{ +public: + void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); + + void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); + + void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); + + void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); + + void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); + + void DrawTransform(const b2Transform& xf); + + void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color); + + void DrawString(int x, int y, const char* string, ...); + + void DrawAABB(b2AABB* aabb, const b2Color& color); +}; + + +#endif diff --git a/src/physics/debug/QQGLESDebugDraw.mm b/src/physics/debug/QQGLESDebugDraw.mm new file mode 100644 index 0000000..674f60e --- /dev/null +++ b/src/physics/debug/QQGLESDebugDraw.mm @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +* +* 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 +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "QQGLESDebugDraw.h" + + +#include +#include + +#include + +void QQGLESDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) +{ + glColor4f(color.r, color.g, color.b,1); + glVertexPointer(2, GL_FLOAT, 0, vertices); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); +} + +void QQGLESDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) +{ + glVertexPointer(2, GL_FLOAT, 0, vertices); + + glColor4f(color.r, color.g, color.b,0.5f); + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); + + glColor4f(color.r, color.g, color.b,1); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); +} + +void QQGLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) +{ + const float32 k_segments = 16.0f; + int vertexCount=16; + const float32 k_increment = 2.0f * b2_pi / k_segments; + float32 theta = 0.0f; + + GLfloat glVertices[vertexCount*2]; + for (int32 i = 0; i < k_segments; ++i) + { + b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); + glVertices[i*2]=v.x; + glVertices[i*2+1]=v.y; + theta += k_increment; + } + + glColor4f(color.r, color.g, color.b,1); + glVertexPointer(2, GL_FLOAT, 0, glVertices); + + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); +} + +void QQGLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) +{ + const float32 k_segments = 16.0f; + int vertexCount=16; + const float32 k_increment = 2.0f * b2_pi / k_segments; + float32 theta = 0.0f; + + GLfloat glVertices[vertexCount*2]; + for (int32 i = 0; i < k_segments; ++i) + { + b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); + glVertices[i*2]=v.x; + glVertices[i*2+1]=v.y; + theta += k_increment; + } + + glColor4f(color.r, color.g, color.b,0.5f); + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); + glColor4f(color.r, color.g, color.b,1); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); + + // Draw the axis line + DrawSegment(center,center+radius*axis,color); +} + +void QQGLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) +{ + glColor4f(color.r, color.g, color.b,1); + GLfloat glVertices[] = { + p1.x,p1.y,p2.x,p2.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_LINES, 0, 2); +} + +void QQGLESDebugDraw::DrawTransform(const b2Transform& xf) +{ + b2Vec2 p1 = xf.position, p2; + const float32 k_axisScale = 0.4f; + + p2 = p1 + k_axisScale * xf.R.col1; + DrawSegment(p1,p2,b2Color(1,0,0)); + + p2 = p1 + k_axisScale * xf.R.col2; + DrawSegment(p1,p2,b2Color(0,1,0)); +} + +void QQGLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) +{ + glColor4f(color.r, color.g, color.b,1); + glPointSize(size); + GLfloat glVertices[] = { + p.x,p.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_POINTS, 0, 1); + glPointSize(1.0f); +} + +void QQGLESDebugDraw::DrawString(int x, int y, const char *string, ...) +{ + + /* Unsupported as yet. Could replace with bitmap font renderer at a later date */ +} + +void QQGLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& c) +{ + + glColor4f(c.r, c.g, c.b,1); + + GLfloat glVertices[] = { + aabb->lowerBound.x, aabb->lowerBound.y, + aabb->upperBound.x, aabb->lowerBound.y, + aabb->upperBound.x, aabb->upperBound.y, + aabb->lowerBound.x, aabb->upperBound.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_LINE_LOOP, 0, 8); + +} diff --git a/src/physics/debug/QQPhysicsDebugView.h b/src/physics/debug/QQPhysicsDebugView.h new file mode 100644 index 0000000..a8f63b6 --- /dev/null +++ b/src/physics/debug/QQPhysicsDebugView.h @@ -0,0 +1,67 @@ +#import +#import +#import +#import + +#include + +#import "physics/QQPhysicsView.h" + +/* +This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. +The view content is basically an EAGL surface you render your OpenGL scene into. +Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. +*/ +@interface QQPhysicsDebugView : QQPhysicsView {} + +@property (nonatomic, readonly, getter=isRunning) BOOL running; +@property (nonatomic, assign) NSTimeInterval animationInterval; + + +- (void) startAnimation; +- (void) stopAnimation; + +@end + + +// Render Settings +struct Settings { + + Settings() : + hz(60.0f), + velocityIterations(10), + positionIterations(4), + drawStats(0), + drawShapes(1), + drawJoints(1), + drawAABBs(0), + drawPairs(0), + drawContactPoints(0), + drawContactNormals(0), + drawContactForces(0), + drawFrictionForces(0), + drawCOMs(0), + enableWarmStarting(1), + enableContinuous(1), + pause(0), + singleStep(0) + {} + + float32 hz; + int32 velocityIterations; + int32 positionIterations; + int32 drawShapes; + int32 drawJoints; + int32 drawAABBs; + int32 drawPairs; + int32 drawContactPoints; + int32 drawContactNormals; + int32 drawContactForces; + int32 drawFrictionForces; + int32 drawCOMs; + int32 drawStats; + int32 enableWarmStarting; + int32 enableContinuous; + int32 pause; + int32 singleStep; +}; diff --git a/src/physics/debug/QQPhysicsDebugView.mm b/src/physics/debug/QQPhysicsDebugView.mm new file mode 100644 index 0000000..6c48262 --- /dev/null +++ b/src/physics/debug/QQPhysicsDebugView.mm @@ -0,0 +1,299 @@ +#import +#import + +#import "QQPhysicsDebugView.h" + + +#define USE_DEPTH_BUFFER 0 +#define kAccelerometerFrequency 30 +#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10 + + + +// A class extension to declare private methods +@interface QQPhysicsDebugView () { + +@private + QQWorld* _world; + BOOL _running; + + NSTimer* animationTimer; + NSTimeInterval animationInterval; + BOOL panning; + + // Position offset and scale + float sceneScale; + CGPoint positionOffset; + + CGPoint lastWorldTouch; + CGPoint lastScreenTouch; + + b2MouseJoint* mouseJoint; + b2Vec2 mouseWorld; + int32 stepCount; + + + /// OpenGL /// + + /* The pixel dimensions of the backbuffer */ + GLint backingWidth; + GLint backingHeight; + + EAGLContext *context; + + /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ + GLuint viewRenderbuffer, viewFramebuffer; + + /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ + GLuint depthRenderbuffer; + +} + +@property (nonatomic, retain) EAGLContext *context; +@property (nonatomic, assign) NSTimer *animationTimer; + +- (BOOL) createFramebuffer; +- (void) destroyFramebuffer; + +@end + + + + +@implementation QQPhysicsDebugView + +@synthesize world = _world; +@synthesize running = _running; + +@synthesize context; +@synthesize animationTimer; +@synthesize animationInterval; + + +// You must implement this method ++ (Class)layerClass { + return [CAEAGLLayer class]; +} + + +//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: +- (id)initWithCoder:(NSCoder*)coder { + + if ((self = [super initWithCoder:coder])) { + // Get the layer + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; + + context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + + if (!context || ![EAGLContext setCurrentContext:context]) { + [self release]; + return nil; + } + + _running = NO; + animationInterval = 1.0 / 60.0; + sceneScale = 10.0f; + positionOffset = CGPointMake(0, 0); + lastWorldTouch = CGPointMake(0, 0); + + [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; + [[UIAccelerometer sharedAccelerometer] setDelegate:self]; + } + + return self; +} + +- (void) dealloc { + [self stopAnimation]; + + if ([EAGLContext currentContext] == context) { + [EAGLContext setCurrentContext:nil]; + } + + [context release]; + [super dealloc]; +} + + +/// Accessors /// + +- (void) setAnimationTimer:(NSTimer*)newTimer { + [animationTimer invalidate]; + animationTimer = newTimer; +} + +- (void) setAnimationInterval:(NSTimeInterval)interval { + animationInterval = interval; + if (animationTimer) { + [self stopAnimation]; + [self startAnimation]; + } +} + + +/// Methods /// + +- (void) startAnimation { + _running = YES; + self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; +} + +- (void) stopAnimation { + _running = NO; + self.animationTimer = nil; +} + +- (CGPoint) screenSpaceToWorldSpace:(CGPoint) screenLocation { + screenLocation.x -= 160; + screenLocation.y -= 240; + screenLocation.x /= 160; + screenLocation.y /= 160; + screenLocation.x *= sceneScale; + screenLocation.y *= -sceneScale; + + screenLocation.x -= positionOffset.x; + screenLocation.y -= positionOffset.y; + + return screenLocation; +} + + +/// Events /// + +- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { + panning = false; + for (UITouch *touch in touches) { + CGPoint touchLocation = [touch locationInView:self]; + CGPoint worldPosition = [self screenSpaceToWorldSpace:touchLocation]; + //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); + lastScreenTouch = touchLocation; + lastWorldTouch = worldPosition; + + // test->MouseDown(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); + // if (!test->m_mouseJoint) panning=true; + } +} + +- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { + for (UITouch *touch in touches) { + CGPoint touchLocation = [touch locationInView:self]; + CGPoint worldPosition = [self screenSpaceToWorldSpace:touchLocation]; + //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); + + + CGPoint screenDistanceMoved = CGPointMake(touchLocation.x-lastScreenTouch.x,touchLocation.y-lastScreenTouch.y); + if (panning) { + screenDistanceMoved.x /= 160; + screenDistanceMoved.y /= 160; + screenDistanceMoved.x *= sceneScale; + screenDistanceMoved.y *= -sceneScale; + positionOffset.x += screenDistanceMoved.x; + positionOffset.y += screenDistanceMoved.y; + } + + lastScreenTouch = touchLocation; + lastWorldTouch = worldPosition; + // test->MouseMove(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); + } +} + +- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event { + // test->MouseUp(b2Vec2(lastWorldTouch.x, lastWorldTouch.y)); +} + +- (void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration { + // Only run for valid values + if (acceleration.y != 0 && acceleration.x != 0) { + if (self.world) [self.world setGravityX:acceleration.x Y:acceleration.y]; + } +} + + + + +/// OpenGL /// + +- (void) drawView { + [EAGLContext setCurrentContext:context]; + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glViewport(0, 0, backingWidth, backingHeight); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glOrthof(-sceneScale, sceneScale, -sceneScale*1.5f, sceneScale*1.5f, -1.0f, 1.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(positionOffset.x, positionOffset.y,0); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glEnableClientState(GL_VERTEX_ARRAY); + + [self.world step]; + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; +} + + +- (void) layoutSubviews { + [EAGLContext setCurrentContext:context]; + [self destroyFramebuffer]; + [self createFramebuffer]; + [self drawView]; +} + + +- (BOOL) createFramebuffer { + + glGenFramebuffersOES(1, &viewFramebuffer); + glGenRenderbuffersOES(1, &viewRenderbuffer); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); + + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + + if (USE_DEPTH_BUFFER) { + glGenRenderbuffersOES(1, &depthRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); + glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); + } + + if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + return NO; + } + + return YES; +} + + +- (void) destroyFramebuffer { + + glDeleteFramebuffersOES(1, &viewFramebuffer); + viewFramebuffer = 0; + glDeleteRenderbuffersOES(1, &viewRenderbuffer); + viewRenderbuffer = 0; + + if(depthRenderbuffer) { + glDeleteRenderbuffersOES(1, &depthRenderbuffer); + depthRenderbuffer = 0; + } +} + +@end diff --git a/src/render/animation/AnimationContainer.h b/src/render/animation/AnimationContainer.h deleted file mode 100644 index 4b4d16c..0000000 --- a/src/render/animation/AnimationContainer.h +++ /dev/null @@ -1,21 +0,0 @@ -#import "SPTextureAtlas.h" - -//////////////////////////////////////////////////////////////////////////////////// -@interface AnimationContainer : NSObject { -} - -//////////////////////////////////////////////////////////////////////////////////// -@property(nonatomic,retain) NSMutableDictionary* mAnimationLookup; -@property(nonatomic,retain) SPTextureAtlas* mAtlas; - -@property(nonatomic,retain) NSString* mAtlasPath; -@property(nonatomic,retain) NSString* mAnimationName; - -//////////////////////////////////////////////////////////////////////////////////// --(id)init; --(id)initWithContainer:(NSString*)containerPath; --(void)dealloc; - --(void)releaseVRAM; - -@end diff --git a/src/render/animation/AnimationContainer.mm b/src/render/animation/AnimationContainer.mm deleted file mode 100644 index 9f278ec..0000000 --- a/src/render/animation/AnimationContainer.mm +++ /dev/null @@ -1,116 +0,0 @@ -#import "AnimationContainer.h" - -#import "SPMovieClip.h" - - -//////////////////////////////////////////////////////////////////////////////////// -// private method -@interface AnimationContainer() - --(void)parseContentXml:(NSString *)contentPath; - -@end - - -//////////////////////////////////////////////////////////////////////////////////// -@implementation AnimationContainer - -//////////////////////////////////////////////////////////////////////////////////// -@synthesize mAnimationLookup; -@synthesize mAtlas; -@synthesize mAtlasPath; -@synthesize mAnimationName; - -//////////////////////////////////////////////////////////////////////////////////// --(id)init { - if ((self = [super init])) { - self.mAnimationLookup = [[NSMutableDictionary alloc] init]; - } - - return self; -} - -//////////////////////////////////////////////////////////////////////////////////// --(id)initWithContainer:(NSString *)containerPath { - if ((self = [super init])) { - [self parseContentXml:containerPath]; - } - - return self; -} - -//////////////////////////////////////////////////////////////////////////////////// --(void)dealloc { - [mAnimationLookup removeAllObjects]; - [mAnimationLookup release]; - [mAtlas release]; - [mAtlasPath release]; - [mAnimationName release]; - [super dealloc]; -} - -//////////////////////////////////////////////////////////////////////////////////// -// need a way to get the VRAM back --(void)releaseVRAM { - [mAnimationLookup removeAllObjects]; // remove all the movie clips, since they hold on to stuff in the atlas, but keep the dictionary - [mAtlas release]; // remove the atlas - mAtlas = nil; // is this extraneous? -} - -//////////////////////////////////////////////////////////////////////////////////// --(void)parseContentXml:(NSString *)contentPath { - NSAutoreleasePool* autoreleasePool = [[NSAutoreleasePool alloc] init]; - - if (!contentPath) return; - - NSString* fullPath = [[NSBundle mainBundle] pathForResource:contentPath ofType:nil]; - NSURL* xmlUrl = [NSURL fileURLWithPath:fullPath]; - NSXMLParser* xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlUrl]; - xmlParser.delegate = self; - BOOL success = [xmlParser parse]; - - [autoreleasePool drain]; // is this wrong? - - if (!success) { - NSLog(@"could not parse content XML %@. Error code: %d, domain: %@", - contentPath, xmlParser.parserError.code, xmlParser.parserError.domain); - } - - [xmlParser release]; -} - -//////////////////////////////////////////////////////////////////////////////////// -// XML parser callback for the following format: -// -// -// -// -// -// -- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName - namespaceURI: (NSString *)namespaceURI - qualifiedName: (NSString *)qName - attributes: (NSDictionary *)attributeDict { - if ([elementName isEqualToString:@"AnimationClips"]) - { - mAnimationLookup = [[NSMutableDictionary alloc] init]; - self.mAnimationName = [attributeDict valueForKey:@"name"]; - self.mAtlasPath = [attributeDict valueForKey:@"xmlPath"]; - mAtlas = [[SPTextureAtlas alloc] initWithContentsOfFile:mAtlasPath]; - } - else if ([elementName isEqualToString:@"Clip"]) - { - NSString* name = [attributeDict valueForKey:@"name"]; - int numFrames = [[attributeDict valueForKey:@"frames"] intValue]; - SPMovieClip* movieClip = [[SPMovieClip alloc] initWithFrames:[mAtlas texturesStartingWith:name] fps:15]; - [mAnimationLookup setValue:movieClip forKey:name]; // add our clip to the dictionary so we can reference it in the future - - if (movieClip.numFrames != numFrames) - { - NSLog(@"Number of frames (%d) in XML does not match number of frames (%d) in atlas!", numFrames, movieClip.numFrames); - } - } -} - - -@end diff --git a/src/render/animation/QQAnimationContainer.h b/src/render/animation/QQAnimationContainer.h new file mode 100644 index 0000000..80c0f84 --- /dev/null +++ b/src/render/animation/QQAnimationContainer.h @@ -0,0 +1,21 @@ +#import "SPTextureAtlas.h" + +//////////////////////////////////////////////////////////////////////////////////// +@interface QQAnimationContainer : NSObject { +} + +//////////////////////////////////////////////////////////////////////////////////// +@property(nonatomic,retain) NSMutableDictionary* mAnimationLookup; +@property(nonatomic,retain) SPTextureAtlas* mAtlas; + +@property(nonatomic,retain) NSString* mAtlasPath; +@property(nonatomic,retain) NSString* mAnimationName; + +//////////////////////////////////////////////////////////////////////////////////// +-(id)init; +-(id)initWithContainer:(NSString*)containerPath; +-(void)dealloc; + +-(void)releaseVRAM; + +@end diff --git a/src/render/animation/QQAnimationContainer.mm b/src/render/animation/QQAnimationContainer.mm new file mode 100644 index 0000000..321929e --- /dev/null +++ b/src/render/animation/QQAnimationContainer.mm @@ -0,0 +1,116 @@ +#import "QQAnimationContainer.h" + +#import "SPMovieClip.h" + + +//////////////////////////////////////////////////////////////////////////////////// +// private method +@interface QQAnimationContainer() + +-(void)parseContentXml:(NSString *)contentPath; + +@end + + +//////////////////////////////////////////////////////////////////////////////////// +@implementation QQAnimationContainer + +//////////////////////////////////////////////////////////////////////////////////// +@synthesize mAnimationLookup; +@synthesize mAtlas; +@synthesize mAtlasPath; +@synthesize mAnimationName; + +//////////////////////////////////////////////////////////////////////////////////// +-(id)init { + if ((self = [super init])) { + self.mAnimationLookup = [[NSMutableDictionary alloc] init]; + } + + return self; +} + +//////////////////////////////////////////////////////////////////////////////////// +-(id)initWithContainer:(NSString *)containerPath { + if ((self = [super init])) { + [self parseContentXml:containerPath]; + } + + return self; +} + +//////////////////////////////////////////////////////////////////////////////////// +-(void)dealloc { + [mAnimationLookup removeAllObjects]; + [mAnimationLookup release]; + [mAtlas release]; + [mAtlasPath release]; + [mAnimationName release]; + [super dealloc]; +} + +//////////////////////////////////////////////////////////////////////////////////// +// need a way to get the VRAM back +-(void)releaseVRAM { + [mAnimationLookup removeAllObjects]; // remove all the movie clips, since they hold on to stuff in the atlas, but keep the dictionary + [mAtlas release]; // remove the atlas + mAtlas = nil; // is this extraneous? +} + +//////////////////////////////////////////////////////////////////////////////////// +-(void)parseContentXml:(NSString *)contentPath { + NSAutoreleasePool* autoreleasePool = [[NSAutoreleasePool alloc] init]; + + if (!contentPath) return; + + NSString* fullPath = [[NSBundle mainBundle] pathForResource:contentPath ofType:nil]; + NSURL* xmlUrl = [NSURL fileURLWithPath:fullPath]; + NSXMLParser* xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlUrl]; + xmlParser.delegate = self; + BOOL success = [xmlParser parse]; + + [autoreleasePool drain]; // is this wrong? + + if (!success) { + NSLog(@"could not parse content XML %@. Error code: %d, domain: %@", + contentPath, xmlParser.parserError.code, xmlParser.parserError.domain); + } + + [xmlParser release]; +} + +//////////////////////////////////////////////////////////////////////////////////// +// XML parser callback for the following format: +// +// +// +// +// +// +- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName + namespaceURI: (NSString *)namespaceURI + qualifiedName: (NSString *)qName + attributes: (NSDictionary *)attributeDict { + if ([elementName isEqualToString:@"AnimationClips"]) + { + mAnimationLookup = [[NSMutableDictionary alloc] init]; + self.mAnimationName = [attributeDict valueForKey:@"name"]; + self.mAtlasPath = [attributeDict valueForKey:@"xmlPath"]; + mAtlas = [[SPTextureAtlas alloc] initWithContentsOfFile:mAtlasPath]; + } + else if ([elementName isEqualToString:@"Clip"]) + { + NSString* name = [attributeDict valueForKey:@"name"]; + int numFrames = [[attributeDict valueForKey:@"frames"] intValue]; + SPMovieClip* movieClip = [[SPMovieClip alloc] initWithFrames:[mAtlas texturesStartingWith:name] fps:15]; + [mAnimationLookup setValue:movieClip forKey:name]; // add our clip to the dictionary so we can reference it in the future + + if (movieClip.numFrames != numFrames) + { + NSLog(@"Number of frames (%d) in XML does not match number of frames (%d) in atlas!", numFrames, movieClip.numFrames); + } + } +} + + +@end diff --git a/src/ui/AppDelegate.h b/src/ui/AppDelegate.h deleted file mode 100644 index 7e85122..0000000 --- a/src/ui/AppDelegate.h +++ /dev/null @@ -1,16 +0,0 @@ -#import "Sparrow.h" -#import "game/Game.h" - - -@interface AppDelegate : NSObject -{ - UIWindow* window; - SPView* sparrowView; - Game* _game; -} - -@property (nonatomic, retain) IBOutlet UIWindow* window; -@property (nonatomic, retain) IBOutlet SPView* sparrowView; -@property (nonatomic, retain) Game* game; - -@end \ No newline at end of file diff --git a/src/ui/AppDelegate.mm b/src/ui/AppDelegate.mm deleted file mode 100644 index 78f81dc..0000000 --- a/src/ui/AppDelegate.mm +++ /dev/null @@ -1,52 +0,0 @@ -// -// AppDelegate.m -// tanks -// -// Created by dsc on 4/27/11. -// Copyright 2011 lttlst.com. All rights reserved. -// - -#import "AppDelegate.h" -#import "game/Game.h" - -@implementation AppDelegate - -@synthesize window; -@synthesize sparrowView; -@synthesize game = _game; - - -- (void) applicationDidFinishLaunching:(UIApplication*)application { - SP_CREATE_POOL(pool); - - [SPStage setSupportHighResolutions:YES]; - [SPAudioEngine start]; - if ( sparrowView.frameRate != 60.0f ) - sparrowView.frameRate = 60.0f; - // sparrowView.stage = [[[SPStage alloc] init] autorelease]; - - _game = [[Game alloc] init]; - sparrowView.stage = _game; - - [window makeKeyAndVisible]; - [sparrowView start]; - - SP_RELEASE_POOL(pool); -} - -- (void) applicationWillResignActive:(UIApplication*)application { - [sparrowView stop]; -} - -- (void) applicationDidBecomeActive:(UIApplication*)application { - [sparrowView start]; -} - -- (void) dealloc { - // [self setGame:nil]; - [_game release]; - [sparrowView release]; - [window release]; - [super dealloc]; -} -@end \ No newline at end of file diff --git a/src/ui/QQAppDelegate.h b/src/ui/QQAppDelegate.h new file mode 100644 index 0000000..f868fe1 --- /dev/null +++ b/src/ui/QQAppDelegate.h @@ -0,0 +1,16 @@ +#import "Sparrow.h" +#import "game/QQGame.h" + + +@interface QQAppDelegate : NSObject +{ + UIWindow* window; + SPView* sparrowView; + QQGame* _game; +} + +@property (nonatomic, retain) IBOutlet UIWindow* window; +@property (nonatomic, retain) IBOutlet SPView* sparrowView; +@property (nonatomic, retain) QQGame* game; + +@end \ No newline at end of file diff --git a/src/ui/QQAppDelegate.mm b/src/ui/QQAppDelegate.mm new file mode 100644 index 0000000..7eaeb17 --- /dev/null +++ b/src/ui/QQAppDelegate.mm @@ -0,0 +1,52 @@ +// +// QQAppDelegate.m +// tanks +// +// Created by dsc on 4/27/11. +// Copyright 2011 lttlst.com. All rights reserved. +// + +#import "QQAppDelegate.h" +#import "game/QQGame.h" + +@implementation QQAppDelegate + +@synthesize window; +@synthesize sparrowView; +@synthesize game = _game; + + +- (void) applicationDidFinishLaunching:(UIApplication*)application { + SP_CREATE_POOL(pool); + + [SPStage setSupportHighResolutions:YES]; + [SPAudioEngine start]; + if ( sparrowView.frameRate != 60.0f ) + sparrowView.frameRate = 60.0f; + // sparrowView.stage = [[[SPStage alloc] init] autorelease]; + + _game = [[QQGame alloc] init]; + sparrowView.stage = _game; + + [window makeKeyAndVisible]; + [sparrowView start]; + + SP_RELEASE_POOL(pool); +} + +- (void) applicationWillResignActive:(UIApplication*)application { + [sparrowView stop]; +} + +- (void) applicationDidBecomeActive:(UIApplication*)application { + [sparrowView start]; +} + +- (void) dealloc { + // [self setGame:nil]; + [_game release]; + [sparrowView release]; + [window release]; + [super dealloc]; +} +@end \ No newline at end of file diff --git a/src/ui/QQViewport.h b/src/ui/QQViewport.h new file mode 100644 index 0000000..f8123fa --- /dev/null +++ b/src/ui/QQViewport.h @@ -0,0 +1,26 @@ +#import "Sparrow.h" + +#import "physics/QQWorld.h" + + +/** + * View subclass which optionally tracks user input gestures that would zoom + * or pan the viewport. + */ +@interface QQViewport : SPView + +@property (nonatomic, retain) QQWorld* world; + +@property (nonatomic, assign, getter=isZoomable) BOOL zoomable; +@property (nonatomic, assign) float viewportZoom; + +@property (nonatomic, assign, getter=isPanable) BOOL panable; +@property (nonatomic, retain) SPPoint *viewportCenter; + + +- (void) drawView; + + +@end + + diff --git a/src/ui/QQViewport.mm b/src/ui/QQViewport.mm new file mode 100644 index 0000000..a3a6cdf --- /dev/null +++ b/src/ui/QQViewport.mm @@ -0,0 +1,36 @@ +#import +#import +#import + +#import "Sparrow.h" + +#import "QQViewport.h" +#import "physics/QQWorld.h" + + +@implementation QQViewport + +@synthesize zoomable; +@synthesize viewportZoom; + +@synthesize panable; +@synthesize viewportCenter; + +@synthesize world; + + +- (id) initWithFrame:(CGRect)frame { + if ((self = [super initWithFrame:frame])) { + zoomable = NO; + panable = NO; + viewportZoom = 1.0f; + viewportCenter = [[[SPPoint alloc] initWithX:0 y:0] autorelease]; + } + return self; +} + +- (void) drawView { + +} + +@end diff --git a/src/ui/Viewport.h b/src/ui/Viewport.h deleted file mode 100644 index 456b5e2..0000000 --- a/src/ui/Viewport.h +++ /dev/null @@ -1,26 +0,0 @@ -#import "Sparrow.h" - -#import "physics/World.h" - - -/** - * View subclass which optionally tracks user input gestures that would zoom - * or pan the viewport. - */ -@interface Viewport : SPView - -@property (nonatomic, retain) World* world; - -@property (nonatomic, assign, getter=isZoomable) BOOL zoomable; -@property (nonatomic, assign) float viewportZoom; - -@property (nonatomic, assign, getter=isPanable) BOOL panable; -@property (nonatomic, retain) SPPoint *viewportCenter; - - -- (void) drawView; - - -@end - - diff --git a/src/ui/Viewport.mm b/src/ui/Viewport.mm deleted file mode 100644 index f0c4eac..0000000 --- a/src/ui/Viewport.mm +++ /dev/null @@ -1,36 +0,0 @@ -#import -#import -#import - -#import "Sparrow.h" - -#import "Viewport.h" -#import "physics/World.h" - - -@implementation Viewport - -@synthesize zoomable; -@synthesize viewportZoom; - -@synthesize panable; -@synthesize viewportCenter; - -@synthesize world; - - -- (id) initWithFrame:(CGRect)frame { - if ((self = [super initWithFrame:frame])) { - zoomable = NO; - panable = NO; - viewportZoom = 1.0f; - viewportCenter = [[[SPPoint alloc] initWithX:0 y:0] autorelease]; - } - return self; -} - -- (void) drawView { - -} - -@end diff --git a/src/ui/iPad/AppDelegate_iPad.h b/src/ui/iPad/AppDelegate_iPad.h deleted file mode 100644 index 0fa5aee..0000000 --- a/src/ui/iPad/AppDelegate_iPad.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// AppDelegate_iPad.h -// tanks -// -// Created by dsc on 4/27/11. -// Copyright 2011 lttlst.com. All rights reserved. -// - -#import -#import "ui/AppDelegate.h" - -@interface AppDelegate_iPad : AppDelegate { - -} - -@end diff --git a/src/ui/iPad/AppDelegate_iPad.mm b/src/ui/iPad/AppDelegate_iPad.mm deleted file mode 100644 index ec4518d..0000000 --- a/src/ui/iPad/AppDelegate_iPad.mm +++ /dev/null @@ -1,18 +0,0 @@ -// -// AppDelegate_iPad.m -// tanks -// -// Created by dsc on 4/27/11. -// Copyright 2011 lttlst.com. All rights reserved. -// - -#import "AppDelegate_iPad.h" - -@implementation AppDelegate_iPad - -- (void)dealloc -{ - [super dealloc]; -} - -@end diff --git a/src/ui/iPad/QQAppDelegate_iPad.h b/src/ui/iPad/QQAppDelegate_iPad.h new file mode 100644 index 0000000..559c9ac --- /dev/null +++ b/src/ui/iPad/QQAppDelegate_iPad.h @@ -0,0 +1,16 @@ +// +// QQAppDelegate_iPad.h +// tanks +// +// Created by dsc on 4/27/11. +// Copyright 2011 lttlst.com. All rights reserved. +// + +#import +#import "ui/QQAppDelegate.h" + +@interface QQAppDelegate_iPad : QQAppDelegate { + +} + +@end diff --git a/src/ui/iPad/QQAppDelegate_iPad.mm b/src/ui/iPad/QQAppDelegate_iPad.mm new file mode 100644 index 0000000..d4d5226 --- /dev/null +++ b/src/ui/iPad/QQAppDelegate_iPad.mm @@ -0,0 +1,18 @@ +// +// QQAppDelegate_iPad.m +// tanks +// +// Created by dsc on 4/27/11. +// Copyright 2011 lttlst.com. All rights reserved. +// + +#import "QQAppDelegate_iPad.h" + +@implementation QQAppDelegate_iPad + +- (void)dealloc +{ + [super dealloc]; +} + +@end diff --git a/src/ui/iPad/en.lproj/MainWindow_iPad.xib b/src/ui/iPad/en.lproj/MainWindow_iPad.xib index eafdb9b..f0d386c 100644 --- a/src/ui/iPad/en.lproj/MainWindow_iPad.xib +++ b/src/ui/iPad/en.lproj/MainWindow_iPad.xib @@ -173,7 +173,7 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin {{202, 84}, {783, 772}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin - AppDelegate_iPad + QQAppDelegate_iPad com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -185,7 +185,7 @@ - AppDelegate + QQAppDelegate NSObject SPView @@ -203,15 +203,15 @@ IBProjectSource - ./Classes/AppDelegate.h + ./Classes/QQAppDelegate.h - AppDelegate_iPad - AppDelegate + QQAppDelegate_iPad + QQAppDelegate IBProjectSource - ./Classes/AppDelegate_iPad.h + ./Classes/QQAppDelegate_iPad.h diff --git a/src/ui/iPhone/AppDelegate_iPhone.h b/src/ui/iPhone/AppDelegate_iPhone.h deleted file mode 100644 index f18a22d..0000000 --- a/src/ui/iPhone/AppDelegate_iPhone.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// AppDelegate_iPhone.h -// tanks -// -// Created by dsc on 4/27/11. -// Copyright 2011 lttlst.com. All rights reserved. -// - -#import -#import "ui/AppDelegate.h" - -@interface AppDelegate_iPhone : AppDelegate { - -} - -@end diff --git a/src/ui/iPhone/AppDelegate_iPhone.mm b/src/ui/iPhone/AppDelegate_iPhone.mm deleted file mode 100644 index 250dd71..0000000 --- a/src/ui/iPhone/AppDelegate_iPhone.mm +++ /dev/null @@ -1,18 +0,0 @@ -// -// AppDelegate_iPhone.m -// tanks -// -// Created by dsc on 4/27/11. -// Copyright 2011 lttlst.com. All rights reserved. -// - -#import "AppDelegate_iPhone.h" - -@implementation AppDelegate_iPhone - -- (void)dealloc -{ - [super dealloc]; -} - -@end diff --git a/src/ui/iPhone/QQAppDelegate_iPhone.h b/src/ui/iPhone/QQAppDelegate_iPhone.h new file mode 100644 index 0000000..1c0e787 --- /dev/null +++ b/src/ui/iPhone/QQAppDelegate_iPhone.h @@ -0,0 +1,16 @@ +// +// QQAppDelegate_iPhone.h +// tanks +// +// Created by dsc on 4/27/11. +// Copyright 2011 lttlst.com. All rights reserved. +// + +#import +#import "ui/QQAppDelegate.h" + +@interface QQAppDelegate_iPhone : QQAppDelegate { + +} + +@end diff --git a/src/ui/iPhone/QQAppDelegate_iPhone.mm b/src/ui/iPhone/QQAppDelegate_iPhone.mm new file mode 100644 index 0000000..6993c4d --- /dev/null +++ b/src/ui/iPhone/QQAppDelegate_iPhone.mm @@ -0,0 +1,18 @@ +// +// QQAppDelegate_iPhone.m +// tanks +// +// Created by dsc on 4/27/11. +// Copyright 2011 lttlst.com. All rights reserved. +// + +#import "QQAppDelegate_iPhone.h" + +@implementation QQAppDelegate_iPhone + +- (void)dealloc +{ + [super dealloc]; +} + +@end diff --git a/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib b/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib index b9ee674..32443c1 100644 --- a/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib +++ b/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib @@ -170,7 +170,7 @@ {{520, 376}, {320, 480}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin - AppDelegate_iPhone + QQAppDelegate_iPhone com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin SPView @@ -185,7 +185,7 @@ - AppDelegate + QQAppDelegate NSObject SPView @@ -203,15 +203,15 @@ IBProjectSource - ./Classes/AppDelegate.h + ./Classes/QQAppDelegate.h - AppDelegate_iPhone - AppDelegate + QQAppDelegate_iPhone + QQAppDelegate IBProjectSource - ./Classes/AppDelegate_iPhone.h + ./Classes/QQAppDelegate_iPhone.h diff --git a/tanks.xcodeproj/project.pbxproj b/tanks.xcodeproj/project.pbxproj index b865a98..5e4aa20 100644 --- a/tanks.xcodeproj/project.pbxproj +++ b/tanks.xcodeproj/project.pbxproj @@ -8,8 +8,8 @@ /* Begin PBXBuildFile section */ 494DE9971376927C00FDB3D7 /* libBox2D.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 494DE9961376927C00FDB3D7 /* libBox2D.a */; }; - 4995ABB213816CCE00334646 /* Game.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A513812427007A6598 /* Game.h */; }; - 4995ABB313816CD400334646 /* Unit.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A213812427007A6598 /* Unit.h */; }; + 4995ABB213816CCE00334646 /* QQGame.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A513812427007A6598 /* QQGame.h */; }; + 4995ABB313816CD400334646 /* QQUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A213812427007A6598 /* QQUnit.h */; }; 499668C713692E2D006E8125 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499668C613692E2D006E8125 /* UIKit.framework */; }; 499668C913692E2D006E8125 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499668C813692E2D006E8125 /* Foundation.framework */; }; 499668CB13692E2D006E8125 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499668CA13692E2D006E8125 /* CoreGraphics.framework */; }; @@ -18,26 +18,26 @@ 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 */; }; - 49E834A713812427007A6598 /* Active.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E8349E13812427007A6598 /* Active.h */; }; - 49E834A813812427007A6598 /* Actor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A013812427007A6598 /* Actor.h */; }; - 49E834A913812427007A6598 /* Actor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834A113812427007A6598 /* Actor.mm */; }; - 49E834AB13812427007A6598 /* Unit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834A313812427007A6598 /* Unit.mm */; }; - 49E834AC13812427007A6598 /* Displayable.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A413812427007A6598 /* Displayable.h */; }; - 49E834AE13812427007A6598 /* Game.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834A613812427007A6598 /* Game.mm */; }; - 49E834BE13812555007A6598 /* AppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834B013812555007A6598 /* AppDelegate.h */; }; - 49E834BF13812555007A6598 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834B113812555007A6598 /* AppDelegate.mm */; }; - 49E834C013812555007A6598 /* AppDelegate_iPad.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834B313812555007A6598 /* AppDelegate_iPad.h */; }; - 49E834C113812555007A6598 /* AppDelegate_iPad.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834B413812555007A6598 /* AppDelegate_iPad.mm */; }; + 49DA67D4137847A7004841E9 /* QQWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DA67D2137847A7004841E9 /* QQWorld.h */; }; + 49DA67D5137847A7004841E9 /* QQWorld.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49DA67D3137847A7004841E9 /* QQWorld.mm */; }; + 49E834A713812427007A6598 /* QQActive.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E8349E13812427007A6598 /* QQActive.h */; }; + 49E834A813812427007A6598 /* QQActor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A013812427007A6598 /* QQActor.h */; }; + 49E834A913812427007A6598 /* QQActor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834A113812427007A6598 /* QQActor.mm */; }; + 49E834AB13812427007A6598 /* QQUnit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834A313812427007A6598 /* QQUnit.mm */; }; + 49E834AC13812427007A6598 /* QQDisplayable.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834A413812427007A6598 /* QQDisplayable.h */; }; + 49E834AE13812427007A6598 /* QQGame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834A613812427007A6598 /* QQGame.mm */; }; + 49E834BE13812555007A6598 /* QQAppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834B013812555007A6598 /* QQAppDelegate.h */; }; + 49E834BF13812555007A6598 /* QQAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834B113812555007A6598 /* QQAppDelegate.mm */; }; + 49E834C013812555007A6598 /* QQAppDelegate_iPad.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834B313812555007A6598 /* QQAppDelegate_iPad.h */; }; + 49E834C113812555007A6598 /* QQAppDelegate_iPad.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834B413812555007A6598 /* QQAppDelegate_iPad.mm */; }; 49E834C213812555007A6598 /* MainWindow_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 49E834B513812555007A6598 /* MainWindow_iPad.xib */; }; - 49E834C313812555007A6598 /* AppDelegate_iPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834B813812555007A6598 /* AppDelegate_iPhone.h */; }; - 49E834C413812555007A6598 /* AppDelegate_iPhone.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834B913812555007A6598 /* AppDelegate_iPhone.mm */; }; + 49E834C313812555007A6598 /* QQAppDelegate_iPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834B813812555007A6598 /* QQAppDelegate_iPhone.h */; }; + 49E834C413812555007A6598 /* QQAppDelegate_iPhone.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834B913812555007A6598 /* QQAppDelegate_iPhone.mm */; }; 49E834C513812555007A6598 /* MainWindow_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 49E834BA13812555007A6598 /* MainWindow_iPhone.xib */; }; - 49E834C613812555007A6598 /* Viewport.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834BC13812555007A6598 /* Viewport.h */; }; - 49E834C713812555007A6598 /* Viewport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834BD13812555007A6598 /* Viewport.mm */; }; - 49E834CD13814F7D007A6598 /* GLESDebugDraw.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834C913814F7D007A6598 /* GLESDebugDraw.h */; }; - 49E834CE13814F7D007A6598 /* GLESDebugDraw.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834CA13814F7D007A6598 /* GLESDebugDraw.mm */; }; + 49E834C613812555007A6598 /* QQViewport.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834BC13812555007A6598 /* QQViewport.h */; }; + 49E834C713812555007A6598 /* QQViewport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834BD13812555007A6598 /* QQViewport.mm */; }; + 49E834CD13814F7D007A6598 /* QQGLESDebugDraw.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834C913814F7D007A6598 /* QQGLESDebugDraw.h */; }; + 49E834CE13814F7D007A6598 /* QQGLESDebugDraw.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834CA13814F7D007A6598 /* QQGLESDebugDraw.mm */; }; 49E834D3138166A6007A6598 /* QQSparrowExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E834D1138166A6007A6598 /* QQSparrowExtensions.h */; }; 49E834D4138166A6007A6598 /* QQSparrowExtensions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49E834D2138166A6007A6598 /* QQSparrowExtensions.mm */; }; 49F2D9C413764666000B6B8C /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B013764666000B6B8C /* main.mm */; }; @@ -137,8 +137,8 @@ 49F2DADE13764ED6000B6B8C /* SPUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2DA8113764ED6000B6B8C /* SPUtils.m */; }; 49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DA1D13764ED5000B6B8C /* Sparrow.h */; }; 4B8B2A3213784D2D00CA4076 /* tank-pink.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B8B2A3113784D2D00CA4076 /* tank-pink.png */; }; - 4B8B2A50137D098500CA4076 /* AnimationContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A4E137D098500CA4076 /* AnimationContainer.h */; }; - 4B8B2A51137D098500CA4076 /* AnimationContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A4F137D098500CA4076 /* AnimationContainer.mm */; }; + 4B8B2A50137D098500CA4076 /* QQAnimationContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A4E137D098500CA4076 /* QQAnimationContainer.h */; }; + 4B8B2A51137D098500CA4076 /* QQAnimationContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A4F137D098500CA4076 /* QQAnimationContainer.mm */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -169,30 +169,30 @@ 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 = ""; }; - 49DA67D3137847A7004841E9 /* World.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = World.mm; sourceTree = ""; }; - 49E8349E13812427007A6598 /* Active.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Active.h; sourceTree = ""; }; - 49E834A013812427007A6598 /* Actor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Actor.h; sourceTree = ""; }; - 49E834A113812427007A6598 /* Actor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Actor.mm; sourceTree = ""; }; - 49E834A213812427007A6598 /* Unit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unit.h; sourceTree = ""; }; - 49E834A313812427007A6598 /* Unit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Unit.mm; sourceTree = ""; }; - 49E834A413812427007A6598 /* Displayable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Displayable.h; sourceTree = ""; }; - 49E834A513812427007A6598 /* Game.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Game.h; sourceTree = ""; }; - 49E834A613812427007A6598 /* Game.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Game.mm; sourceTree = ""; }; - 49E834B013812555007A6598 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 49E834B113812555007A6598 /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = ""; }; - 49E834B313812555007A6598 /* AppDelegate_iPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate_iPad.h; sourceTree = ""; }; - 49E834B413812555007A6598 /* AppDelegate_iPad.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate_iPad.mm; sourceTree = ""; }; + 49DA67D2137847A7004841E9 /* QQWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQWorld.h; sourceTree = ""; }; + 49DA67D3137847A7004841E9 /* QQWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQWorld.mm; sourceTree = ""; }; + 49E8349E13812427007A6598 /* QQActive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQActive.h; sourceTree = ""; }; + 49E834A013812427007A6598 /* QQActor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQActor.h; sourceTree = ""; }; + 49E834A113812427007A6598 /* QQActor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQActor.mm; sourceTree = ""; }; + 49E834A213812427007A6598 /* QQUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQUnit.h; sourceTree = ""; }; + 49E834A313812427007A6598 /* QQUnit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQUnit.mm; sourceTree = ""; }; + 49E834A413812427007A6598 /* QQDisplayable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQDisplayable.h; sourceTree = ""; }; + 49E834A513812427007A6598 /* QQGame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQGame.h; sourceTree = ""; }; + 49E834A613812427007A6598 /* QQGame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQGame.mm; sourceTree = ""; }; + 49E834B013812555007A6598 /* QQAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQAppDelegate.h; sourceTree = ""; }; + 49E834B113812555007A6598 /* QQAppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQAppDelegate.mm; sourceTree = ""; }; + 49E834B313812555007A6598 /* QQAppDelegate_iPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQAppDelegate_iPad.h; sourceTree = ""; }; + 49E834B413812555007A6598 /* QQAppDelegate_iPad.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQAppDelegate_iPad.mm; sourceTree = ""; }; 49E834B613812555007A6598 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow_iPad.xib; sourceTree = ""; }; - 49E834B813812555007A6598 /* AppDelegate_iPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate_iPhone.h; sourceTree = ""; }; - 49E834B913812555007A6598 /* AppDelegate_iPhone.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate_iPhone.mm; sourceTree = ""; }; + 49E834B813812555007A6598 /* QQAppDelegate_iPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQAppDelegate_iPhone.h; sourceTree = ""; }; + 49E834B913812555007A6598 /* QQAppDelegate_iPhone.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQAppDelegate_iPhone.mm; sourceTree = ""; }; 49E834BB13812555007A6598 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow_iPhone.xib; sourceTree = ""; }; - 49E834BC13812555007A6598 /* Viewport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Viewport.h; sourceTree = ""; }; - 49E834BD13812555007A6598 /* Viewport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Viewport.mm; sourceTree = ""; }; - 49E834C913814F7D007A6598 /* GLESDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLESDebugDraw.h; sourceTree = ""; }; - 49E834CA13814F7D007A6598 /* GLESDebugDraw.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GLESDebugDraw.mm; sourceTree = ""; }; - 49E834CB13814F7D007A6598 /* PhysicsDebugView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhysicsDebugView.h; sourceTree = ""; }; - 49E834CC13814F7D007A6598 /* PhysicsDebugView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PhysicsDebugView.mm; sourceTree = ""; }; + 49E834BC13812555007A6598 /* QQViewport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQViewport.h; sourceTree = ""; }; + 49E834BD13812555007A6598 /* QQViewport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQViewport.mm; sourceTree = ""; }; + 49E834C913814F7D007A6598 /* QQGLESDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQGLESDebugDraw.h; sourceTree = ""; }; + 49E834CA13814F7D007A6598 /* QQGLESDebugDraw.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQGLESDebugDraw.mm; sourceTree = ""; }; + 49E834CB13814F7D007A6598 /* QQPhysicsDebugView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQPhysicsDebugView.h; sourceTree = ""; }; + 49E834CC13814F7D007A6598 /* QQPhysicsDebugView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQPhysicsDebugView.mm; sourceTree = ""; }; 49E834D1138166A6007A6598 /* QQSparrowExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QQSparrowExtensions.h; sourceTree = ""; }; 49E834D2138166A6007A6598 /* QQSparrowExtensions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QQSparrowExtensions.mm; sourceTree = ""; }; 49F2D99B137645DF000B6B8C /* box2d-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "box2d-ios.xcodeproj"; path = "libs/box2d/box2d-ios.xcodeproj"; sourceTree = ""; }; @@ -295,8 +295,8 @@ 49F2DA8013764ED6000B6B8C /* SPUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUtils.h; sourceTree = ""; }; 49F2DA8113764ED6000B6B8C /* SPUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUtils.m; sourceTree = ""; }; 4B8B2A3113784D2D00CA4076 /* tank-pink.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "tank-pink.png"; path = "textures/tank-pink.png"; sourceTree = ""; }; - 4B8B2A4E137D098500CA4076 /* AnimationContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnimationContainer.h; path = animation/AnimationContainer.h; sourceTree = ""; }; - 4B8B2A4F137D098500CA4076 /* AnimationContainer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AnimationContainer.mm; path = animation/AnimationContainer.mm; sourceTree = ""; }; + 4B8B2A4E137D098500CA4076 /* QQAnimationContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QQAnimationContainer.h; path = animation/QQAnimationContainer.h; sourceTree = ""; }; + 4B8B2A4F137D098500CA4076 /* QQAnimationContainer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = QQAnimationContainer.mm; path = animation/QQAnimationContainer.mm; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -359,10 +359,10 @@ isa = PBXGroup; children = ( 49E8349F13812427007A6598 /* actor */, - 49E8349E13812427007A6598 /* Active.h */, - 49E834A413812427007A6598 /* Displayable.h */, - 49E834A513812427007A6598 /* Game.h */, - 49E834A613812427007A6598 /* Game.mm */, + 49E8349E13812427007A6598 /* QQActive.h */, + 49E834A413812427007A6598 /* QQDisplayable.h */, + 49E834A513812427007A6598 /* QQGame.h */, + 49E834A613812427007A6598 /* QQGame.mm */, ); path = game; sourceTree = ""; @@ -370,10 +370,10 @@ 49E8349F13812427007A6598 /* actor */ = { isa = PBXGroup; children = ( - 49E834A013812427007A6598 /* Actor.h */, - 49E834A113812427007A6598 /* Actor.mm */, - 49E834A213812427007A6598 /* Unit.h */, - 49E834A313812427007A6598 /* Unit.mm */, + 49E834A013812427007A6598 /* QQActor.h */, + 49E834A113812427007A6598 /* QQActor.mm */, + 49E834A213812427007A6598 /* QQUnit.h */, + 49E834A313812427007A6598 /* QQUnit.mm */, ); path = actor; sourceTree = ""; @@ -383,10 +383,10 @@ children = ( 49E834B213812555007A6598 /* iPad */, 49E834B713812555007A6598 /* iPhone */, - 49E834B013812555007A6598 /* AppDelegate.h */, - 49E834B113812555007A6598 /* AppDelegate.mm */, - 49E834BC13812555007A6598 /* Viewport.h */, - 49E834BD13812555007A6598 /* Viewport.mm */, + 49E834B013812555007A6598 /* QQAppDelegate.h */, + 49E834B113812555007A6598 /* QQAppDelegate.mm */, + 49E834BC13812555007A6598 /* QQViewport.h */, + 49E834BD13812555007A6598 /* QQViewport.mm */, ); path = ui; sourceTree = ""; @@ -394,8 +394,8 @@ 49E834B213812555007A6598 /* iPad */ = { isa = PBXGroup; children = ( - 49E834B313812555007A6598 /* AppDelegate_iPad.h */, - 49E834B413812555007A6598 /* AppDelegate_iPad.mm */, + 49E834B313812555007A6598 /* QQAppDelegate_iPad.h */, + 49E834B413812555007A6598 /* QQAppDelegate_iPad.mm */, 49E834B513812555007A6598 /* MainWindow_iPad.xib */, ); path = iPad; @@ -404,8 +404,8 @@ 49E834B713812555007A6598 /* iPhone */ = { isa = PBXGroup; children = ( - 49E834B813812555007A6598 /* AppDelegate_iPhone.h */, - 49E834B913812555007A6598 /* AppDelegate_iPhone.mm */, + 49E834B813812555007A6598 /* QQAppDelegate_iPhone.h */, + 49E834B913812555007A6598 /* QQAppDelegate_iPhone.mm */, 49E834BA13812555007A6598 /* MainWindow_iPhone.xib */, ); path = iPhone; @@ -414,10 +414,10 @@ 49E834C813814F7C007A6598 /* debug */ = { isa = PBXGroup; children = ( - 49E834C913814F7D007A6598 /* GLESDebugDraw.h */, - 49E834CA13814F7D007A6598 /* GLESDebugDraw.mm */, - 49E834CB13814F7D007A6598 /* PhysicsDebugView.h */, - 49E834CC13814F7D007A6598 /* PhysicsDebugView.mm */, + 49E834C913814F7D007A6598 /* QQGLESDebugDraw.h */, + 49E834CA13814F7D007A6598 /* QQGLESDebugDraw.mm */, + 49E834CB13814F7D007A6598 /* QQPhysicsDebugView.h */, + 49E834CC13814F7D007A6598 /* QQPhysicsDebugView.mm */, ); path = debug; sourceTree = ""; @@ -447,8 +447,8 @@ isa = PBXGroup; children = ( 49E834C813814F7C007A6598 /* debug */, - 49DA67D2137847A7004841E9 /* World.h */, - 49DA67D3137847A7004841E9 /* World.mm */, + 49DA67D2137847A7004841E9 /* QQWorld.h */, + 49DA67D3137847A7004841E9 /* QQWorld.mm */, ); path = physics; sourceTree = ""; @@ -706,8 +706,8 @@ 4B8B2A4D137D090D00CA4076 /* animation */ = { isa = PBXGroup; children = ( - 4B8B2A4E137D098500CA4076 /* AnimationContainer.h */, - 4B8B2A4F137D098500CA4076 /* AnimationContainer.mm */, + 4B8B2A4E137D098500CA4076 /* QQAnimationContainer.h */, + 4B8B2A4F137D098500CA4076 /* QQAnimationContainer.mm */, ); name = animation; sourceTree = ""; @@ -769,18 +769,18 @@ 49F2DADB13764ED6000B6B8C /* SPPoolObject.h in Headers */, 49F2DADD13764ED6000B6B8C /* SPUtils.h in Headers */, 49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */, - 49DA67D4137847A7004841E9 /* World.h in Headers */, - 4B8B2A50137D098500CA4076 /* AnimationContainer.h in Headers */, - 49E834A713812427007A6598 /* Active.h in Headers */, - 49E834A813812427007A6598 /* Actor.h in Headers */, - 49E834AC13812427007A6598 /* Displayable.h in Headers */, - 4995ABB213816CCE00334646 /* Game.h in Headers */, - 4995ABB313816CD400334646 /* Unit.h in Headers */, - 49E834BE13812555007A6598 /* AppDelegate.h in Headers */, - 49E834C013812555007A6598 /* AppDelegate_iPad.h in Headers */, - 49E834C313812555007A6598 /* AppDelegate_iPhone.h in Headers */, - 49E834C613812555007A6598 /* Viewport.h in Headers */, - 49E834CD13814F7D007A6598 /* GLESDebugDraw.h in Headers */, + 49DA67D4137847A7004841E9 /* QQWorld.h in Headers */, + 4B8B2A50137D098500CA4076 /* QQAnimationContainer.h in Headers */, + 49E834A713812427007A6598 /* QQActive.h in Headers */, + 49E834A813812427007A6598 /* QQActor.h in Headers */, + 49E834AC13812427007A6598 /* QQDisplayable.h in Headers */, + 4995ABB213816CCE00334646 /* QQGame.h in Headers */, + 4995ABB313816CD400334646 /* QQUnit.h in Headers */, + 49E834BE13812555007A6598 /* QQAppDelegate.h in Headers */, + 49E834C013812555007A6598 /* QQAppDelegate_iPad.h in Headers */, + 49E834C313812555007A6598 /* QQAppDelegate_iPhone.h in Headers */, + 49E834C613812555007A6598 /* QQViewport.h in Headers */, + 49E834CD13814F7D007A6598 /* QQGLESDebugDraw.h in Headers */, 49E834D3138166A6007A6598 /* QQSparrowExtensions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -911,17 +911,17 @@ 49F2DADA13764ED6000B6B8C /* SPNSExtensions.m in Sources */, 49F2DADC13764ED6000B6B8C /* SPPoolObject.m in Sources */, 49F2DADE13764ED6000B6B8C /* SPUtils.m in Sources */, - 49DA67D5137847A7004841E9 /* World.mm in Sources */, - 4B8B2A51137D098500CA4076 /* AnimationContainer.mm in Sources */, + 49DA67D5137847A7004841E9 /* QQWorld.mm in Sources */, + 4B8B2A51137D098500CA4076 /* QQAnimationContainer.mm in Sources */, 49F2D9C413764666000B6B8C /* main.mm in Sources */, - 49E834A913812427007A6598 /* Actor.mm in Sources */, - 49E834AB13812427007A6598 /* Unit.mm in Sources */, - 49E834AE13812427007A6598 /* Game.mm in Sources */, - 49E834BF13812555007A6598 /* AppDelegate.mm in Sources */, - 49E834C113812555007A6598 /* AppDelegate_iPad.mm in Sources */, - 49E834C413812555007A6598 /* AppDelegate_iPhone.mm in Sources */, - 49E834C713812555007A6598 /* Viewport.mm in Sources */, - 49E834CE13814F7D007A6598 /* GLESDebugDraw.mm in Sources */, + 49E834A913812427007A6598 /* QQActor.mm in Sources */, + 49E834AB13812427007A6598 /* QQUnit.mm in Sources */, + 49E834AE13812427007A6598 /* QQGame.mm in Sources */, + 49E834BF13812555007A6598 /* QQAppDelegate.mm in Sources */, + 49E834C113812555007A6598 /* QQAppDelegate_iPad.mm in Sources */, + 49E834C413812555007A6598 /* QQAppDelegate_iPhone.mm in Sources */, + 49E834C713812555007A6598 /* QQViewport.mm in Sources */, + 49E834CE13814F7D007A6598 /* QQGLESDebugDraw.mm in Sources */, 49E834D4138166A6007A6598 /* QQSparrowExtensions.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; -- 1.7.0.4