Skip to content

Instantly share code, notes, and snippets.

@aalemayhu
Created March 12, 2013 19:04
Show Gist options
  • Save aalemayhu/5145921 to your computer and use it in GitHub Desktop.
Save aalemayhu/5145921 to your computer and use it in GitHub Desktop.
Player
if (CGPointEqualToPoint(playerPos, startPos) && levelCompleted == NO)
{
NSUInteger moves = 0;
NSUInteger tile_X, tile_Y;
CCTMXLayer *layer = [tilemap_ layerNamed:@"GameField"];
for (tile_X = 0; tile_X < layer.layerSize.width; tile_X++)
for (tile_Y = 0; tile_Y < layer.layerSize.height; tile_Y++) {
if ([layer tileGIDAt:ccp(tile_X, tile_Y)] == BRICK_RISING)
moves++;
}
if (moves >= (layer.layerSize.width-1)*(layer.layerSize.height-1))
levelCompleted = YES;
}
if (levelCompleted == YES)
{
if (updateCalled >= 10 && bonus > 0)
{
NSString *newBonus = [NSString stringWithFormat:@"BONUS:\n\n%d", --bonus];
[bonusItem setString:newBonus];
NSString *newScore = [NSString stringWithFormat:@"SCORE:\n\n%d", ++score];
[scoreItem setString:newScore];
updateCalled = 0;
}
else if (bonus == 0){
//TODO: Display dialog for win.
}
}
//TODO: Check if user can go nowhere and end game if yes.
@xiumingLan
Copy link

very nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment