Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed perspective to first-person

  • Loading branch information...
commit 8041a1e9d928b6a8f641c2253a7350daf53bec56 1 parent 99ae195
@jakeboxer authored
View
30 SubwaySlide.xcodeproj/project.pbxproj
@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
+ 23335ED41339682E00450E90 /* bg_subway-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = 23335ED21339682E00450E90 /* bg_subway-hd.png */; };
+ 23335ED51339682E00450E90 /* bg_subway.png in Resources */ = {isa = PBXBuildFile; fileRef = 23335ED31339682E00450E90 /* bg_subway.png */; };
23B4512913381ED60096FD8D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23B4512813381ED60096FD8D /* QuartzCore.framework */; };
23B4512B13381ED60096FD8D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23B4512A13381ED60096FD8D /* OpenGLES.framework */; };
23B4512D13381ED60096FD8D /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23B4512C13381ED60096FD8D /* OpenAL.framework */; };
@@ -113,7 +115,6 @@
23B4528113381ED80096FD8D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B4528013381ED80096FD8D /* AppDelegate.m */; };
23B4528413381ED80096FD8D /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B4528313381ED80096FD8D /* RootViewController.m */; };
23B452931338260B0096FD8D /* GameLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B452921338260B0096FD8D /* GameLayer.m */; };
- 23B4529713382BB70096FD8D /* Player.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B4529613382BB70096FD8D /* Player.m */; };
23E31E51133831A400D4C438 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E47133831A400D4C438 /* Default.png */; };
23E31E52133831A400D4C438 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E48133831A400D4C438 /* fps_images.png */; };
23E31E53133831A400D4C438 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E49133831A400D4C438 /* Icon-72.png */; };
@@ -123,11 +124,11 @@
23E31E57133831A400D4C438 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E4D133831A400D4C438 /* Icon.png */; };
23E31E58133831A400D4C438 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E4E133831A400D4C438 /* Icon@2x.png */; };
23E31E5A133831A400D4C438 /* iTunesArtwork in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E50133831A400D4C438 /* iTunesArtwork */; };
- 23E31E601338337100D4C438 /* player-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E5E1338337100D4C438 /* player-hd.png */; };
- 23E31E611338337100D4C438 /* player.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E31E5F1338337100D4C438 /* player.png */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 23335ED21339682E00450E90 /* bg_subway-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "bg_subway-hd.png"; sourceTree = "<group>"; };
+ 23335ED31339682E00450E90 /* bg_subway.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bg_subway.png; sourceTree = "<group>"; };
23B4512413381ED60096FD8D /* SubwaySlide.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SubwaySlide.app; sourceTree = BUILT_PRODUCTS_DIR; };
23B4512813381ED60096FD8D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
23B4512A13381ED60096FD8D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
@@ -349,8 +350,6 @@
23B4528813381ED80096FD8D /* GameConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameConfig.h; sourceTree = "<group>"; };
23B452911338260B0096FD8D /* GameLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameLayer.h; sourceTree = "<group>"; };
23B452921338260B0096FD8D /* GameLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameLayer.m; sourceTree = "<group>"; };
- 23B4529513382BB70096FD8D /* Player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Player.h; sourceTree = "<group>"; };
- 23B4529613382BB70096FD8D /* Player.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Player.m; sourceTree = "<group>"; };
23E31E47133831A400D4C438 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
23E31E48133831A400D4C438 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; };
23E31E49133831A400D4C438 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = "<group>"; };
@@ -361,8 +360,6 @@
23E31E4E133831A400D4C438 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = "<group>"; };
23E31E4F133831A400D4C438 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
23E31E50133831A400D4C438 /* iTunesArtwork */ = {isa = PBXFileReference; lastKnownFileType = file; path = iTunesArtwork; sourceTree = "<group>"; };
- 23E31E5E1338337100D4C438 /* player-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "player-hd.png"; sourceTree = "<group>"; };
- 23E31E5F1338337100D4C438 /* player.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = player.png; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -384,6 +381,15 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ 23335ED01339681200450E90 /* Backgrounds */ = {
+ isa = PBXGroup;
+ children = (
+ 23335ED21339682E00450E90 /* bg_subway-hd.png */,
+ 23335ED31339682E00450E90 /* bg_subway.png */,
+ );
+ path = Backgrounds;
+ sourceTree = "<group>";
+ };
23B4511913381ED60096FD8D = {
isa = PBXGroup;
children = (
@@ -722,8 +728,6 @@
23B4529413382B4E0096FD8D /* Game Objects */ = {
isa = PBXGroup;
children = (
- 23B4529513382BB70096FD8D /* Player.h */,
- 23B4529613382BB70096FD8D /* Player.m */,
);
path = "Game Objects";
sourceTree = "<group>";
@@ -731,6 +735,7 @@
23E31E5B133831E600D4C438 /* Images */ = {
isa = PBXGroup;
children = (
+ 23335ED01339681200450E90 /* Backgrounds */,
23E31E5D1338328F00D4C438 /* Game Objects */,
23E31E5C1338324000D4C438 /* Icons */,
23E31E47133831A400D4C438 /* Default.png */,
@@ -755,8 +760,6 @@
23E31E5D1338328F00D4C438 /* Game Objects */ = {
isa = PBXGroup;
children = (
- 23E31E5E1338337100D4C438 /* player-hd.png */,
- 23E31E5F1338337100D4C438 /* player.png */,
);
path = "Game Objects";
sourceTree = "<group>";
@@ -817,8 +820,8 @@
23E31E57133831A400D4C438 /* Icon.png in Resources */,
23E31E58133831A400D4C438 /* Icon@2x.png in Resources */,
23E31E5A133831A400D4C438 /* iTunesArtwork in Resources */,
- 23E31E601338337100D4C438 /* player-hd.png in Resources */,
- 23E31E611338337100D4C438 /* player.png in Resources */,
+ 23335ED41339682E00450E90 /* bg_subway-hd.png in Resources */,
+ 23335ED51339682E00450E90 /* bg_subway.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -927,7 +930,6 @@
23B4528113381ED80096FD8D /* AppDelegate.m in Sources */,
23B4528413381ED80096FD8D /* RootViewController.m in Sources */,
23B452931338260B0096FD8D /* GameLayer.m in Sources */,
- 23B4529713382BB70096FD8D /* Player.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
10 SubwaySlide/Classes/Game Objects/Player.h
@@ -1,10 +0,0 @@
-#import "cocos2d.h"
-
-@interface Player : NSObject {
-@private
- CCSprite* _sprite;
-}
-
-@property (nonatomic, retain) CCSprite* sprite;
-
-@end
View
26 SubwaySlide/Classes/Game Objects/Player.m
@@ -1,26 +0,0 @@
-#import "Player.h"
-
-@implementation Player
-
-@synthesize sprite = _sprite;
-
-#pragma mark -
-#pragma mark Creation/Removal Methods
-
-- (id)init {
- self = [super init];
-
- if (nil != self) {
- self.sprite = [CCSprite spriteWithFile:@"player.png"];
- }
-
- return self;
-}
-
-- (void)dealloc {
- [_sprite release];
-
- [super dealloc];
-}
-
-@end
View
3  SubwaySlide/Classes/Layers/GameLayer.h
@@ -4,9 +4,8 @@
@interface GameLayer : CCLayer {
@private
+ float _accelerometerVelocity;
BOOL _canChangeSubwayVelocity;
- Player* _player;
- float _playerRotationVelocity;
float _subwayVelocity;
CCLabelTTF* _subwayVelocityLabel;
}
View
41 SubwaySlide/Classes/Layers/GameLayer.m
@@ -1,11 +1,9 @@
#import "GameLayer.h"
-#import "Player.h"
@interface GameLayer ()
+@property (nonatomic, assign) float accelerometerVelocity;
@property (nonatomic, assign) BOOL canChangeSubwayVelocity;
-@property (nonatomic, retain) Player* player;
-@property (nonatomic, assign) float playerRotationVelocity;
@property (nonatomic, assign) float subwayVelocity;
@property (nonatomic, assign) CCLabelTTF* subwayVelocityLabel;
@@ -18,9 +16,8 @@ - (void)update:(ccTime)dt;
@implementation GameLayer
+@synthesize accelerometerVelocity = _accelerometerVelocity;
@synthesize canChangeSubwayVelocity = _canChangeSubwayVelocity;
-@synthesize player = _player;
-@synthesize playerRotationVelocity = _playerRotationVelocity;
@synthesize subwayVelocity = _subwayVelocity;
@synthesize subwayVelocityLabel = _subwayVelocityLabel;
@@ -43,10 +40,10 @@ - (id)init {
self.isAccelerometerEnabled = YES;
self.canChangeSubwayVelocity = YES;
- self.player = [[[Player alloc] init] autorelease];
- self.player.sprite.anchorPoint = ccp(0.5, 0);
- self.player.sprite.position = ccp(winSize.width * 0.25f, 0);
- [self addChild:self.player.sprite];
+ // Background
+ CCSprite* background = [CCSprite spriteWithFile:@"bg_subway.png"];
+ background.position = ccp(winSize.width * 0.5, winSize.height * 0.5);
+ [self addChild:background z:-1];
self.subwayVelocityLabel = [CCLabelTTF labelWithString:@"Go!" fontName:@"Helvetica" fontSize:24];
self.subwayVelocityLabel.position = ccp(winSize.width * 0.5,
@@ -60,17 +57,11 @@ - (id)init {
return self;
}
-- (void)dealloc {
- [_player release];
-
- [super dealloc];
-}
-
#pragma mark -
#pragma mark Scheduled Methods
- (void)considerChangingSubwayVelocity:(ccTime)dt {
- if (self.canChangeSubwayVelocity && CCRANDOM_0_1() > 0.25) {
+ if (self.canChangeSubwayVelocity && CCRANDOM_0_1() < 0.25) {
self.canChangeSubwayVelocity = NO;
float newVelocity = MAX(-100, MIN(100, CCRANDOM_MINUS1_1() * 2.5));
@@ -87,19 +78,19 @@ - (void)considerChangingSubwayVelocity:(ccTime)dt {
}
- (void)update:(ccTime)dt {
- float newRotation = self.player.sprite.rotation - (self.playerRotationVelocity + self.subwayVelocity);
+ float newRotation = self.rotation - (self.accelerometerVelocity + self.subwayVelocity);
if (newRotation > 90.0f) {
newRotation = 90.0f;
- self.playerRotationVelocity = 0;
+ self.accelerometerVelocity = 0;
self.subwayVelocity = 0;
} else if (newRotation < -90.0f) {
newRotation = -90.0f;
- self.playerRotationVelocity = 0;
+ self.accelerometerVelocity = 0;
self.subwayVelocity = 0;
}
- self.player.sprite.rotation = newRotation;
+ self.rotation = newRotation;
}
#pragma mark -
@@ -116,7 +107,7 @@ - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAccelerat
float maxVelocity = 100;
// Adjust velocity based on current accelerometer acceleration
- float newVelocity = (self.playerRotationVelocity * deceleration) + (acceleration.y * sensitivity);
+ float newVelocity = (self.accelerometerVelocity * deceleration) + (acceleration.y * sensitivity);
// We must limit the max velocity of the player sprite in both directions
if (newVelocity > maxVelocity) {
@@ -125,7 +116,7 @@ - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAccelerat
newVelocity = -maxVelocity;
}
- self.playerRotationVelocity = newVelocity;
+ self.accelerometerVelocity = newVelocity;
}
#pragma mark -
@@ -136,15 +127,15 @@ - (void)allowChangingSubwayVelocity {
}
- (void)changeSubwayVelocityTo:(NSNumber*)newVelocity {
- self.subwayVelocity = [newVelocity floatValue];
+ float newVelocityFloat = [newVelocity floatValue];
- if ([newVelocity floatValue] > self.subwayVelocity) {
+ if (newVelocityFloat > self.subwayVelocity) {
[self.subwayVelocityLabel setString:@"Speeding up!"];
} else {
[self.subwayVelocityLabel setString:@"Slowing down!"];
}
- self.subwayVelocity = [newVelocity floatValue];
+ self.subwayVelocity = newVelocityFloat;
[self performSelector:@selector(allowChangingSubwayVelocity)
withObject:nil
View
BIN  SubwaySlide/Resources/Images/Backgrounds/bg_subway-hd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  SubwaySlide/Resources/Images/Backgrounds/bg_subway.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  SubwaySlide/Resources/Images/Game Objects/player-hd.png
Deleted file not rendered
View
BIN  SubwaySlide/Resources/Images/Game Objects/player.png
Deleted file not rendered
Please sign in to comment.
Something went wrong with that request. Please try again.