|
|
|
|
@ -1,13 +1,14 @@
|
|
|
|
|
|
|
|
|
|
// Some defaults for the game layout
|
|
|
|
|
#define HEX_SIZE 20 |
|
|
|
|
#define HEX_RADIUS 9 |
|
|
|
|
#define HEX_SIZE 10 |
|
|
|
|
#define HEX_RADIUS 19 |
|
|
|
|
#define HEX_ORIENTATION layout_flat |
|
|
|
|
#define FILL_COLOR 0x565656FF |
|
|
|
|
#define SELECTED_FILL_COLOR 0xF46000FF |
|
|
|
|
#define DEBUG_DRAW true |
|
|
|
|
#define VIEWPORT_WIDTH 1280 |
|
|
|
|
#define VIEWPORT_HEIGHT 720 |
|
|
|
|
#define CONE_ANGLE 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <string> |
|
|
|
|
@ -31,6 +32,7 @@ using std::vector;
|
|
|
|
|
|
|
|
|
|
game_state* g_game_state; |
|
|
|
|
render_state* g_render_state; |
|
|
|
|
vector<Point> g_polygon_select_vertices = {Point(), Point(), Point(), Point()}; |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
createHexes(vector<hex_info> *hxi_array, const Layout &layout, uint32 color) |
|
|
|
|
@ -182,7 +184,7 @@ updateHexConeFill(int32 x, int32 y)
|
|
|
|
|
Point p2(g_game_state->current_hex->XPos, g_game_state->current_hex->YPos); |
|
|
|
|
real64 angle = std::atan2(p2.y - p1.y, p2.x - p1.x); |
|
|
|
|
real64 len = std::hypot(p2.y - p1.y, p2.x - p1.x); |
|
|
|
|
real64 coneAngle = 30.f * M_PI / 180; // M_PI is non-standard and may not be portable
|
|
|
|
|
real64 coneAngle = CONE_ANGLE * M_PI / 180; // M_PI is non-standard and may not be portable
|
|
|
|
|
|
|
|
|
|
real64 x1 = len * std::cos(angle); |
|
|
|
|
real64 y1 = len * std::sin(angle); |
|
|
|
|
@ -193,14 +195,9 @@ updateHexConeFill(int32 x, int32 y)
|
|
|
|
|
real64 botX = x1 * std::cos(coneAngle) + y1 * std::sin(coneAngle) + p1.x; |
|
|
|
|
real64 botY = x1 * std::sin(-1 * coneAngle) + y1 * std::cos(coneAngle) + p1.y; |
|
|
|
|
|
|
|
|
|
hex_info* topHex = getSingleHex(topX, topY); |
|
|
|
|
hex_info* botHex = getSingleHex(botX, botY); |
|
|
|
|
|
|
|
|
|
if (topHex && botHex) |
|
|
|
|
{ |
|
|
|
|
Point test_p; |
|
|
|
|
Point vert2 = Point(botHex->XPos, botHex->YPos); |
|
|
|
|
Point vert4 = Point(topHex->XPos, topHex->YPos); |
|
|
|
|
Point vert2 = Point(botX, botY); |
|
|
|
|
Point vert4 = Point(topX, topY); |
|
|
|
|
std::vector<Point> vertices = {p1, vert2, p2, vert4}; |
|
|
|
|
|
|
|
|
|
for (hex_info &h : *g_game_state->hex_array) |
|
|
|
|
@ -219,7 +216,11 @@ updateHexConeFill(int32 x, int32 y)
|
|
|
|
|
h.current_color = h.stored_color; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
g_polygon_select_vertices[0].x = p1.x; g_polygon_select_vertices[0].y = p1.y; |
|
|
|
|
g_polygon_select_vertices[1].x = vert2.x; g_polygon_select_vertices[1].y = vert2.y; |
|
|
|
|
g_polygon_select_vertices[2].x = p2.x; g_polygon_select_vertices[2].y = p2.y; |
|
|
|
|
g_polygon_select_vertices[3].x = vert4.x; g_polygon_select_vertices[3].y = vert4.y; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -475,7 +476,7 @@ int main(int argc, char* argv[])
|
|
|
|
|
SDL_Delay(16); // ~60hz
|
|
|
|
|
renderFrame(g_game_state->hex_array); |
|
|
|
|
if (g_render_state->is_debug_draw && g_game_state->draw_mode == CONE_FILL) |
|
|
|
|
renderDebug(g_game_state->start_hex, g_game_state->current_hex); |
|
|
|
|
renderDebug(g_polygon_select_vertices); |
|
|
|
|
renderGooey(handles, g_game_state->draw_mode, g_render_state->is_debug_draw, |
|
|
|
|
g_game_state->start_hex, g_game_state->current_hex, g_game_state->is_selecting); |
|
|
|
|
SDL_GL_SwapWindow(handles.window); |
|
|
|
|
|