diff options
Diffstat (limited to 'Classes')
-rw-r--r-- | Classes/JumpGameMode.m | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 7299160..13294c3 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m | |||
@@ -328,7 +328,31 @@ | |||
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | int objectX = arc4random()%448+16; | 331 | int objectX; |
332 | |||
333 | CGSize first = [cart.sprite boundingBox].size; | ||
334 | CGSize second = [object.sprite boundingBox].size; | ||
335 | |||
336 | for (;;) | ||
337 | { | ||
338 | objectX = arc4random()%448+16; | ||
339 | |||
340 | if (waterTick == 0) | ||
341 | { | ||
342 | break; | ||
343 | } | ||
344 | |||
345 | if (cart.sprite.position.x > (objectX - second.width/2 - first.width/2)) | ||
346 | { | ||
347 | if (cart.sprite.position.x < (objectX + second.width/2 + first.width/2)) | ||
348 | { | ||
349 | continue; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | break; | ||
354 | } | ||
355 | |||
332 | object.sprite.position = ccp(objectX, 360); | 356 | object.sprite.position = ccp(objectX, 360); |
333 | object.sprite.scale = 1; | 357 | object.sprite.scale = 1; |
334 | [self addChild:object.sprite]; | 358 | [self addChild:object.sprite]; |
@@ -342,7 +366,26 @@ | |||
342 | { | 366 | { |
343 | object = [[Rock alloc] init]; | 367 | object = [[Rock alloc] init]; |
344 | 368 | ||
345 | objectX = arc4random()%448+16; | 369 | for (;;) |
370 | { | ||
371 | objectX = arc4random()%448+16; | ||
372 | |||
373 | if (waterTick == 0) | ||
374 | { | ||
375 | break; | ||
376 | } | ||
377 | |||
378 | if (cart.sprite.position.x > (objectX - second.width/2 - first.width/2)) | ||
379 | { | ||
380 | if (cart.sprite.position.x < (objectX + second.width/2 + first.width/2)) | ||
381 | { | ||
382 | continue; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | break; | ||
387 | } | ||
388 | |||
346 | object.sprite.position = ccp(objectX, 360); | 389 | object.sprite.position = ccp(objectX, 360); |
347 | object.sprite.scale = 1; | 390 | object.sprite.scale = 1; |
348 | [self addChild:object.sprite]; | 391 | [self addChild:object.sprite]; |
@@ -358,7 +401,26 @@ | |||
358 | { | 401 | { |
359 | object = [[Rock alloc] init]; | 402 | object = [[Rock alloc] init]; |
360 | 403 | ||
361 | objectX = arc4random()%448+16; | 404 | for (;;) |
405 | { | ||
406 | objectX = arc4random()%448+16; | ||
407 | |||
408 | if (waterTick == 0) | ||
409 | { | ||
410 | break; | ||
411 | } | ||
412 | |||
413 | if (cart.sprite.position.x > (objectX - second.width/2 - first.width/2)) | ||
414 | { | ||
415 | if (cart.sprite.position.x < (objectX + second.width/2 + first.width/2)) | ||
416 | { | ||
417 | continue; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | break; | ||
422 | } | ||
423 | |||
362 | object.sprite.position = ccp(objectX, 360); | 424 | object.sprite.position = ccp(objectX, 360); |
363 | object.sprite.scale = 1; | 425 | object.sprite.scale = 1; |
364 | [self addChild:object.sprite]; | 426 | [self addChild:object.sprite]; |