Hey,
Let's start from the beginning. Please keep the code in english, re-edit it for submission if you have to, variables such az Iziquerdo won't help us understand your code.
Now, let's move on to bouncy bouncy.
First of all you need to start thinking with objects. The ball is an object.
Most important thing for us is the VECTOR along which our ball moves. I assume that you're trying to do that in 2d.
class Vector2d{ public: float x; float y; ...}
We assume that the vector is anchored at the position of your ball. The length of the vector is the speed of the ball. This means that in the next frame the ball will appear at ballX = ballX + vector.x , ballY= ballY+ vector.y
When the ball hits something, it will bounce at speed reduced by friction, against the normal (perpendicular to surface) vector of the surface, using the same angle.
To learn what are normal vectors, and how bouncing works, you will need to fetch your math book, and possibly a physics book for the bounce thing. Or simply draw it on a piece of paper with a grid.
Collision detection is something you will have to think a lot about. Generally, you need to check your ball against ALL collidable objects in the scene (reducing this number to speed up computation is quite a task in itself, so let's disregard this).
The basic idea is to encase every object in a bounding volume, like a box, and then see if boxes overlap for collision.
Basic sphere->box collision test can look like this :
bool AABB_Sphere(nSphere sphere,int mode) { // false for no collision, true for collision, how smart is that? :) float d=0.0; float sphereaxis[3]={sphere.center.x,sphere.center.y,sphere.center.z}; float minaxis[3]={BV.vmin.x,BV.vmin.y,BV.vmin.z}; float maxaxis[3]={BV.vmax.x,BV.vmax.y,BV.vmax.z}; for (int i=0;i<3;i++) { if (sphereaxis < minaxis) { d += (sphereaxis - minaxis)*(sphereaxis - minaxis); } else if (sphereaxis > maxaxis) { d += (sphereaxis - maxaxis)*(sphereaxis - maxaxis); } } // if sphere intersects the box if (d < (sphere.radius*sphere.radius)) { return true; } return false ; // false in all other cases}
This is for 3d. For 2d test, you need to simply reduce the number of tested axes to two. Basically, if the distance from the box is less than radius^2 there is a collision. This is quite an old code of mine, and I'm not entirely sure why it's sphere^2 anymore :P I'm quite certain this method was taken from some book, but Real Time Rendering 2nd ed didn't have it when i looked just now.
When there is a collision, you perform the bounce mentioned above.
Unfortunately this is not an easy matter, and WILL require a lot of thought and thinking about the underlying geometry of objects you are using, and a LOT of maths to make it spin.
Read up on vectors, normal vectors, normalizing, bouncing, etc. High-school level math manual should have most of this stuff.
For the rest, if you're interested, mentioned real-time rendering 2nd ed will be useful, however it has a lot of stuff you won't ever need.
Hope this somewhat sketchy rundown helped you grasp what you're being pitted against.
Good luck!