add getIndex and setCol and the header of forza4
This commit is contained in:
parent
8fc71bc58b
commit
b524d834ca
|
@ -0,0 +1,12 @@
|
|||
#ifndef FORZA4_H
|
||||
#define FORZA4_H
|
||||
|
||||
#include <structures.h>
|
||||
|
||||
static int col;
|
||||
|
||||
void setCollums(int collums);
|
||||
int getIndex(int i, int j);
|
||||
int checkWin(tile_t *board, int x, int y, int rows, int collums);
|
||||
|
||||
#endif
|
12
src/forza4.c
12
src/forza4.c
|
@ -1,12 +1,20 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <structures.h>
|
||||
static int col;
|
||||
|
||||
void setCollums(int collums) {
|
||||
col = collums;
|
||||
}
|
||||
|
||||
int getIndex(int i, int j) {
|
||||
return i * col + j;
|
||||
}
|
||||
|
||||
// checks board for a win
|
||||
// returns player number on win, otherwise 0
|
||||
// x e y come cartesiani, rows e collums le dimensioni
|
||||
int checkWin(tile_t *board, int x, int y, int rows, int collums) {
|
||||
int i;
|
||||
int i;
|
||||
tile_t current = board[x + y * collums];
|
||||
|
||||
// horrizontal
|
||||
|
|
Loading…
Reference in New Issue