4 changed files with 174 additions and 182 deletions
@ -1,111 +1,116 @@ |
|||||||
|
|
||||||
#ifndef HEXGAME_H |
#ifndef HEXGAME_H |
||||||
#define HEXGAME_H |
#define HEXGAME_H |
||||||
|
|
||||||
#include <vector> |
#include <vector> |
||||||
#include <cassert> |
#include <cassert> |
||||||
|
|
||||||
#include <SDL.h> |
#if defined (_WIN32) |
||||||
#include "aixlog.hpp" |
#include <SDL.h> |
||||||
|
#else |
||||||
#include "hexlib.h" |
#include <SDL2/SDL.h> |
||||||
|
#endif |
||||||
typedef float real32; |
#include "aixlog.hpp" |
||||||
typedef double real64; |
|
||||||
typedef int32_t bool32; |
#include "hexlib.h" |
||||||
typedef int32_t int32; |
|
||||||
typedef int64_t int64; |
typedef float real32; |
||||||
typedef uint8_t uint8; |
typedef double real64; |
||||||
typedef uint32_t uint32; |
typedef int32_t bool32; |
||||||
|
typedef int32_t int32; |
||||||
struct v2f |
typedef int64_t int64; |
||||||
{ |
typedef uint8_t uint8; |
||||||
v2f(): x(0), y(0) {} |
typedef uint32_t uint32; |
||||||
v2f(real64 a, real64 b): x(a), y(b) {} |
|
||||||
real64 x; |
struct v2f |
||||||
real64 y; |
{ |
||||||
}; |
v2f(): x(0), y(0) {} |
||||||
|
v2f(real64 a, real64 b): x(a), y(b) {} |
||||||
struct v2i |
real64 x; |
||||||
{ |
real64 y; |
||||||
v2i(int a, int b): x(a), y(b) {} |
}; |
||||||
v2i() : x(0), y(0) {} |
|
||||||
int32 x; |
struct v2i |
||||||
int32 y; |
{ |
||||||
}; |
v2i(int a, int b): x(a), y(b) {} |
||||||
|
v2i() : x(0), y(0) {} |
||||||
struct v4i |
int32 x; |
||||||
{ |
int32 y; |
||||||
int32 x0; |
}; |
||||||
int32 y0; |
|
||||||
int32 x1; |
struct v4i |
||||||
int32 y1; |
{ |
||||||
}; |
int32 x0; |
||||||
|
int32 y0; |
||||||
struct SDL_Handles |
int32 x1; |
||||||
{ |
int32 y1; |
||||||
SDL_Window *window; |
}; |
||||||
SDL_GLContext glContext; |
|
||||||
SDL_DisplayMode currentDisplayMode; |
struct SDL_Handles |
||||||
std::vector<SDL_Surface*> texSurfaces; |
{ |
||||||
}; |
SDL_Window *window; |
||||||
|
SDL_GLContext glContext; |
||||||
struct hex_info |
SDL_DisplayMode currentDisplayMode; |
||||||
{ |
std::vector<SDL_Surface*> texSurfaces; |
||||||
int32 hexID = 0; |
}; |
||||||
Hex hex = {}; |
|
||||||
real64 XPos = 0; |
struct hex_info |
||||||
real64 YPos = 0; |
{ |
||||||
uint32 current_color = 0; // RGBA
|
int32 hexID = 0; |
||||||
uint32 stored_color = 0; // RGBA
|
Hex hex = {}; |
||||||
bool selected = false; |
real64 XPos = 0; |
||||||
std::vector<Point> vertices; |
real64 YPos = 0; |
||||||
}; |
uint32 current_color = 0; // RGBA
|
||||||
|
uint32 stored_color = 0; // RGBA
|
||||||
enum HexDrawMode |
bool selected = false; |
||||||
{ |
std::vector<Point> vertices; |
||||||
NONE, |
}; |
||||||
FILL, |
|
||||||
LINE, |
enum HexDrawMode |
||||||
CONE_FILL, |
{ |
||||||
PATHFINDING |
NONE, |
||||||
}; |
FILL, |
||||||
|
LINE, |
||||||
struct render_state |
CONE_FILL, |
||||||
{ |
PATHFINDING |
||||||
v2i viewport_dims; |
}; |
||||||
bool is_debug_draw; |
|
||||||
uint32 fill_color; |
struct render_state |
||||||
uint32 selected_fill_color; |
{ |
||||||
}; |
v2i viewport_dims; |
||||||
|
bool is_debug_draw; |
||||||
struct game_state |
uint32 fill_color; |
||||||
{ |
uint32 selected_fill_color; |
||||||
bool is_selecting; |
}; |
||||||
std::vector<hex_info> *hex_array; |
|
||||||
hex_info *start_hex; |
struct game_state |
||||||
hex_info *current_hex; |
{ |
||||||
vector<hex_info> selected_hexes; |
bool is_selecting; |
||||||
HexDrawMode draw_mode; |
std::vector<hex_info> *hex_array; |
||||||
const Layout hex_layout; |
hex_info *start_hex; |
||||||
|
hex_info *current_hex; |
||||||
game_state(Layout &l) : hex_layout(l) {} |
vector<hex_info> selected_hexes; |
||||||
}; |
HexDrawMode draw_mode; |
||||||
|
const Layout hex_layout; |
||||||
real32 |
|
||||||
SafeRatio(real32 dividend, real32 divisor) |
game_state(Layout &l) : hex_layout(l) {} |
||||||
{ |
}; |
||||||
if (divisor == 0) |
|
||||||
return dividend; |
real32 |
||||||
else |
SafeRatio(real32 dividend, real32 divisor) |
||||||
return dividend / divisor; |
{ |
||||||
} |
if (divisor == 0) |
||||||
|
return dividend; |
||||||
int32 |
else |
||||||
SafeTruncateToInt32(int64 val) |
return dividend / divisor; |
||||||
{ |
} |
||||||
assert(val <= INT32_MAX && val >= INT32_MIN); |
|
||||||
return (int32) val; |
int32 |
||||||
} |
SafeTruncateToInt32(int64 val) |
||||||
|
{ |
||||||
#endif // HEXGAME_H
|
assert(val <= INT32_MAX && val >= INT32_MIN); |
||||||
|
return (int32) val; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HEXGAME_H
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,5 @@ |
|||||||
|
[Window][Debug##Default] |
||||||
|
Pos=0,5 |
||||||
|
Size=400,400 |
||||||
|
Collapsed=0 |
||||||
|
|
||||||
Loading…
Reference in new issue