diff options
author | 2025-05-17 01:21:21 +0200 | |
---|---|---|
committer | 2025-05-17 01:21:21 +0200 | |
commit | 87cde6f952917522a1c13524354ac52f2bcb0fbe (patch) | |
tree | 22234ffc7c612103d999eeb9f309e0bb2cbb146a | |
parent | e7f81ff8f43b49331c368e3be09326551e0e6213 (diff) | |
download | tris-87cde6f952917522a1c13524354ac52f2bcb0fbe.tar.gz tris-87cde6f952917522a1c13524354ac52f2bcb0fbe.zip |
Draw the game field
-rw-r--r-- | src/main/game.c | 10 | ||||
-rw-r--r-- | src/main/game.h | 2 | ||||
-rw-r--r-- | src/main/main.c | 14 |
3 files changed, 23 insertions, 3 deletions
diff --git a/src/main/game.c b/src/main/game.c index bc9e007..ea1a935 100644 --- a/src/main/game.c +++ b/src/main/game.c @@ -17,13 +17,21 @@ * along with Tris Game. If not, see <http://www.gnu.org/licenses/>. */ +#include <GL/gl.h> + #include "engine/engine.h" void -game_field(int box_size, int x, int y) +game_draw_field(int box_size, int x, int y) { + glLineWidth(5.0f); + glBegin(GL_LINES); + glColor3f(1.0f, 1.0f, 0.0f); /* Yellow */ + engine_draw_line(box_size, y, box_size, box_size * 3); engine_draw_line(box_size * 2, y, box_size * 2, box_size * 3); engine_draw_line(x, box_size, box_size * 3, box_size); engine_draw_line(x, box_size * 2, box_size * 3, box_size * 2); + + glEnd(); } diff --git a/src/main/game.h b/src/main/game.h index a337bf8..8148645 100644 --- a/src/main/game.h +++ b/src/main/game.h @@ -20,6 +20,6 @@ #ifndef __GAME_H__ #define __GAME_H__ -void game_field(int box_size, int x, int y); +void game_draw_field(int box_size, int x, int y); #endif /* __GAME_H__ */ diff --git a/src/main/main.c b/src/main/main.c index 76876f0..6e10477 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -17,15 +17,27 @@ * along with Tris Game. If not, see <http://www.gnu.org/licenses/>. */ +#include <GL/gl.h> +#include <GL/glx.h> #include <stdio.h> #include <stdlib.h> #include "ui/ui.h" #include "engine/engine.h" +#include "game.h" #define WIDTH 640 #define HEIGHT 480 -void draw_frame() { +void +draw_frame() +{ + glClearColor(0.0f, 0.0f, 0.2f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + game_draw_field(100, 10, 10); } int main(void) { |