1
1
Fork 0
Browse Source

fix windows build

emscriptem
alistair 3 years ago
parent
commit
ca4e32d5db
  1. 6
      Makefile
  2. 9
      src/game.c
  3. 4
      src/main.c

6
Makefile

@ -9,11 +9,11 @@ endif @@ -9,11 +9,11 @@ endif
debug = true
ifeq ($(target),windows)
CC=x86_64-w64-mingw32-gcc
SDL_INCLUDE = -Dmain=SDL_main -Lsdllib -lSDL2main -lSDL2main -lSDL2 -lmingw32 -lSDL2main -lSDL2 -mwindows -lSDL2_mixer -Wl,-static -lpthread -lm
CC=x86_64-w64-mingw32-gcc -DWIN32
SDL_INCLUDE = -Dmain=SDL_main -Lsdllib -lSDL2main -lSDL2main -lSDL2_mixer -lSDL2_ttf -lSDL2 -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,-static -lpthread -lm
CCFLAGS=$(SDL_INCLUDE) -O3
else
CC=gcc
CC=gcc -D__linux__
SDL_INCLUDE= -lSDL2 -lm -lSDL2_ttf -lSDL2_mixer
CCFLAGS=$(SDL_INCLUDE) -O3
endif

9
src/game.c

@ -85,7 +85,11 @@ int long_comparator(const void *a, const void *b, void *non) { @@ -85,7 +85,11 @@ int long_comparator(const void *a, const void *b, void *non) {
}
void sort_times(void) {
#ifdef __linux__
qsort_r(save_times_lst.times, save_times_lst.size, sizeof(long), long_comparator, NULL);
#elif WIN32
qsort_s(save_times_lst.times, save_times_lst.size, sizeof(long), long_comparator, NULL);
#endif
}
long get_best_time(void) {
@ -1009,6 +1013,7 @@ void add_rope(int mouse_x, int mouse_y) { @@ -1009,6 +1013,7 @@ void add_rope(int mouse_x, int mouse_y) {
struct physics_collection s;
bool found = false;
double len = MAX_ROPE_GRAB_LEN;
double t, u;
for (int j = 0; j < (floor.numItems + ceil.numItems - 2); j++) {
if (j >= floor.numItems - 1) {
s = ceil;
@ -1029,10 +1034,10 @@ void add_rope(int mouse_x, int mouse_y) { @@ -1029,10 +1034,10 @@ void add_rope(int mouse_x, int mouse_y) {
double x4 = wall_e.x;
double y4 = wall_e.y;
double t = ((x1 - x3)*(y3 - y4) - (y1 - y3)*(x3-x4))
t = ((x1 - x3)*(y3 - y4) - (y1 - y3)*(x3-x4))
/ ((x1-x2)*(y3-y4) - (y1 - y2)*(x3-x4));
double u = ((x1 - x2)*(y1 - y3) - (y1 - y2)*(x1 - x3))
u = ((x1 - x2)*(y1 - y3) - (y1 - y2)*(x1 - x3))
/ ((x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4));
if (t < 0 || u > 0 || t > 1 || u < -1) {

4
src/main.c

@ -144,7 +144,11 @@ int game(void) { @@ -144,7 +144,11 @@ int game(void) {
int main (int argc, char** argv) {
#ifdef __linux__
mkdirat(AT_FDCWD, "saves", 0777);
#elif WIN32
mkdir("saves");
#endif
game();
SDL_Quit();

Loading…
Cancel
Save