Define pi as a constant instead of a macro

Consistent to what we already do in image example
This commit is contained in:
Dmitry Marakasov 2015-09-10 20:40:35 +03:00
parent 156786d047
commit a8ec68a625

View File

@ -32,12 +32,10 @@
#include <SDL2pp/Texture.hh>
#include <SDL2pp/Surface.hh>
#if !defined(M_PI)
#define M_PI 3.14159265358979323846f
#endif
using namespace SDL2pp;
static const float pi = 3.14159265358979323846f;
int Run() {
SDL sdl(SDL_INIT_VIDEO);
SDLImage image(IMG_INIT_PNG); // optional
@ -63,8 +61,8 @@ int Run() {
render.Clear();
// Fill
float dx = sin(SDL_GetTicks() / 5000.0 * M_PI) * 32;
float dy = cos(SDL_GetTicks() / 10000.0 * M_PI) * 32;
float dx = sin(SDL_GetTicks() / 5000.0f * pi) * 32.0f;
float dy = cos(SDL_GetTicks() / 10000.0f * pi) * 32.0f;
render.FillCopy(sprite, NullOpt, Rect(32, 32, window.GetWidth() - 64, window.GetHeight() - 64), SDL2pp::Point(dx, dy), SDL_FLIP_HORIZONTAL);