Skip to content

Commit

Permalink
open source version of canabalt
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Johnson committed Dec 30, 2010
0 parents commit a74cf9a
Show file tree
Hide file tree
Showing 468 changed files with 24,564 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*~
build
*.pbxuser
*.mode1v3
.DS_Store

42 changes: 42 additions & 0 deletions Canabalt-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>icon.png</string>
<key>CFBundleIconFiles</key>
<array>
<string>icon.png</string>
<string>canabalt_icon_72x72.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>com.semisecretsoftware.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.6</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UIPrerenderedIcon</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
1,130 changes: 1,130 additions & 0 deletions Canabalt.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions Canabalt_Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Canabalt_Prefix.pch
// Canabalt
//
// Copyright Semi Secret Software 2009-2010. All rights reserved.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

//
// Prefix header for all source files of the 'Canabalt' target in the 'Canabalt' project
//

#import <Availability.h>

#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <Flixel/Flixel.h>
#import "UIImage+RIFAddition.h"
#endif
27 changes: 27 additions & 0 deletions Classes/CanabaltAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// CanabaltAppDelegate.h
// Canabalt
//
// Copyright Semi Secret Software 2009-2010. All rights reserved.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import <UIKit/UIKit.h>
#import <Flixel/Flixel.h>

@class Canabalt;

@interface CanabaltAppDelegate : NSObject <UIApplicationDelegate>
{
Canabalt * game;
}

@end

100 changes: 100 additions & 0 deletions Classes/CanabaltAppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// CanabaltAppDelegate.m
// Canabalt
//
// Copyright Semi Secret Software 2009-2010. All rights reserved.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import "CanabaltAppDelegate.h"
#import "Canabalt.h"

#import <SemiSecret/SemiSecretTexture.h>

void preloadTextureAtlases()
{
NSDictionary * infoDictionary = nil;
if (FlxG.iPad)
infoDictionary = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"iPadTextureAtlas.atlas"]];
else
infoDictionary = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"textureAtlas.atlas"]];

//can only contain NSData, NSDate, NSNumber, NSString, NSArray, and NSDictionary

NSDictionary * images = [infoDictionary objectForKey:@"images"];

for (NSString * image in images) {
NSDictionary * imageInfo = [images objectForKey:image];
CGRect placement;
placement.origin.x = [[imageInfo objectForKey:@"placement.origin.x"] floatValue];
placement.origin.y = [[imageInfo objectForKey:@"placement.origin.y"] floatValue];
placement.size.width = [[imageInfo objectForKey:@"placement.size.width"] floatValue];
placement.size.height = [[imageInfo objectForKey:@"placement.size.height"] floatValue];
NSString * atlas = [imageInfo objectForKey:@"atlas"];
SemiSecretTexture * textureAtlas = [FlxG addTextureWithParam1:atlas param2:NO];
SemiSecretTexture * texture = [SemiSecretTexture textureWithAtlasTexture:textureAtlas
offset:placement.origin
size:placement.size];
[FlxG setTexture:texture forKey:image];
}

}

@implementation CanabaltAppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

//in canabalt, we never want linear filtering (not even on ipad)
[SemiSecretTexture setTextureFilteringMode:SSTextureFilteringNearest];

[application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight
animated:NO];

game = [[Canabalt alloc] init];

//preload textures here, now that opengl stuff should be created
preloadTextureAtlases();

return YES;
}

- (void) applicationDidEnterBackground:(UIApplication *)application
{
[FlxG didEnterBackground];
}

- (void) applicationWillEnterForeground:(UIApplication *)application
{
[FlxG willEnterForeground];
}

- (void) applicationWillResignActive:(UIApplication *)application
{
[FlxG willResignActive];
}

- (void) applicationDidBecomeActive:(UIApplication *)application
{
[FlxG didBecomeActive];
}

- (void) applicationWillTerminate:(UIApplication *)application
{
}

- (void) dealloc
{
[game release];
[super dealloc];
}

@end
22 changes: 22 additions & 0 deletions Classes/UIImage+RIFAddition.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// UIImage+RIFAddition.h
// Canabalt
//
// Copyright Semi Secret Software 2009-2010. All rights reserved.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import <UIKit/UIKit.h>

@interface UIImage (RIFAddition)
- (id)initWithContentsOfResolutionIndependentFile:(NSString *)path;
+ (UIImage *) imageWithContentsOfResolutionIndependentFile:(NSString *)path;
+ (UIImage *) resolutionIndependentImageNamed:(NSString *)name;
@end
62 changes: 62 additions & 0 deletions Classes/UIImage+RIFAddition.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// UIImage+RIFAddition.m
// Canabalt
//
// Copyright Semi Secret Software 2009-2010. All rights reserved.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import "UIImage+RIFAddition.h"

@implementation UIImage (RFAddition)

- (id)initWithContentsOfResolutionIndependentFile:(NSString *)path
{
BOOL iPad = NO;
if ([UIDevice instancesRespondToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
iPad = YES;
if ([UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0) {
// kind of forward thinking, eh?
if (iPad) {
NSString * iPadpath2x = [[path stringByDeletingLastPathComponent]
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@@2x~ipad.%@",
[[path lastPathComponent] stringByDeletingPathExtension],
[path pathExtension]]];
if ([[NSFileManager defaultManager] fileExistsAtPath:iPadpath2x])
return [self initWithContentsOfFile:iPadpath2x];
}
NSString * path2x = [[path stringByDeletingLastPathComponent]
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@@2x.%@",
[[path lastPathComponent] stringByDeletingPathExtension],
[path pathExtension]]];
if ([[NSFileManager defaultManager] fileExistsAtPath:path2x])
return [self initWithContentsOfFile:path2x];
} else if (iPad) {
NSString * iPadpath = [[path stringByDeletingLastPathComponent]
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@~ipad.%@",
[[path lastPathComponent] stringByDeletingPathExtension],
[path pathExtension]]];
if ( [[NSFileManager defaultManager] fileExistsAtPath:iPadpath] )
return [self initWithContentsOfFile:iPadpath];
}
return [self initWithContentsOfFile:path];
}

+ (UIImage*)imageWithContentsOfResolutionIndependentFile:(NSString *)path
{
return [[[UIImage alloc] initWithContentsOfResolutionIndependentFile:path] autorelease];
}

+ (UIImage *) resolutionIndependentImageNamed:(NSString *)name
{
return [self imageWithContentsOfResolutionIndependentFile:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], name]];
}

@end
Binary file added data/images/Default-LandscapeLeft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/Default-LandscapeRight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/canabalt_icon_72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_daily_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_daily_off~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_daily_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_daily_on~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_everyone_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_everyone_off~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_everyone_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_everyone_on~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_forever_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_forever_off~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_forever_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_forever_on~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_friends_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_friends_off~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_friends_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_friends_on~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_global_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_global_off~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_global_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_global_on~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_local_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/high_scores_local_off~ipad.png
Binary file added data/images/high_scores_local_on.png
Binary file added data/images/high_scores_local_on~ipad.png
Binary file added data/images/high_scores_monthly_off.png
Binary file added data/images/high_scores_monthly_off~ipad.png
Binary file added data/images/high_scores_monthly_on.png
Binary file added data/images/high_scores_monthly_on~ipad.png
Binary file added data/images/high_scores_weekly_off.png
Binary file added data/images/high_scores_weekly_off~ipad.png
Binary file added data/images/high_scores_weekly_on.png
Binary file added data/images/high_scores_weekly_on~ipad.png
Binary file added data/images/hud.png
Binary file added data/images/iPadMenu_atlas0.png
Binary file added data/images/iPadMenu_atlas0_backup.png
Binary file added data/images/iPadPlay2_atlas0.png
Loading

0 comments on commit a74cf9a

Please sign in to comment.