PROTO::KLUDGE  0.1
Quick prototyping library for games using SDL and OpenGL.
PhysicsHelpers.hpp
Go to the documentation of this file.
1 #ifndef PHYSICSHELPERS_HPP
2 #define PHYSICSHELPERS_HPP
3 
4 namespace pk
5 {
6  namespace physics
7  {
8  //number of tiles per character in the scene
9  //I chose 16 pixel tiles, but this could be
10  // any value as long as it's consistent
11  //see: http://box2d.org/manual.pdf
12  const float tilex = 16.f;
13  const float tiley = 16.f;
14 
15  const float PPM = tilex;
16  const float MPP = 1.f/PPM;
17 
18  namespace
19  {
25  glm::vec2 metersToPixels(b2Vec2 meters)
26  {
27  return { meters.x*PPM, meters.y*PPM };
28  };
29 
35  b2Vec2 pixelsToMeters(glm::vec2 pixels)
36  {
37  return { pixels.x/PPM, pixels.y/PPM };
38  };
39  }
40  }
41 }
42 #endif // PHYSICSHELPERS_HPP
const float PPM
Definition: PhysicsHelpers.hpp:15
Definition: Game.hpp:7
const float MPP
Definition: PhysicsHelpers.hpp:16
const float tilex
Definition: PhysicsHelpers.hpp:12
const float tiley
Definition: PhysicsHelpers.hpp:13