diff --git a/main.m b/main.m index 9c7568a..6a8c591 100644 --- a/main.m +++ b/main.m @@ -3,26 +3,18 @@ #include #include "timer.h" -static inline struct timespec subts(volatile struct timespec t1, volatile struct timespec t2) { - return (struct timespec) { - .tv_sec = t2.tv_sec - t1.tv_sec, - .tv_nsec = t2.tv_nsec - t1.tv_nsec, - }; -} - int main(void) { Timer *t = [[Timer alloc] init]; char buffer[100]; - InitWindow(400, 400, "raytime"); + InitWindow(400, 400, "ghost"); SetTargetFPS(60); Color theColor = BLACK; [t start]; while (!WindowShouldClose()) { - sprintf(buffer, "%jd", (intmax_t)[t time].tv_sec); if (IsKeyPressed(KEY_SPACE)) { if (t->paused) { @@ -33,9 +25,9 @@ int main(void) { [t pause]; } } - - [t tick]; + [t tick]; + BeginDrawing(); ClearBackground(WHITE); DrawText([t timeString], 400/2 - 50, 400/2 - 50, 100, theColor); diff --git a/makefile b/makefile index 6b027bb..a37a2e7 100755 --- a/makefile +++ b/makefile @@ -1,15 +1,15 @@ -CC=g++ +CC=gcc INCLUDE= -I /home/sandyx/code/objc/wow/include main: main.o timer.o - g++ main.o timer.o -o main -L /home/sandyx/code/objc/wow/lib/linux64 -lraylib -lobjc -lyeslib + $(CC) main.o timer.o -o main -L /home/sandyx/code/objc/wow/lib/linux64 -lraylib -lobjc -lyeslib -lm main.o: - g++ $(INCLUDE) main.mm -c + $(CC) $(INCLUDE) main.m -c timer.o: - g++ $(INCLUDE) timer.mm -c + $(CC) $(INCLUDE) timer.m -c clean: rm main *.o \ No newline at end of file diff --git a/timer.h b/timer.h index de2b70a..5e523d2 100644 --- a/timer.h +++ b/timer.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #define NSEC_PER_SEC 1000000000 diff --git a/timer.m b/timer.m index d04a6b2..ddb4237 100644 --- a/timer.m +++ b/timer.m @@ -7,13 +7,6 @@ struct timespec subts(struct timespec t1, struct timespec t2) { }; } -struct timespec negts(struct timespec t) { - return (struct timespec) { - .tv_sec = -t.tv_sec, - .tv_nsec = -t.tv_nsec, - }; -} - struct timespec addts(struct timespec t1, struct timespec t2) { return (struct timespec) { .tv_sec = t1.tv_sec + t2.tv_sec, @@ -21,10 +14,6 @@ struct timespec addts(struct timespec t1, struct timespec t2) { }; } -void print_ts(struct timespec t) { - printf("time: %ld.%ld\n", (unsigned long)t.tv_sec, (unsigned long)t.tv_nsec); -} - double timespec_to_double(struct timespec ts) { return ((double)(ts.tv_sec) + ((double)(ts.tv_nsec) / NSEC_PER_SEC)); } @@ -34,11 +23,11 @@ double timespec_to_double(struct timespec ts) { self = [super init]; running = false; paused = false; - pause_start = {0}; - pause_current = {0}; - start = {0}; - current = {0}; - diff = {0}; + pause_start = (struct timespec){0}; + pause_current = (struct timespec){0}; + start = (struct timespec){0}; + current = (struct timespec){0}; + diff = (struct timespec){0}; return self; } @@ -73,7 +62,6 @@ double timespec_to_double(struct timespec ts) { clock_gettime(CLOCK_REALTIME, ¤t); } else { clock_gettime(CLOCK_REALTIME, &pause_current); - //pause_current = subts(pause_current, pause_start); } }