Skip to content

Instantly share code, notes, and snippets.

@ericcgu
Created February 17, 2015 20:33
Show Gist options
  • Select an option

  • Save ericcgu/c96c93795b94645c4b6a to your computer and use it in GitHub Desktop.

Select an option

Save ericcgu/c96c93795b94645c4b6a to your computer and use it in GitHub Desktop.
Win Condition
func checkWinCondition (column: Int, row: Int){
let alert = UIAlertView()
alert.title = "Four In a Row! Game Over!"
alert.addButtonWithTitle("OK")
for row in 0..<gameBoard.rows {
for column in 0..<gameBoard.columns {
//horizontal
if(isLinearMatch(column: column, row: row, stepX: 1, stepY: 0)){
isFinished = true
alert.show()
}
//vertical
if(isLinearMatch(column: column, row: row, stepX: 0, stepY: 1)){
isFinished = true
alert.show()
}
//diagonal
if(isLinearMatch(column: column, row: row, stepX: 1, stepY: 1)){
isFinished = true
alert.show()
}
//second diagonal
if(isLinearMatch(column: column, row: row, stepX: 1, stepY: -1)){
isFinished = true
alert.show()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment