The mouse_click() method is the only one that utilizes the global value
player so far. Here's what it does if player is 2:
if(player == 2) {
state = 3;
}
state is defined in the Tile object, and that is only utilized here:
void Tile::show() {
if (state == 0) {
applySurface(box.x, box.y, squares, screen, &clip[0]);
}
if (state == 1) {
applySurface(box.x, box.y, squares, screen, &clip[2]);
log("Stat52");
}
if (state == 2) {
applySurface(box.x, box.y, squares, screen, &clip[1]);
}
if (state == 3) {
applySurface(box.x, box.y, squares, screen, &clip[3]);
}
}
If state == 3 is what
should be executed if the player is player 2. The only real problem I see is when you use &clip[3]. You define clip as another global array, here:
SDL_Rect clip[3];
Notice that you only declared clip to have 3 elements. If you use &clip[3], you're actually calling a
fourth element, not the third, as arrays are 0-indexed. This is an undefined value, and could lead to all sorts of erratic behavior. You'll need to define and initialize it!
At least, that's all I found so far.