mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-28 07:44:11 -04:00
Define pi as a constant instead of a macro
Consistent to what we already do in image example
This commit is contained in:
parent
156786d047
commit
a8ec68a625
@ -32,12 +32,10 @@
|
|||||||
#include <SDL2pp/Texture.hh>
|
#include <SDL2pp/Texture.hh>
|
||||||
#include <SDL2pp/Surface.hh>
|
#include <SDL2pp/Surface.hh>
|
||||||
|
|
||||||
#if !defined(M_PI)
|
|
||||||
#define M_PI 3.14159265358979323846f
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace SDL2pp;
|
using namespace SDL2pp;
|
||||||
|
|
||||||
|
static const float pi = 3.14159265358979323846f;
|
||||||
|
|
||||||
int Run() {
|
int Run() {
|
||||||
SDL sdl(SDL_INIT_VIDEO);
|
SDL sdl(SDL_INIT_VIDEO);
|
||||||
SDLImage image(IMG_INIT_PNG); // optional
|
SDLImage image(IMG_INIT_PNG); // optional
|
||||||
@ -63,8 +61,8 @@ int Run() {
|
|||||||
render.Clear();
|
render.Clear();
|
||||||
|
|
||||||
// Fill
|
// Fill
|
||||||
float dx = sin(SDL_GetTicks() / 5000.0 * M_PI) * 32;
|
float dx = sin(SDL_GetTicks() / 5000.0f * pi) * 32.0f;
|
||||||
float dy = cos(SDL_GetTicks() / 10000.0 * M_PI) * 32;
|
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);
|
render.FillCopy(sprite, NullOpt, Rect(32, 32, window.GetWidth() - 64, window.GetHeight() - 64), SDL2pp::Point(dx, dy), SDL_FLIP_HORIZONTAL);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user