Permalink
Browse files

fixed coordinate convertors

  • Loading branch information...
niksaak committed Feb 3, 2013
1 parent 30da6b9 commit dae7cc47d3680e73e3b252e0415e40180485b0cf
Showing with 11 additions and 6 deletions.
  1. +9 −4 src/engine/util.c
  2. +2 −2 src/engine/util.h
View
@@ -16,19 +16,24 @@ SDL_Point SDLpt(int x, int y)
return pt;
}
-SDL_Point cpvSDL(cpVect vector, SDL_Surface* target, cpVect offset)
+SDL_Point cpvSDL(cpVect vector, const SDL_Surface* target, cpVect offset)
{
SDL_Point pt;
- pt.x = (target->w / 2) + vector.x - offset.x;
+ pt.x = (target->w / 2) + vector.x + offset.x;
pt.y = (target->h / 2) - vector.y + offset.y;
return pt;
}
-cpVect SDLcpv(SDL_Point point, SDL_Surface* target, cpVect offset)
+cpVect SDLcpv(SDL_Point point, const SDL_Surface* target, cpVect offset)
{
- return cpvzero; // FIXME
+ cpVect v;
+
+ v.x = -(target->w / 2) + point.x + offset.x;
+ v.y = (target->h / 2) - point.y + offset.y;
+
+ return v;
}
bool nullp(const void* ptr)
View
@@ -25,9 +25,9 @@ typedef struct SDL_point {
extern SDL_Point SDLpt(int x, int y);
-extern SDL_Point cpvSDL(cpVect vector, SDL_Surface* target, cpVect offset);
+extern SDL_Point cpvSDL(cpVect vector, const SDL_Surface* target, cpVect offset);
-extern cpVect SDLcpv(SDL_Point point, SDL_Surface* target, cpVect offset);
+extern cpVect SDLcpv(SDL_Point point, const SDL_Surface* target, cpVect offset);
extern bool nullp(const void*);

0 comments on commit dae7cc4

Please sign in to comment.