Changed type stuff

This commit is contained in:
AnnaSnoeijs 2025-06-06 21:32:00 +02:00
parent 355c79bac4
commit c0b357deb2
6 changed files with 65 additions and 50 deletions

View file

@ -27,26 +27,24 @@
#define SCOREBOARD_HEIGHT 9
void initBoard( const board_t board ){
for( int i = SCOREBOARD_HEIGHT - ( board.rows + 2 ); i > 0; i-- )
for( rowsint_t i = SCOREBOARD_HEIGHT - ( board.rows + 2 ); i > 0; i-- )
putchar( '\n' );
printf( "\n " );
for( int column = 0; column < board.columns; column++ )
for( columnsint_t column = 0; column < board.columns; column++ )
printf( "%2d ", column + FIRST_NUMBER );
putchar( '\n' );
for( int row = board.rows - 1; row > -1; row-- ){
for( rowsint_t row = board.rows - 1; row > -1; row-- ){
// begin row
printf( "%2d " , row + FIRST_NUMBER );
for( int column = 0; column < board.columns; column++ )
for( columnsint_t column = 0; column < board.columns; column++ )
printf( "[ ]" );
// end of row
printf( "%2d" , row + FIRST_NUMBER );
switch( row ){
}
putchar( '\n' );
}
// end of board
printf( " " );
for( int column = 0; column < board.columns; column++ )
for( columnsint_t column = 0; column < board.columns; column++ )
printf( "%2d ", column + FIRST_NUMBER );
#define SCOREBOARD_LINE_END "\033[B\033["XSTR(SCOREBOARD_WIDTH)"D"
printf("\033["XSTR(SCOREBOARD_OFFSET)"C\033["XSTR(SCOREBOARD_HEIGHT)"A"
@ -69,9 +67,9 @@ void initBoard( const board_t board ){
void updateBoard(
const wins_t wins,
const board_t board,
const int column
const columnsint_t column
){
int height = board.height [ column ];
rowsint_t height = board.height [ column ];
printf(
"\033[%dA\033[%dC%c\033[%dB",
height + 3,
@ -81,11 +79,11 @@ void updateBoard(
);
printf(
"\r\033[7A\033[%dC"
"%3d │%3d\033[B\033[8D"
"%3d │%3d\033[B\033[8D"
"%3d │%3d\033[B\033[8D"
"%3d │%3d\033[2B\033[8D"
"%3d │%3d\033[2B"
"" WININT_FORMAT "" WININT_FORMAT "\033[B\033[8D"
"" WININT_FORMAT "" WININT_FORMAT "\033[B\033[8D"
"" WININT_FORMAT "" WININT_FORMAT "\033[B\033[8D"
"" WININT_FORMAT "" WININT_FORMAT "\033[2B\033[8D"
"" WININT_FORMAT "" WININT_FORMAT "\033[2B"
,( 3 * board.columns + 6 ) + SCOREBOARD_WIDTH - 8
,wins.count0.vertical, wins.count1.vertical
,wins.count0.horizontal, wins.count1.horizontal
@ -99,7 +97,7 @@ void updateBoard(
int askColumn(
const board_t board
){
int column;
columnsint_t column;
for(;;){
printf( "Wher player %d put? ", board.player );
printf( "\033[K" ); // clear everything after cursor
@ -112,7 +110,7 @@ int askColumn(
else
column *= 10;
if( column >= 0 )
column += ( int )( ch - '0' );
column += (columnsint_t)( ch - '0' );
} else {
column = -2;
}