]> git.localhorst.tv Git - sdl-test7.git/blob - src/pong/Ball.cpp
imported current version
[sdl-test7.git] / src / pong / Ball.cpp
1 /*
2  * Ball.cpp
3  *
4  *  Created on: Apr 9, 2012
5  *      Author: holy
6  */
7
8 #include "Ball.h"
9
10 #include "Paddle.h"
11
12 #include <cmath>
13 #include <SDL/SDL_gfxPrimitives.h>
14
15 using game::Entity;
16
17
18 namespace pong {
19
20 Ball::Ball(Scalar radius)
21 : Entity(&shape)
22 , shape(radius) {
23
24 }
25
26 Ball::Ball(const Vector &position, Scalar radius)
27 : Entity(position, &shape)
28 , shape(position, radius) {
29
30 }
31
32
33 void Ball::Collide(Entity &other, const Vector &normal) {
34         Entity::Collide(other, normal);
35
36         if (dynamic_cast<Paddle *>(&other)) {
37                 Accelerate(1.015f);
38         }
39 }
40
41 void Ball::Render(SDL_Surface *screen) {
42         circleRGBA(screen, shape.X(), shape.Y(), shape.Radius(), 0xFF, 0xFF, 0xFF, 0xFF);
43 }
44
45 }