+++ /dev/null
-#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
/**
- * Anything that takes a turn is Active.
+ * Anything that takes a turn is QQActive.
*/
-@protocol Active
+@protocol QQActive
@property (nonatomic, getter=isActive) BOOL active;
#import "Sparrow.h"
-@protocol Displayable
+@protocol QQDisplayable
@property (nonatomic, retain, readonly) SPDisplayObject* shape;
--- /dev/null
+#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
-#import "Game.h"
-#import "game/actor/Unit.h"
+#import "QQGame.h"
+#import "game/actor/QQUnit.h"
-static Game* _currentGame = NULL;
+static QQGame* _currentGame = NULL;
-@interface Game ()
-@property (nonatomic, retain) Unit* unit;
+@interface QQGame ()
+@property (nonatomic, retain) QQUnit* unit;
@end
-@implementation Game
+@implementation QQGame
@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!"];
+ [NSException raise:@"TooManyGames" format:@"cannot instantiate more than one QQGame at a time!"];
}
if ( (self = [super init]) ){
_currentGame = self;
ticks = 0l;
- _world = [[World alloc] init];
+ _world = [[QQWorld alloc] init];
[self addEventListener:@selector(onEnterFrame:) atObject:self forType:SP_EVENT_TYPE_ENTER_FRAME];
- _unit = [[Unit alloc] init];
+ _unit = [[QQUnit alloc] init];
// [self addEventListener:@selector(onTouch:) atObject:_unit forType:SP_EVENT_TYPE_TOUCH];
// if (_unit.shape) [self addChild:_unit.shape];
}
[self.world step];
}
-+ (Game*) current {
++ (QQGame*) current {
if (!_currentGame)
- [[[Game alloc] init] // init assigns to singleton, but singleton is a weakref,
+ [[[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;
}
+++ /dev/null
-#import "game/Active.h"
-#import "game/Displayable.h"
-#import "physics/World.h"
-
-@class Game;
-
-
-@interface Actor : NSObject <Active, Displayable> {
-
-@private
- BOOL _active;
-}
-
-@property (nonatomic, readonly) Game* game;
-@property (nonatomic, readonly) World* world;
-
-
-
-@end
+++ /dev/null
-#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
--- /dev/null
+#import "game/QQActive.h"
+#import "game/QQDisplayable.h"
+#import "physics/QQWorld.h"
+
+@class QQGame;
+
+
+@interface QQActor : NSObject <QQActive, QQDisplayable> {
+
+@private
+ BOOL _active;
+}
+
+@property (nonatomic, readonly) QQGame* game;
+@property (nonatomic, readonly) QQWorld* world;
+
+
+
+@end
--- /dev/null
+#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
#import "Sparrow.h"
#import "render/QQSparrowExtensions.h"
-#import "game/actor/Actor.h"
-#import "physics/World.h"
+#import "game/actor/QQActor.h"
+#import "physics/QQWorld.h"
-@interface Unit : Actor {
+@interface QQUnit : QQActor {
@private
SPDisplayObject* _shape;
#import "Sparrow.h"
-#import "Unit.h"
+#import "QQUnit.h"
-@implementation Unit
+@implementation QQUnit
@synthesize shape = _shape;
#include <Box2D/Box2D.h>
-#import "physics/debug/GLESDebugDraw.h"
+#import "physics/debug/QQGLESDebugDraw.h"
-@interface World : NSObject {
+@interface QQWorld : NSObject {
@private
float _timestep;
int _positionIterations;
b2World* _world;
- GLESDebugDraw debugDraw;
+ QQGLESDebugDraw debugDraw;
}
@property (nonatomic, readonly) b2World* world;
@property (nonatomic, assign) int positionIterations;
-- (World*) init;
-- (World*) initWithTimestep:(float)hz;
-- (World*) initWithTimestep:(float)hz gravityX:(float)x y:(float)y;
+- (QQWorld*) init;
+- (QQWorld*) initWithTimestep:(float)hz;
+- (QQWorld*) initWithTimestep:(float)hz gravityX:(float)x y:(float)y;
- (void) setGravityX:(float)x y:(float)y;
-#import "World.h"
+#import "QQWorld.h"
-@implementation World
+@implementation QQWorld
@synthesize world = _world;
@synthesize timestep = _timestep;
@synthesize positionIterations = _positionIterations;
-- (World*) init {
+- (QQWorld*) init {
return [self initWithTimestep:60.0f];
}
-- (World*) initWithTimestep:(float)hz {
+- (QQWorld*) initWithTimestep:(float)hz {
return [self initWithTimestep:hz gravityX:0.0f y:0.0f];
}
-- (World*) initWithTimestep:(float)hz gravityX:(float)x y:(float)y {
+- (QQWorld*) initWithTimestep:(float)hz gravityX:(float)x y:(float)y {
if ((self = [super init])) {
_timestep = 1.0f/hz;
_velocityIterations = 10;
// This class implements debug drawing callbacks that are invoked
// inside b2World::Step.
-class GLESDebugDraw : public b2DebugDraw
+class QQGLESDebugDraw : public b2DebugDraw
{
public:
void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color);
* 3. This notice may not be removed or altered from any source distribution.
*/
-#include "GLESDebugDraw.h"
+#include "QQGLESDebugDraw.h"
#include <cstdio>
#include <cstring>
-void GLESDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
+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 GLESDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
+void QQGLESDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(GL_LINE_LOOP, 0, vertexCount);
}
-void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
+void QQGLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
{
const float32 k_segments = 16.0f;
int vertexCount=16;
glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount);
}
-void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color)
+void QQGLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color)
{
const float32 k_segments = 16.0f;
int vertexCount=16;
DrawSegment(center,center+radius*axis,color);
}
-void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color)
+void QQGLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color)
{
glColor4f(color.r, color.g, color.b,1);
GLfloat glVertices[] = {
glDrawArrays(GL_LINES, 0, 2);
}
-void GLESDebugDraw::DrawTransform(const b2Transform& xf)
+void QQGLESDebugDraw::DrawTransform(const b2Transform& xf)
{
b2Vec2 p1 = xf.position, p2;
const float32 k_axisScale = 0.4f;
DrawSegment(p1,p2,b2Color(0,1,0));
}
-void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color)
+void QQGLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color)
{
glColor4f(color.r, color.g, color.b,1);
glPointSize(size);
glPointSize(1.0f);
}
-void GLESDebugDraw::DrawString(int x, int y, const char *string, ...)
+void QQGLESDebugDraw::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)
+void QQGLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& c)
{
glColor4f(c.r, c.g, c.b,1);
#include <Box2D/Box2D.h>
-#import "physics/PhysicsView.h"
+#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 PhysicsDebugView : PhysicsView {}
+@interface QQPhysicsDebugView : QQPhysicsView {}
@property (nonatomic, readonly, getter=isRunning) BOOL running;
@property (nonatomic, assign) NSTimeInterval animationInterval;
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
-#import "PhysicsDebugView.h"
+#import "QQPhysicsDebugView.h"
#define USE_DEPTH_BUFFER 0
// A class extension to declare private methods
-@interface PhysicsDebugView () {
+@interface QQPhysicsDebugView () {
@private
- World* _world;
+ QQWorld* _world;
BOOL _running;
NSTimer* animationTimer;
-@implementation PhysicsDebugView
+@implementation QQPhysicsDebugView
@synthesize world = _world;
@synthesize running = _running;
#import "SPTextureAtlas.h"
////////////////////////////////////////////////////////////////////////////////////
-@interface AnimationContainer : NSObject <NSXMLParserDelegate> {
+@interface QQAnimationContainer : NSObject <NSXMLParserDelegate> {
}
////////////////////////////////////////////////////////////////////////////////////
-#import "AnimationContainer.h"
+#import "QQAnimationContainer.h"
#import "SPMovieClip.h"
////////////////////////////////////////////////////////////////////////////////////
// private method
-@interface AnimationContainer()
+@interface QQAnimationContainer()
-(void)parseContentXml:(NSString *)contentPath;
////////////////////////////////////////////////////////////////////////////////////
-@implementation AnimationContainer
+@implementation QQAnimationContainer
////////////////////////////////////////////////////////////////////////////////////
@synthesize mAnimationLookup;
#import "Sparrow.h"
-#import "game/Game.h"
+#import "game/QQGame.h"
-@interface AppDelegate : NSObject <UIApplicationDelegate>
+@interface QQAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow* window;
SPView* sparrowView;
- Game* _game;
+ QQGame* _game;
}
@property (nonatomic, retain) IBOutlet UIWindow* window;
@property (nonatomic, retain) IBOutlet SPView* sparrowView;
-@property (nonatomic, retain) Game* game;
+@property (nonatomic, retain) QQGame* game;
@end
\ No newline at end of file
//
-// AppDelegate.m
+// QQAppDelegate.m
// tanks
//
// Created by dsc on 4/27/11.
// Copyright 2011 lttlst.com. All rights reserved.
//
-#import "AppDelegate.h"
-#import "game/Game.h"
+#import "QQAppDelegate.h"
+#import "game/QQGame.h"
-@implementation AppDelegate
+@implementation QQAppDelegate
@synthesize window;
@synthesize sparrowView;
sparrowView.frameRate = 60.0f;
&