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

2019/1/3

Bounce off a round player

1
2
3
4
5
6
Randomness Randomness

2019/1/6

#
danpost wrote...
Your ball does not seem to have smooth moving implemented for it.
it's implemented. Is it possible to send you the project and you can take a look? Maybe you'll find what I did wrong. I spent sooo many hours just for this and it's still not working 100%
danpost danpost

2019/1/6

#
Randomness wrote...
it's implemented. Is it possible to send you the project and you can take a look? Maybe you'll find what I did wrong. I spent sooo many hours just for this and it's still not working 100%
You can Share it here, with Publish source code.
Randomness Randomness

2019/1/6

#
danpost wrote...
You can Share it here, with Publish source code.
Just uploaded the scenario! Hope you can take a look
danpost danpost

2019/1/6

#
Randomness wrote...
Just uploaded the scenario! Hope you can take a look
One thing that may be causing issues is that you have most of your players' behavior in a different class -- namely, the steuerung class. It would take a bit of doing, but it would be worth it to get rid of that class and put code in the players" classes. In fact, you can combine both player classes into one class -- same goes with the lasergoal classes. The less you have to work with, the easier it will be to code. Another thing that you can do without are your try-catch phrases. The is nothing in your project (as yet) that you can not explicitly rule out. That is to say, a simple check can be performed prior to any command you execute to ensure no exceptions will be thrown.
Randomness Randomness

2019/1/6

#
okay I can make a players class and put the code from "Steuerung" into it but why should it change or fix the bounces?
danpost danpost

2019/1/6

#
Randomness wrote...
okay I can make a players class and put the code from "Steuerung" into it but why should it change or fix the bounces?
I never said it would automatically fix the bounce. It just makes things a whole lot easier to work with -- everything in one place where it belongs and not copy/pasting to multiple classes. What I mean by a single player class is a Player class that extends SmoothMover with no sub-classes -- and the ball should be the only other SmoothMover extension. Similarly, one LaserGoal class. No player1 player2, laserGoal1 or laserGoal2 class.
danpost danpost

2019/1/7

#
You still do not have it where no contact (in range) between the player and ball is (somewhat) guaranteed after a player moves. There must be separation between the two after any move by any object. At least an attempt at separating them must be made. It is possible that the ball could be squeezed between two players and it will "spit" out somewhere (like a fight for control of the ball), just with ball bounce and player push..
Randomness Randomness

2019/1/10

#
I'm back trying to fix the game again.
danpost wrote...
You still do not have it where no contact (in range) between the player and ball is (somewhat) guaranteed after a player moves. There must be separation between the two after any move by any object. At least an attempt at separating them must be made. It is possible that the ball could be squeezed between two players and it will "spit" out somewhere (like a fight for control of the ball), just with ball bounce and player push..
What do you mean with your post? What do I need to change? I'm still figuring out how to make perfect bounces and actually I only have 5 days left until I have to be finished with this project so I hope I'll find a clean solution very soon
danpost danpost

2019/1/10

#
Randomness wrote...
What do you mean with your post? What do I need to change?
If I recall, you have yet to check for an intersecting ball when a player moves. And when found, create a separation.
I'm still figuring out how to make perfect bounces and actually I only have 5 days left until I have to be finished with this project so I hope I'll find a clean solution very soon
Getting the above done will be a big part of fixing the bounce.
Randomness Randomness

2019/1/10

#
What is meant with seperation?
danpost danpost

2019/1/10

#
Randomness wrote...
What is meant with seperation?
Use setLocation or move so that the two actors are no longer intersecting. Do it to the actor of your choice (the intersecting ball or the player). I would suggest re-positioning the ball so that it appears that the player has some control over where it goes.
Randomness Randomness

2019/1/10

#
That would probably looks really strange because the ball will teleport to a another location. Which location? How should this look like a clean bounce?
danpost danpost

2019/1/10

#
Randomness wrote...
That would probably looks really strange because the ball will teleport to a another location. Which location? How should this look like a clean bounce?
Just move the ball as much and in the same direction as the player moved to cause the collision. Then, when the ball moves, it will either bounce (if it was moving toward the player) or it will continue on its way (when the player stops moving it). Even if the ball bounces, the player is faster and may continue to push it and it may not appear to actually have bounced; but, the change in directional movement of the ball will always be away from the player when consecutive collisions stop occurring.
Randomness Randomness

2019/1/10

#
Damn English makes it sooo hard for me to understand this , sry .. is it possible to provide me a piece of code so maybe I can understand better what you mean ?
danpost danpost

2019/1/10

#
It will look something like this:this.
There are more replies on the next page.
1
2
3
4
5
6