SVN commit 999070 by sujithh: Fixing the Bball getting stuck at the bottom right/left corner. Added a feature for making the ball bounce even if the ball is released from the top right/left corner. CCMAIL: plasma-devel@kde.org M +24 -4 bball.cpp M +1 -1 bball.h --- trunk/KDE/kdeplasma-addons/applets/bball/bball.cpp #999069:999070 @@ -55,7 +55,10 @@ m_x_vel(0.0), m_y_vel(0.0), m_circum_vel(0.0), - m_mouse_pressed(false) + m_mouse_pressed(false), + m_bottom_left(0), + m_bottom_right(0), + m_bottom(0) { setHasConfigurationInterface (true); //TODO figure out why it is not good enough to set it here @@ -284,6 +287,7 @@ m_y_vel *= -m_resitution; adjustAngularVelocity( &m_x_vel, m_circum_vel ); m_circum_vel = m_x_vel; + m_bottom=1; } inline void bballApplet::topCollision() @@ -296,18 +300,31 @@ inline void bballApplet::rightCollision() { - m_position.moveRight (m_screen.right ()); + m_position.moveRight (m_screen.right () - 0.1); m_x_vel *= -m_resitution; adjustAngularVelocity( &m_y_vel, -m_circum_vel ); m_circum_vel = -m_y_vel; + if (m_bottom == 1) + { + //kDebug() << "HIT Bottom AND RIGHT"; + m_x_vel = 0.0; + m_bottom=0; + m_bottom_right=1; + } } inline void bballApplet::leftCollision() { - m_position.moveLeft (m_screen.left ()); + m_position.moveLeft (m_screen.left () + 0.1); m_x_vel *= -m_resitution; adjustAngularVelocity( &m_y_vel, m_circum_vel ); m_circum_vel = m_y_vel; + if (m_bottom == 1) + { + //kDebug() << "HIT Bottom AND LEFT"; + m_bottom=0; + m_bottom_left=1; + } } inline void bballApplet::checkCollisions() @@ -319,6 +336,7 @@ { bottomCollision(); collision = true; + kDebug() << "Bottom collision"; } //ceiling @@ -353,6 +371,9 @@ m_y_vel += m_gravity; m_y_vel *= m_friction; m_x_vel *= m_friction; + if (m_bottom_right == 1 || m_bottom_left == 1) { + m_x_vel=0.0; + } } inline void bballApplet::moveAndRotateBall() @@ -364,7 +385,6 @@ void bballApplet::goPhysics () { -// kDebug() << "called"; if ( m_mouse_pressed ) { return; } --- trunk/KDE/kdeplasma-addons/applets/bball/bball.h #999069:999070 @@ -75,7 +75,7 @@ inline void applyPhysics(); inline void moveAndRotateBall(); - int m_radius, m_old_radius, m_sound_volume, m_overlay_opacity; + int m_radius, m_old_radius, m_sound_volume, m_overlay_opacity, m_bottom_left, m_bottom_right, m_bottom; QRectF m_position, m_screen, m_pie_size; QPointF m_old_mouse, m_mouse; qreal m_angle; _______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel