Skip to content
Browse files

added SDL_Point struct and function to convert from cpVect

  • Loading branch information...
1 parent 2a03f8e commit 6a99cea749291d4150cf5bf90b0f0f5daf221e2e @niksaak committed Feb 2, 2013
Showing with 22 additions and 0 deletions.
  1. +10 −0 src/engine/util.c
  2. +12 −0 src/engine/util.h
View
10 src/engine/util.c
@@ -6,6 +6,16 @@
#include "util.h"
+SDL_Point cpvSDL(cpVect vector, SDL_Surface* target, cpVect offset)
+{
+ SDL_Point pt;
+
+ pt.x = (target->w / 2) + vector.x - offset.x;
+ pt.y = (target->h / 2) - vector.y + offset.y;
+
+ return pt;
+}
+
bool nullp(const void* ptr)
{
if(ptr == NULL)
View
12 src/engine/util.h
@@ -2,6 +2,9 @@
#include <stdbool.h>
+#include <SDL/SDL.h>
+#include <chipmunk/chipmunk.h>
+
#ifdef DEBUG_MODE
#include <stdio.h>
#define DEBUG(...) \
@@ -14,6 +17,15 @@
#define CRASH(r) \
crash(__func__, r);
+typedef struct SDL_point {
+ int x;
+ int y;
+} SDL_Point;
+
+extern SDL_Point cpvSDL(cpVect point, SDL_Surface* target, cpVect offset);
+
extern bool nullp(const void*);
+
extern void warn(const char*, const char*);
+
extern void crash(const char*, const char*);

0 comments on commit 6a99cea

Please sign in to comment.
Something went wrong with that request. Please try again.