This site requires JavaScript, please enable it in your browser!
Greenfoot back
Randomness
Randomness wrote ...

2019/1/3

Bounce off a round player

3
4
5
6
Randomness Randomness

2019/1/11

#
Can you not just make the ball the same speed as the player? It would work then I think. So when it touches the ball, the ball moves the other way very fast so it bounces. Would be really great if you edit this so I can see how it looks like with almost perfect bouncing :)
danpost danpost

2019/1/11

#
I tried speeding up the ball and otter issues popped up (sticking to world edges for one). I did eventually modify the replacement code slightly for a better bounce. Add the following line at the end (after the removing of lines 1 and 4)
ball.turn(180);
This ensures the ball will bounce back in the direction being pushed by the player.
Randomness Randomness

2019/1/11

#
danpost wrote...
I tried speeding up the ball and otter issues popped up (sticking to world edges for one).
okay makes sense
danpost wrote...
I did eventually modify the replacement code slightly for a better bounce. This ensures the ball will bounce back in the direction being pushed by the player.
can you upload the modified version?
danpost danpost

2019/1/11

#
Randomness wrote...
can you upload the modified version?
Here it is.
Randomness Randomness

2019/1/11

#
without the ball.turn(180) the ball bounces (almost) perfect if you multiply move with 10 so the ball moves faster. The thing is (as I already said) that it only works with the left player. When I add ball.turn(180) even the left player is buggy so doesn't seem to be a solution :( Try it yourself and multiply the move speed with 10.
danpost danpost

2019/1/11

#
Randomness wrote...
without the ball.turn(180) the ball bounces (almost) perfect if you multiply move with 10 so the ball moves faster. The thing is (as I already said) that it only works with the left player. When I add ball.turn(180) even the left player is buggy so doesn't seem to be a solution :( Try it yourself and multiply the move speed with 10.
I am not going to even try (multiplying ball speed by 10). It would probably be buggy everywhere.
Randomness Randomness

2019/1/11

#
well as I said the bounce off player 1 works perfectly. But it seems like it bounces off the wrong direction of player 2 and I don't know why
danpost danpost

2019/1/11

#
Randomness wrote...
well as I said the bounce off player 1 works perfectly. But it seems like it bounces off the wrong direction of player 2 and I don't know why
Okay. Remove the "turn(180)" in the buggy one.
Randomness Randomness

2019/1/11

#
I have only one player class so I can't remove the turn(180) just in one player.. edit: I think I fixed it!
You need to login to post a reply.
3
4
5
6