To do this you'll want loops, an an array will make it easy too. Add an array to your project with a Width of 5, a Height of 5, and a Depth of 1. The array can be seen as a 'spreadsheet' where you store the result of each turn. When a player places a piece, fill the appropriate cell in the array with the appropriate value. For example:
> The YELLOW player's turn, they have placed a piece at X:
Array > Set at x,y > X: 3, Y: 1, Value: "yellow" [/code:3o94uufb]
Running this at the end of each turn will make it much easier to check for a win-state - which is what we check for next. There are a lot of ways to do this, but here's what I can think of:
Array > For each element (xy)
System > Compare two values >
First Value: Array.At( Array.CurX - 1 , Array.CurY )&Array.At( Array.CurX , Array.CurY )&Array.At( Array.CurX + 1 , Array.CurY ) = "yellowyellowyellow" | Array.At( Array.CurX , Array.CurY + 1 )&Array.At( Array.CurX , Array.CurY )&Array.At( Array.CurX , Array.CurY - 1 ) = "yellowyellowyellow" | Array.At( Array.CurX - 1 , Array.CurY )&Array.At( Array.CurX , Array.CurY )&Array.At( Array.CurX + 1 , Array.CurY ) = "blueblueblue" | Array.At( Array.CurX , Array.CurY + 1 )&Array.At( Array.CurX , Array.CurY )&Array.At( Array.CurX , Array.CurY - 1 ) = "blueblueblue"
Second Value: 1
This seems pretty long-winded but it's actually a single event, which is nice. The 'For each element (xy)' action means the event will be run for every cell in the Array's x,y dimension. The first of the two values to compare is a long 'or' expression - each vertical line '|' character can be read as 'or'. The conditions in the expression create strings that represent the orthogonal lines through the current cell, and compare them to strings that define a win-state, eg: "blueblueblue" or "yellowyellowyellow". Because they are part of an 'or' expression, if any of the conditions in this expression are met, the output of the expression will be "1" - so the second value with which to compare the first should just be "1".
Place whatever actions go in your win condition into this action - good luck! What a fun little problem.
I did it but it only checked horizontally and vertically, but how to check in diagonally?