Permalink
Browse files

Removed moving ship code which was bugged

  • Loading branch information...
1 parent 13e0789 commit 9d6ed1100ec92661536859d73fcada5b6313e87f @mikedaley mikedaley committed Jan 25, 2012
View
BIN .DS_Store
Binary file not shown.
@@ -23,7 +23,7 @@
8F43E301145F1127004FBE6B /* plasmaEmitter.pex in Resources */ = {isa = PBXBuildFile; fileRef = 8F43E2FF145F1127004FBE6B /* plasmaEmitter.pex */; };
8F43E307145F1948004FBE6B /* PlasmaShot.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8F43E306145F1948004FBE6B /* PlasmaShot.mm */; };
8F528ED61432151900F7EAF8 /* Camera.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8F528ED51432151800F7EAF8 /* Camera.mm */; };
- 8F528EDA1432229400F7EAF8 /* SkyBox.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8F528ED91432229300F7EAF8 /* SkyBox.mm */; };
+ 8F528EDA1432229400F7EAF8 /* SkyBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F528ED91432229300F7EAF8 /* SkyBox.m */; };
8F531CF2141E643900118841 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F531CF1141E643900118841 /* UIKit.framework */; };
8F531CF4141E643900118841 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F531CF3141E643900118841 /* Foundation.framework */; };
8F531CF6141E643900118841 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F531CF5141E643900118841 /* CoreGraphics.framework */; };
@@ -165,7 +165,7 @@
8F528ED41432151800F7EAF8 /* Camera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Camera.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
8F528ED51432151800F7EAF8 /* Camera.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = Camera.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
8F528ED81432229300F7EAF8 /* SkyBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = SkyBox.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
- 8F528ED91432229300F7EAF8 /* SkyBox.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = SkyBox.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+ 8F528ED91432229300F7EAF8 /* SkyBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = SkyBox.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
8F531CED141E643900118841 /* GLKit_TD3D.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GLKit_TD3D.app; sourceTree = BUILT_PRODUCTS_DIR; };
8F531CF1141E643900118841 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8F531CF3141E643900118841 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -471,7 +471,7 @@
8F43E305145F1948004FBE6B /* PlasmaShot.h */,
8F43E306145F1948004FBE6B /* PlasmaShot.mm */,
8F528ED81432229300F7EAF8 /* SkyBox.h */,
- 8F528ED91432229300F7EAF8 /* SkyBox.mm */,
+ 8F528ED91432229300F7EAF8 /* SkyBox.m */,
8F528ED41432151800F7EAF8 /* Camera.h */,
8F528ED51432151800F7EAF8 /* Camera.mm */,
);
@@ -1006,7 +1006,7 @@
8F218D0514227FC40060C5AC /* EnemyFighter.mm in Sources */,
8FAFA3AA142F877A006913FD /* EnemyBomber.mm in Sources */,
8F528ED61432151900F7EAF8 /* Camera.mm in Sources */,
- 8F528EDA1432229400F7EAF8 /* SkyBox.mm in Sources */,
+ 8F528EDA1432229400F7EAF8 /* SkyBox.m in Sources */,
8F079AD11445E9A100B1AF3A /* ParticleEmitter.mm in Sources */,
8F079AD91445EAE800B1AF3A /* NSDataAdditions.m in Sources */,
8F079ADA1445EAE800B1AF3A /* TBXML.m in Sources */,
View
@@ -613,14 +613,14 @@ mikedaley
3473
-ParticleEmitter.mm
+SkyBox.h
file
-2011-11-06T16:40:15.000000Z
-3477f55e71498282f9675447724405bb
+2011-11-02T16:49:29.000000Z
+3a405bc8ec61c2e432941871c8ecc8bc
2011-11-06T18:13:36.424873Z
19
mikedaley
@@ -645,16 +645,16 @@ mikedaley
-24141
+1861
-SkyBox.h
+ParticleEmitter.mm
file
-2011-11-02T16:49:29.000000Z
-3a405bc8ec61c2e432941871c8ecc8bc
+2011-11-06T16:40:15.000000Z
+3477f55e71498282f9675447724405bb
2011-11-06T18:13:36.424873Z
19
mikedaley
@@ -679,7 +679,21 @@ mikedaley
-1861
+24141
+
+touchImage.png
+file
+0
+
+
+add
+
+
+
+
+
+has-props
+has-prop-mods
EnemyBomberTexture.png
file
@@ -715,20 +729,6 @@ has-props
917222
-touchImage.png
-file
-0
-
-
-add
-
-
-
-
-
-has-props
-has-prop-mods
-
SSGameSceneController.mm
file
25
@@ -768,7 +768,7 @@ file
-delete
+
2011-11-02T16:49:29.000000Z
c8e35b16d10e398c8a936ca92722d00b
2011-11-06T18:13:36.424873Z
@@ -865,16 +865,16 @@ mikedaley
2375
-AssetManager.mm
+SSMenuSceneController.h
file
-2011-11-07T20:05:08.000000Z
-bf9308b0772848915327889b1f9db755
-2011-11-08T12:34:53.999929Z
-22
+2011-11-02T16:50:58.000000Z
+268ba98b3fa72ee16a6670937db52360
+2011-11-06T18:13:36.424873Z
+19
mikedaley
@@ -897,7 +897,7 @@ mikedaley
-4967
+1240
skybox_texture.png
file
@@ -933,16 +933,16 @@ has-props
976751
-SSMenuSceneController.h
+AssetManager.mm
file
-2011-11-02T16:50:58.000000Z
-268ba98b3fa72ee16a6670937db52360
-2011-11-06T18:13:36.424873Z
-19
+2011-11-07T20:05:08.000000Z
+bf9308b0772848915327889b1f9db755
+2011-11-08T12:34:53.999929Z
+22
mikedaley
@@ -965,7 +965,7 @@ mikedaley
-1240
+4967
OpenGLCommon.h
file
@@ -1109,29 +1109,6 @@ mikedaley
2259
-SkyBox.mm
-file
-
-
-
-add
-
-c8e35b16d10e398c8a936ca92722d00b
-
-
-
-
-
-
-
-
-
-
-
-copied
-https://mikedaley@71squared.svn.beanstalkapp.com/games/trunk/GLKit_TD3D/GLKit_TD3D/SkyBox.m
-24
-
sparksEmitter.pex
file
View
@@ -72,7 +72,7 @@ - (id)initWithGameSceneController:(SSGameSceneController *)aGameSceneController
viewHeight = gameSceneController.view.bounds.size.height;
aspectRatio = viewWidth/viewHeight;
nearDistance = 0.1f;
- farDistance = 1000.0f;
+ farDistance = 500.0f;
// Create a 4x4 projection matrix. This will be used by all shaders as their projection matrix
projectionMatrix = GLKMatrix4MakePerspective(fieldOfView, aspectRatio, nearDistance, farDistance);
@@ -87,18 +87,9 @@ - (id)initWithGameSceneController:(SSGameSceneController *)aGameSceneController
- (void)updateWithModelMatrix:(GLKMatrix4)aModelMatrix {
- GLKMatrix4 collisionMatrix = GLKMatrix4Identity;
- collisionMatrix = GLKMatrix4Translate(collisionMatrix, gameSceneController.camera.position.x, gameSceneController.camera.position.y, gameSceneController.camera.position.z);
- collisionMatrix = GLKMatrix4Multiply(aModelMatrix, collisionMatrix);
-
- // Update the objects collision hull orientation with the same matrix used for the model
- basis.setFromOpenGLSubMatrix(collisionMatrix.m);
- collisionObject->getWorldTransform().setBasis(basis);
-
// Update the facing vector based on the rotation matrix
- aModelMatrix = GLKMatrix4Invert(collisionMatrix, nil);
- facingVector = GLKVector3Normalize(GLKMatrix4MultiplyVector3(collisionMatrix, facingIdentityVector));
-
+ aModelMatrix = GLKMatrix4Invert(aModelMatrix, nil);
+ facingVector = GLKVector3Normalize(GLKMatrix4MultiplyVector3(aModelMatrix, facingIdentityVector));
}
@@ -95,7 +95,6 @@ - (void)updateWithDelta:(GLfloat)aDelta {
// Decide if you want to fire the weapon at the player
if ((int)(10 * RANDOM_0_TO_1()) == 1) {
[gameSceneController fireWeaponFrom:position to:gameSceneController.camera.position];
-// NSLog(@"%f %f %f", gameSceneController.camera.position.x, gameSceneController.camera.position.y, gameSceneController.camera.position.z);
}
// Steer the model to the next waypoint
View
@@ -72,7 +72,7 @@ - (void)updateWithDelta:(GLfloat)aDelta {
// Increment a timer. If the particle is alive for more than 5 seconds then destroy it
timer += aDelta;
- if (timer >= 5) {
+ if (timer == 5000) {
timer = 0;
particleEmitter.active = NO;
[self removeFromCollisionWorld:gameSceneController.collisionWorld];
@@ -55,8 +55,6 @@
IBOutlet UIImageView *redSight;
IBOutlet UILabel *enemyShieldText;
IBOutlet UIImageView *touchImage;
- IBOutlet UIButton *thrustButton;
- IBOutlet UILabel *speedLabel;
GLKBaseEffect *particleEmitterEffect;
@@ -78,7 +76,5 @@
// location and run
- (void)explosionAt:(GLKVector3)aVector;
-- (IBAction)thrusterFiring:(id)sender;
-- (IBAction)thrusterStopped:(id)sender;
@end
@@ -69,11 +69,7 @@ @interface SSGameSceneController () {
uint firingTouchHash; // Tracks the touch that caused the player to fire
uint enemyShield; // Holds the shiled of the currently target enemy
-
- BOOL thrusterOn; // YES if the thruster button is being pressed
- float speed; // The current speed of the player
- GLKMatrix4 deviceMatrix; // Holds the gyros roation matrix for the device
}
#pragma mark - Private Properties
@@ -182,8 +178,6 @@ - (void)viewDidUnload {
redSight = nil;
enemyShieldText = nil;
touchImage = nil;
- thrustButton = nil;
- speedLabel = nil;
[super viewDidUnload];
}
@@ -315,6 +309,7 @@ - (void)update {
CMRotationMatrix rm = attitude.rotationMatrix;
// Create a GLKMatrix4 that we will apply to our models so that they are rendered in relation to where the device is pointing
+ GLKMatrix4 deviceMatrix;
deviceMatrix = GLKMatrix4Make(rm.m11, rm.m21, rm.m31, 0,
rm.m12, rm.m22, rm.m32, 0,
rm.m13, rm.m23, rm.m33, 0,
@@ -331,33 +326,20 @@ - (void)update {
sceneModelMatrix = GLKMatrix4Multiply(sceneModelMatrix, deviceMatrix);
}
- // While the thrust button is pressed increase speed to the max. If the button is not pressed then reduce
- // speed
- if (thrusterOn) {
- if (speed + 0.001f <= 0.5f)
- speed += 0.001f;
- } else {
- if (speed - 0.001f >= 0)
- speed -= 0.001f;
- }
-
- // Adjust the cameras location
- camera.position = GLKVector3Add(camera.position, GLKVector3MultiplyScalar(GLKVector3Negate(camera.facingVector), speed));
-
// Move to the cameras location
sceneModelMatrix = GLKMatrix4Translate(sceneModelMatrix, camera.position.x, camera.position.y, camera.position.z);
-
+
// Update the camera based on the rotation of the device which is now held in the sceneModelMatrix
- [camera updateWithModelMatrix:deviceMatrix];
-
+ [camera updateWithModelMatrix:sceneModelMatrix];
+
// Check to see if the gun sight is lined up
enemyInSights = [self checkGunSight];
// Having calculated the SceneModelMatrix based on the gyro, set the base effects model matrix and set the lights position.
// This ensures that the lights position is calculated correctly for all rendering from this point onwards on the scenes objects
self.effect.transform.modelviewMatrix = sceneModelMatrix;
self.effect.light0.position = GLKVector4Make(0, 0, 1, 0);
-
+
// Update the logic of each object in the scene. They all inherit from SSAbstractObject so we can treat each object as an
// SSAbstractObject
for (SSAbstractObject *object in objects) {
@@ -398,9 +380,8 @@ - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- // Transform and render the skybox. We pass in the deviceMatrix as we are only interested in rotation for the skybox
- // as it's always located at the cameras position
- [skybox renderWithModelMatrix:deviceMatrix gameScene:self];
+ // Transform and render the skybox
+ [skybox renderWithModelMatrix:sceneModelMatrix];
// Render ships
[objects makeObjectsPerformSelector:@selector(render)];
@@ -441,9 +422,6 @@ - (void)renderHUD {
whiteSight.hidden = NO;
enemyShieldText.hidden = YES;
}
-
- // Update the ships speed
- [speedLabel setText:[NSString stringWithFormat:@"Speed: %1.2f", speed]];
}
@@ -578,14 +556,6 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
}
-- (IBAction)thrusterFiring:(id)sender {
- thrusterOn = YES;
-}
-
-- (IBAction)thrusterStopped:(id)sender {
- thrusterOn = NO;
-}
-
#pragma mark - Init Core Motion, Physics world and Game Scene
#pragma mark - Initialize Scene
@@ -659,8 +629,6 @@ - (void)initScene {
// By default the player is not firing
firing = NO;
- thrusterOn = NO;
-
}
- (void)initCoreMotion {
Oops, something went wrong.

0 comments on commit 9d6ed11

Please sign in to comment.