before building. If you change these settings in the Makefile after
building, you'll have to "make clean" and build again before
installing.
-
#ifndef VOR_COMMON_H
#define VOR_COMMON_H
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef false
-#define false 0
-#endif
+#include <stdbool.h>
+#include <stddef.h>
#ifndef max
#define max(a, b) ((a) > (b) ? (a) : (b))
#define CONDERROR(a) if((a)) {initerror = strdup(SDL_GetError());return 1;}
#define NULLERROR(a) CONDERROR((a) == NULL)
+#ifdef WIN32
+# include <windows.h>
+#endif
+
#endif // VOR_COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/stat.h>
+#ifndef WIN32
+# include <sys/stat.h>
+#endif
#include <sys/types.h>
#include <unistd.h>
s = malloc(2+plen+flen);
if(!s) return NULL;
memcpy(s, path, plen);
- s[plen] = '/';
+ s[plen] = PATH_SEPARATOR;
memcpy(s+plen+1, file, flen+1);
return s;
}
return add_path(g_data_dir, filename);
}
-int
+#ifdef WIN32
+
+bool
+is_dir(char *dirname)
+{
+ WIN32_FILE_ATTRIBUTE_DATA buf;
+ if(!GetFileAttributesEx(dirname, GetFileExInfoStandard, &buf))
+ return false;
+ return buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+}
+
+bool
+is_file(char *filename)
+{
+ WIN32_FILE_ATTRIBUTE_DATA buf;
+ if(!GetFileAttributesEx(filename, GetFileExInfoStandard, &buf))
+ return false;
+ return buf.dwFileAttributes & FILE_ATTRIBUTE_NORMAL;
+}
+
+#else /* !WIN32 */
+
+bool
is_dir(char *dirname)
{
struct stat buf;
return S_ISDIR(buf.st_mode);
}
-int
+bool
is_file(char *filename)
{
struct stat buf;
return S_ISREG(buf.st_mode);
}
-int
+#endif /* !WIN32 */
+
+bool
find_data_dir(void)
{
int i;
char *data_options[3] = {
- "./data",
getenv("VOR_DATA"),
+ "data",
DATA_PREFIX
};
return false;
}
-int
+bool
find_score_file(void)
{
char *dir, *s;
} else return false;
}
-int
+bool
find_files(void)
{
- int r;
- r = find_data_dir();
- find_score_file();
- return r;
+ return find_data_dir() && find_score_file();
}
FILE *
#ifndef VOR_FILE_H
#define VOR_FILE_H
+#include <stdbool.h>
#include <stdio.h>
-#include <sys/types.h>
-
-extern char *g_data_dir;
-extern char *g_score_file;
-extern mode_t g_score_mode;
char *add_data_path(char *filename);
-int is_dir(char *dirname);
-int is_file(char *filename);
-int find_data_dir(void);
-int find_score_file(void);
-int find_files(void);
+bool is_dir(char *dirname);
+bool is_file(char *filename);
+bool find_data_dir(void);
+bool find_score_file(void);
+bool find_files(void);
FILE *open_score_file(char *mode);
+#ifdef WIN32
+# define PATH_SEPARATOR '\\'
+#else
+# define PATH_SEPARATOR '/'
+#endif
+
#endif // VOR_FILE_H
// Initialize SDL with audio and video
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
opt_sound = 0;
- printf ("Can't open sound, starting without it\n");
+ fputs("Can't open sound, starting without it\n", stderr);
atexit(SDL_Quit);
} else {
atexit(SDL_Quit);
new_rocks();
- // INERTIA
- shipx += shipdx*t_frame;
- shipy += shipdy*t_frame;
-
// SCROLLING
- tmp = (shipy-YSCROLLTO)/25 + (shipdy-screendy);
+ tmp = (shipy+shipdy*t_frame-YSCROLLTO)/25 + (shipdy-screendy);
screendy += tmp * t_frame/12;
- tmp = (shipx-XSCROLLTO)/25 + (shipdx-screendx);
+ tmp = (shipx+shipdx*t_frame-XSCROLLTO)/25 + (shipdx-screendx);
screendx += tmp * t_frame/12;
// taper off so we don't hit the barrier abruptly.
// (if we would hit in < 2 seconds, adjust to 2 seconds).
xscroll = screendx * t_frame;
yscroll = screendy * t_frame;
- shipx -= xscroll;
- shipy -= yscroll;
+ shipx += shipdx*t_frame - xscroll;
+ shipy += shipdy*t_frame - yscroll;
// move bang center
bangx += bangdx*t_frame - xscroll;