[code]
TYPE
Tstates = (empty,red,yellow);
Tboard = ARRAY[0..ColMax, 0..RowMax] OF Tstates;[/code]

I have been advised to use this in my c4 game by someone, but I have no idea how to allocate the position of a cell as 'empty, red or yellow' i.e. accessing that Tstates data.

• : [code]:
: TYPE
: Tstates = (empty,red,yellow);
: Tboard = ARRAY[0..ColMax, 0..RowMax] OF Tstates;[/code]:
:
: I have been advised to use this in my c4 game by someone, but I have
: no idea how to allocate the position of a cell as 'empty, red or
: yellow' i.e. accessing that Tstates data.
:
:
:
The usage of the array is very similar as a 2-D array of itnegers, string or booleans. Each element is one of the values of the TStates type. To set the value of an element use a code like this:
[code]
var
Board: TBoard;
begin
Board[0, 1] := red;
end;
[/code]
If you want to copy a value into another variable:
[code]
var
MyState: TStates;
begin
MyState := board[5, 2];
end;
[/code]
To check the value of an element, simply perform an if-then as you would with integers, strings, booleans, etc:
[code]
const
Player1Color: TStates = red;
begin
if board[6, 4] = empty then
begin
board[6, 4] := Player1Color;
end else begin
writeln('Cannot place there');
end;
end;
[/code]

I've used constant values in all of the codes to keep it simple. Obviously you can use integer variables to index the array itself.
• : : [code]: :
: : TYPE
: : Tstates = (empty,red,yellow);
: : Tboard = ARRAY[0..ColMax, 0..RowMax] OF Tstates;[/code]: :
: :
: : I have been advised to use this in my c4 game by someone, but I have
: : no idea how to allocate the position of a cell as 'empty, red or
: : yellow' i.e. accessing that Tstates data.
: :
: :
: :
: The usage of the array is very similar as a 2-D array of itnegers,
: string or booleans. Each element is one of the values of the TStates
: type. To set the value of an element use a code like this:
: [code]:
: var
: Board: TBoard;
: begin
: Board[0, 1] := red;
: end;
: [/code]:
: If you want to copy a value into another variable:
: [code]:
: var
: MyState: TStates;
: begin
: MyState := board[5, 2];
: end;
: [/code]:
: To check the value of an element, simply perform an if-then as you
: would with integers, strings, booleans, etc:
: [code]:
: const
: Player1Color: TStates = red;
: begin
: if board[6, 4] = empty then
: begin
: board[6, 4] := Player1Color;
: end else begin
: writeln('Cannot place there');
: end;
: end;
: [/code]:
:
: I've used constant values in all of the codes to keep it simple.
: Obviously you can use integer variables to index the array itself.

Thanks again Zibadian, I feel like I should be writing out a check to you!
• : [code]:
: TYPE
: Tstates = (empty,red,yellow);
: Tboard = ARRAY[0..ColMax, 0..RowMax] OF Tstates;[/code]:
:
: I have been advised to use this in my c4 game by someone, but I have
: no idea how to allocate the position of a cell as 'empty, red or
: yellow' i.e. accessing that Tstates data.
:
:
:

So I have the players choice and I drop the counter into the cell by asking the player which column they want it dropped in.

My problem now is, I'm not sure how to show that to the player,
• : : [code]: :
: : TYPE
: : Tstates = (empty,red,yellow);
: : Tboard = ARRAY[0..ColMax, 0..RowMax] OF Tstates;[/code]: :
: :
: : I have been advised to use this in my c4 game by someone, but I have
: : no idea how to allocate the position of a cell as 'empty, red or
: : yellow' i.e. accessing that Tstates data.
: :
: :
: :
:
: So I have the players choice and I drop the counter into the cell by
: asking the player which column they want it dropped in.
:
: My problem now is, I'm not sure how to show that to the player,
:
There are several procedure to place and color text on the screen:
GotoXY() places text cursor
TextColor() sets the foreground color
TextBackground() sets the background color

The Crt unit has several color constants and other procedures to handle screen-related issues.

You can also use a case-statement for the TStates type:
[code]
case board[i, j] of
red: begin
TextColor(red);
end;
yellow: begin
TextColor(yellow);
end;
empty: begin
TextColor(black);
end;
end;
[/code]
Together with GotoXY(), some maths and write() you can create a multicolored game board.