index : cartcollect

this commit

0.5

jump

master

selection_screen

An iOS game where you catch items in a cart |

summary refs log tree commit diff stats

log msg

author

committer

range

path: root/LICENSE.cocosdenshion

| Commit message (Collapse) | Author | Age | Files | Lines
* | Initial commit (version 0.2.1) | Starla Insigna | 2011-07-30 | 1 | -0/+21
|

generated by cgit-pink 1.4.1 (git 2.36.1) at 2024-09-21 09:34:08 +0000

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

//
// GameLayer.m
// Cart Collect
//
// Created by iD Student Account on 7/18/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ClassicGameMode.h"
#import "FallingObject.h"
#import "Cherry.h"
#import "Bottle.h"
#import "OneUp.h"
#import "Rock.h"
#import "GameOverScene.h"
#import "SimpleAudioEngine.h"

@implementation ClassicGameMode

- (void)tick:(ccTime)dt
{
int lastScore = score;

[super tick:dt];

if (lives == 0)
{
[self unscheduleAllSelectors];

[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score]]];
} else if (score > lastScore)
{
if ((lastScore < 6500) && (score >= 6500))
{
[self unschedule:@selector(randomlyAddObject:)];
[self schedule:@selector(randomlyAddObject:) interval:0.6f];
addSpeed = 0.6f;
} else if ((lastScore < 4500) && (score >= 4500))
{
[self unschedule:@selector(randomlyAddObject:)];
[self schedule:@selector(randomlyAddObject:) interval:0.7f];
addSpeed = 0.7f;
} else if ((lastScore < 2500) && (score >= 2500))
{
[self unschedule:@selector(randomlyAddObject:)];
[self schedule:@selector(randomlyAddObject:) interval:0.8f];
addSpeed = 0.8f;
} else if ((lastScore < 1500) && (score >= 1500))
{
[self unschedule:@selector(randomlyAddObject:)];
[self schedule:@selector(randomlyAddObject:) interval:0.9f];
addSpeed = 0.9f;
} else if ((lastScore < 500) && (score >= 500))
{
[self unschedule:@selector(randomlyAddObject:)];
[self schedule:@selector(randomlyAddObject:) interval:1.0f];
addSpeed = 1.0f;
} else if ((lastScore < 150) && (score >= 150))
{
[self unschedule:@selector(randomlyAddObject:)];
[self schedule:@selector(randomlyAddObject:) interval:2.0f];
addSpeed = 2.0f;
}
}
}

- (void)randomlyAddObject:(ccTime)dt
{
FallingObject* object;
int oneuppercent = 98 - (lives == 1 ? 1 : 0);

if (score < 1000)
{
int randomval = arc4random()%100;

if (randomval < 65)
{
object = [[Cherry alloc] init];
} else if (randomval < oneuppercent)
{
object = [[Bottle alloc] init];
} else {
object = [[OneUp alloc] init];
}
} else {
int randomval = arc4random()%100;

if (randomval < 40)
{
object = [[Cherry alloc] init];
} else if (randomval < 70)
{
object = [[Rock alloc] init];
} else if (randomval < oneuppercent)
{
object = [[Bottle alloc] init];
} else {
object = [[OneUp alloc] init];
}
}

int objectX = arc4random()%448+16;
object.sprite.position = ccp(objectX, 360);
object.sprite.scale = 1;
[self addChild:object.sprite];

[objects addObject:object];
[object release];

if (score >= 2000)
{
if (arc4random() % 100 > 80)
{
object = [[Rock alloc] init];

objectX = arc4random()%448+16;
object.sprite.position = ccp(objectX, 360);
object.sprite.scale = 1;
[self addChild:object.sprite];

[objects addObject:object];
[object release];
}
}

if (score >= 4000)
{
if (arc4random() % 100 > 80)
{
object = [[Rock alloc] init];

objectX = arc4random()%448+16;
object.sprite.position = ccp(objectX, 360);
object.sprite.scale = 1;
[self addChild:object.sprite];

[objects addObject:object];
[object release];
}
}
}

- (id)init
{
self = [super init];

if (nil != self)
{
CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"];
backgroundImage.position = ccp(240, 160);
[self addChild:backgroundImage z:-1];

addSpeed = 2.5f;
}

return self;
}

- (void)onEnterTransitionDidFinish
{
[super onEnterTransitionDidFinish];

[self schedule:@selector(randomlyAddObject:) interval:addSpeed];
}

@end

generated by cgit-pink 1.4.1 (git 2.36.1) at 2024-09-21 09:34:09 +0000