X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fpong%2FBall.cpp;fp=src%2Fpong%2FBall.cpp;h=97248f32df6f6b2303ac9824f1806421c0eca1d7;hb=8b4877fe48d21d7e789cf52f81c1d6a87b06bcbc;hp=0000000000000000000000000000000000000000;hpb=42db59e3850c958821e8396fadc20fbeb71050c4;p=sdl-test8.git diff --git a/src/pong/Ball.cpp b/src/pong/Ball.cpp new file mode 100644 index 0000000..97248f3 --- /dev/null +++ b/src/pong/Ball.cpp @@ -0,0 +1,35 @@ +/* + * Ball.cpp + * + * Created on: Apr 9, 2012 + * Author: holy + */ + +#include "Ball.h" + +#include "Paddle.h" +#include "../geometry/constants.h" + +#include +#include + +using game::Entity; +using geometry::PI; + + +namespace pong { + +Ball::Ball(Scalar r) +: Entity(&shape, 4 * PI * r * r * r / 3) +, shape(r) { + +} + + +void Ball::Render(SDL_Surface *screen) const { + circleRGBA(screen, shape.Center().X(), shape.Center().Y(), shape.Radius(), 0xFF, 0xFF, 0xFF, 0xFF); + Vector angle(Vector(0, 1).Rotate(Angle()) * shape.Radius() + Origin()); + lineRGBA(screen, shape.Center().X(), shape.Center().Y(), angle.X(), angle.Y(), 0xFF, 0xFF, 0xFF, 0xFF); +} + +}