2 * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "../Entities/PhysicsEntity.h"
21 #include "../Entities/Ball.h"
24 /// ***** Constructors/Destructors *****
35 /// ***** Public Class Methods *****
37 Vector2 Screen::positionDelta(const PhysicsEntity* e, float time_step) const
39 const Vector2& pos = e->positionRaw();
44 const Ball* b = dynamic_cast<const Ball*>(e);
46 radius = b->getRadius();
49 if(pos.y > 600-radius)
50 acc.y += 600-radius - pos.y;
53 acc.y += 0+radius - pos.y;
55 if(pos.x > 800-radius)
56 acc.x += 800-radius - pos.x;
59 acc.x += 0+radius - pos.x;
64 Vector2 Screen::velocityDelta(const PhysicsEntity* e, float time_step) const
66 const Vector2& pos = e->positionRaw();
67 const Vector2& velo = e->velocityRaw();
73 const Ball* b = dynamic_cast<const Ball*>(e);
75 radius = b->getRadius();
78 if(pos.y > 600-radius && velo.y > 0)
79 acc.y += velo.y * -(1 + CoR);
81 if(pos.y < 0+radius && velo.y < 0)
82 acc.y += velo.y * -(1 + CoR);
84 if(pos.x > 800-radius && velo.x > 0)
85 acc.x += velo.x * -(1 + CoR);
87 if(pos.x < 0+radius && velo.x < 0)
88 acc.x += velo.x * -(1 + CoR);