From 76276c527527efdf6c56fe9db681906b7fe5e8ec Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Thu, 1 Jan 2015 06:03:28 +0100 Subject: [PATCH] rework file --- game.c | 34 +--------------------------------- polygons.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ polygons.h | 17 +++++++++++++++++ 3 files changed, 66 insertions(+), 33 deletions(-) create mode 100644 polygons.c create mode 100644 polygons.h diff --git a/game.c b/game.c index 39cca32..6dded2d 100644 --- a/game.c +++ b/game.c @@ -8,42 +8,11 @@ #include #include #include "game.h" +#include "polygons.h" #include "obs.h" #include "SDL_prims.h" #include "SDL/SDL.h" -SDL_Point -get_hexagon_vertice(int faceno, int dist) { //{{{ - SDL_Point p1; - - p1.x = dist * cos((M_PI/3)*faceno); - p1.y = dist * sin((M_PI/3)*faceno); - - OFFSET_POINT(p1); - - return p1; -} //}}} -void -draw_hexagon_side(struct s_game *g, int faceno, int dist, int thick, int col) { //{{{ - SDL_Point p1, p2, p3, p4; - - p1 = get_hexagon_vertice(faceno, dist); - p2 = get_hexagon_vertice(faceno+1, dist); - p3 = get_hexagon_vertice(faceno+1, dist+thick); - p4 = get_hexagon_vertice(faceno, dist+thick); - - SDL_Point points[4] = {p1, p2, p3, p4} ; - SDL_FillPolygon(g->screen, points, 4, col); -}//}}} -void -draw_hexagon(struct s_game *g) { //{{{ - int faces; - -#define DFT_COLOR 128 - for(faces = 0; faces < SHAPE_HEXAGON; faces++) { - draw_hexagon_side(g, faces, POLYGON_SIZE, SHAPE_THICK-5, g->color); - } -} //}}} int get_face_from_cursor(struct s_game *g) { @@ -77,7 +46,6 @@ draw_cursor(struct s_game *g) { //{{{ void draw_game(struct s_game *g) { - switch(g->polygon_type) { case SHAPE_HEXAGON: draw_hexagon(g); diff --git a/polygons.c b/polygons.c new file mode 100644 index 0000000..46cdc4d --- /dev/null +++ b/polygons.c @@ -0,0 +1,48 @@ +/* +** polygons.c - <+DESC+> +** +** 2014 - Frank Villaro-Dixon +*/ + +#include +#include +#include +#include "game.h" +#include "polygons.h" +#include "obs.h" +#include "SDL_prims.h" +#include "SDL/SDL.h" + +SDL_Point +get_hexagon_vertice(int faceno, int dist) { //{{{ + SDL_Point p1; + + p1.x = dist * cos((M_PI/3)*faceno); + p1.y = dist * sin((M_PI/3)*faceno); + + OFFSET_POINT(p1); + + return p1; +} //}}} +void +draw_hexagon_side(struct s_game *g, int faceno, int dist, int thick, int col) { //{{{ + SDL_Point p1, p2, p3, p4; + + p1 = get_hexagon_vertice(faceno, dist); + p2 = get_hexagon_vertice(faceno+1, dist); + p3 = get_hexagon_vertice(faceno+1, dist+thick); + p4 = get_hexagon_vertice(faceno, dist+thick); + + SDL_Point points[4] = {p1, p2, p3, p4} ; + SDL_FillPolygon(g->screen, points, 4, col); +}//}}} +void +draw_hexagon(struct s_game *g) { //{{{ + int faces; + +#define DFT_COLOR 128 + for(faces = 0; faces < SHAPE_HEXAGON; faces++) { + draw_hexagon_side(g, faces, POLYGON_SIZE, SHAPE_THICK-5, g->color); + } +} //}}} + diff --git a/polygons.h b/polygons.h new file mode 100644 index 0000000..3fabe38 --- /dev/null +++ b/polygons.h @@ -0,0 +1,17 @@ +/* +** polygons.h - <+DESC+> +** +** 2014 - Frank Villaro-Dixon +*/ + +#ifndef POLYGONS_H +#define POLYGONS_H + +void +draw_hexagon(struct s_game *g); + +void +draw_hexagon_side(struct s_game *g, int faceno, int dist, int thick, int col); + +#endif /* ndef POLYGONS_H */ +