summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Classes/JumpGameMode.m6
1 files changed, 5 insertions, 1 deletions
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 13294c3..93e05ea 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m
@@ -129,7 +129,8 @@
129 129
130 if (rightmost <= 480) 130 if (rightmost <= 480)
131 { 131 {
132 CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:(arc4random() % 10) height:2]]; 132 int ledgeWidth = arc4random() % 9 + 1;
133 CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:ledgeWidth height:2]];
133 CCSprite* ledge = [CCSprite spriteWithTexture:texture]; 134 CCSprite* ledge = [CCSprite spriteWithTexture:texture];
134 ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32); 135 ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32);
135 [self addChild:ledge]; 136 [self addChild:ledge];
@@ -463,6 +464,9 @@
463 464
464- (UIImage*)createLedgeWithWidth:(int)width height:(int)height 465- (UIImage*)createLedgeWithWidth:(int)width height:(int)height
465{ 466{
467 NSAssert(width > 0, @"Ledge width must be greater than 0");
468 NSAssert(height > 0, @"Ledge height must be greater than 0");
469
466 UIGraphicsBeginImageContext(CGSizeMake(width*32, height*32)); 470 UIGraphicsBeginImageContext(CGSizeMake(width*32, height*32));
467 471
468 for (int y=0; y<height; y++) 472 for (int y=0; y<height; y++)