diff options
author | 2025-05-21 16:09:14 +0200 | |
---|---|---|
committer | 2025-05-21 16:09:14 +0200 | |
commit | bf93cf0e5209815e51a2932288029d26f2153aca (patch) | |
tree | 1644b1ad9e640592f430b0d8ef116170a0cbc3ca | |
parent | 9706b174847143402db4150e0d497d4f8a152151 (diff) | |
download | tris-bf93cf0e5209815e51a2932288029d26f2153aca.tar.gz tris-bf93cf0e5209815e51a2932288029d26f2153aca.zip |
Change the value of the signs
-rw-r--r-- | src/main/game/game.c | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/src/main/game/game.c b/src/main/game/game.c index f39459b..72d03b1 100644 --- a/src/main/game/game.c +++ b/src/main/game/game.c @@ -35,22 +35,26 @@ float second_col, half_second_col; float third_row, half_third_row; float third_col, half_third_col; -/* 0 = circle, 1 = cross */ -int sign = 0; +/* 1 = circle, 2 = cross */ +int sign = 1; + +int moves = 0; static void draw_sign(float x, float y) { float l = 0.20; - if (sign == 0) { + if (sign == 1) { engine_draw_circle(x, y, l, 120, 1); - sign = 1; - } else if (sign == 1) { + sign = 2; + } else if (sign == 2) { engine_draw_line(x - l, y + l, x + l, y - l); engine_draw_line(x + l, y + l, x - l, y - l); - sign = 0; + sign = 1; } + + moves++; } static void @@ -59,46 +63,37 @@ game_mouse_button_pressed(float x, float y) /* Click inside the field */ if (x >= xmin && x <= xmax && y >= ymin && y <= ymax) { if (y >= first_row) { - if (x <= first_col && field_matrix[0][0] == 0) { + if (x <= first_col && field_matrix[0][0] == -1) { draw_sign(half_first_col, half_first_row); - field_matrix[0][0] = 1; - printf("OK\n"); - } else if (x >= first_col && x <= second_col && field_matrix[0][1] == 0) { + field_matrix[0][0] = sign; + } else if (x >= first_col && x <= second_col && field_matrix[0][1] == -1) { draw_sign(half_second_col, half_first_row); - field_matrix[0][1] = 1; - printf("OK\n"); - } else if (x >= second_col && field_matrix[0][2] == 0) { + field_matrix[0][1] = sign; + } else if (x >= second_col && field_matrix[0][2] == -1) { draw_sign(half_third_col, half_first_row); - field_matrix[0][2] = 1; - printf("OK\n"); + field_matrix[0][2] = sign; } } else if (y >= second_row) { - if (x <= first_col && field_matrix[1][0] == 0) { + if (x <= first_col && field_matrix[1][0] == -1) { draw_sign(half_first_col, half_second_row); - field_matrix[1][0] = 1; - printf("OK\n"); - } else if (x >= first_col && x <= second_col && field_matrix[1][1] == 0) { + field_matrix[1][0] = sign; + } else if (x >= first_col && x <= second_col && field_matrix[1][1] == -1) { draw_sign(half_second_col, half_second_row); - field_matrix[1][1] = 1; - printf("OK\n"); - } else if (x >= second_col && field_matrix[1][2] == 0) { + field_matrix[1][1] = sign; + } else if (x >= second_col && field_matrix[1][2] == -1) { draw_sign(half_third_col, half_second_row); - field_matrix[1][2] = 1; - printf("OK\n"); + field_matrix[1][2] = sign; } } else if (y >= third_row) { - if (x <= first_col && field_matrix[2][0] == 0) { + if (x <= first_col && field_matrix[2][0] == -1) { draw_sign(half_first_col, half_third_row); - field_matrix[2][0] = 1; - printf("OK\n"); - } else if (x >= first_col && x <= second_col && field_matrix[2][1] == 0) { + field_matrix[2][0] = sign; + } else if (x >= first_col && x <= second_col && field_matrix[2][1] == -1) { draw_sign(half_second_col, half_third_row); - field_matrix[2][1] = 1; - printf("OK\n"); - } else if (x >= second_col && field_matrix[2][2] == 0) { + field_matrix[2][1] = sign; + } else if (x >= second_col && field_matrix[2][2] == -1) { draw_sign(half_third_col, half_third_row); - field_matrix[2][2] = 1; - printf("OK\n"); + field_matrix[2][2] = sign; } } } @@ -120,7 +115,7 @@ game_init(int width, int height) for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - field_matrix[i][j] = 0; + field_matrix[i][j] = -1; } } |