From: Patrik Gornicz Date: Thu, 21 Aug 2008 20:06:23 +0000 (-0400) Subject: changed to a better make header hack ... added position delta to screen collisions... X-Git-Tag: physics-premerge~146 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=5d5a6f3fc2e0bd7ef539cc7ac76c7650c8a80431;p=libbear.git changed to a better make header hack ... added position delta to screen collisions to insure balls stay in the screen --- diff --git a/src/Effects/Screen.cpp b/src/Effects/Screen.cpp index 85759c8..e4ef901 100644 --- a/src/Effects/Screen.cpp +++ b/src/Effects/Screen.cpp @@ -34,6 +34,34 @@ Screen::~Screen() /// ***** Public Class Methods ***** +Vector2 Screen::positionDelta(const PhysicsEntity* e, float time_step) const +{ + const Vector2& pos = e->positionRaw(); + const Vector2& velo = e->velocityRaw(); + + Vector2 acc(0,0); + + float radius = 0; + const Ball* b = dynamic_cast(e); + if( b != NULL ) + radius = b->getRadius(); + + + if(pos.y > 600-radius && velo.y > 0) + acc.y += 600-radius - pos.y; + + if(pos.y < 0+radius && velo.y < 0) + acc.y += 0+radius - pos.y; + + if(pos.x > 800-radius && velo.x > 0) + acc.x += 800-radius - pos.x; + + if(pos.x < 0+radius && velo.x < 0) + acc.x += 0+radius - pos.x; + + return acc; +} + Vector2 Screen::velocityDelta(const PhysicsEntity* e, float time_step) const { const Vector2& pos = e->positionRaw(); diff --git a/src/Effects/Screen.h b/src/Effects/Screen.h index 890fae8..ff8111a 100644 --- a/src/Effects/Screen.h +++ b/src/Effects/Screen.h @@ -30,6 +30,7 @@ class Screen: public Effect Screen(); ~Screen(); + Vector2 positionDelta(const PhysicsEntity*, float) const; Vector2 velocityDelta(const PhysicsEntity*, float) const; }; diff --git a/src/Makefile b/src/Makefile index 638655a..3ed4b86 100644 --- a/src/Makefile +++ b/src/Makefile @@ -60,7 +60,7 @@ DEPS := ${SRCS:.cpp=.d} DEPS := $(addprefix ${DEPSDIR},${DEPS}) HRDS := ${SRCS:.cpp=.h} -HRDS := ${HRDS:main.h=} # remove main.h +HRDS := $(filter-out main.h,$HRDS) # remove main.h HRDS += debug.h HRDS += graphics/colors.h