Hey I have another question. I'm sorry for always asking, but as it is a school project, with a nice small mark, i want it to be good. I'm upgrading my breakout game , with a new system.
I have actually (thanks to Danpost and Davmac) a world that loads some blocks in a circular way (the blocks are arranged in a circle shape), and are moving (turning as a wheel) around the center of the world.
I also have a plate that moves with the keyboard keys and that turns around the world. Now, my problem is the ball's bounce. When the ball hits a bloc, it's supposed to bounce in the right direction.
So if my bloc is with a rotation of 92, i need my ball to bounce the good way, but when it is with a rotation of -107, i also need a good bounce.
Before, i used this :
It worked when the blocs were not moving, and when their rotation was always the same, arranged in line.
Now that it's moving, it doesn't work anymore.
So i tried with some
while using a simple move(3); for my ball, but doesn't work. And i'd like to keep this method for my ball :
so i can create some cool bonus that could alter that and other stuff.
Thanks a lot !
Bloc bloc = (Bloc)getOneIntersectingObject(Bloc.class); if(bloc != null) { Greenfoot.playSound("plop.wav"); if (getX() >= bloc.getX()-bloc.getImage().getWidth()/2 && getX() <= bloc.getX()+bloc.getImage().getWidth()/2) { moveY = -moveY; } else if (getY() >= bloc.getY()-bloc.getImage().getHeight()/2 && getY() <= bloc.getY()+bloc.getImage().getHeight()/2) { moveX = -moveX; } else { moveX = - (moveX + Greenfoot.getRandomNumber(3) ); } }
setRotation( -bloc.getRotation() );
setLocation(getX() + moveX, getY() + moveY); //moveX and moveY are defined above