Created
April 4, 2013 13:03
-
-
Save Dimillian/5310171 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CellSize size; | |
if (_list) { | |
size = CellSizeList; | |
} | |
else{ | |
//TODO: Factorize landscape/portrait code | |
//Randomize cell size and avoid hole | |
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])) { | |
if (_currentRowStatus == CellRowEmpty || | |
_currentRowStatus == CellRowOneSpaceUsed) { | |
int randomInt = arc4random() % 2; | |
size = (CellSize)randomInt; | |
} | |
if (_currentRowStatus == CellRowTwoSpaceUsed){ | |
size = CellSizeOne;; | |
} | |
int newRowStatus = _currentRowStatus + 1 + size; | |
_currentRowStatus = (CellRowStatus)newRowStatus; | |
if (_currentRowStatus == CellFullRow) { | |
_currentRowStatus = CellRowEmpty; | |
} | |
} | |
else{ | |
if (_currentRowStatus == CellRowEmpty || | |
_currentRowStatus == CellRowOneSpaceUsed) { | |
int randomInt = arc4random() % 2; | |
size = (CellSize)randomInt; | |
} | |
if (_currentRowStatus == CellFullRow || | |
_currentRowStatus == CellRowTwoSpaceUsed){ | |
size = CellSizeOne; | |
} | |
int newRowStatus = _currentRowStatus + 1 + size; | |
_currentRowStatus = (CellRowStatus)newRowStatus; | |
if (_currentRowStatus == cellFullLandscapeRow) { | |
_currentRowStatus = CellRowEmpty; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment