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
danpost danpost

2019/1/4

#
Randomness wrote...
this really doesn't solve the problem. it looks veeery buggy and doesn't work very often. Is there a better way to solve this so I can move the player as fast as I want and the ball will still bounce?
Is the player to maintain its position and not be influenced at all by the collision, that only the ball bounces off the player? I can imagine one problem that since the player goes faster than the ball, even with a good bounce, the player can move over the ball and cause unwanted results. That would be the case even if we cause the ball to bounce when the player moves (as well as when the ball moves).
Randomness Randomness

2019/1/4

#
Well it wasn't planned that the player is influenced by the collision because I think it's too hard. But now I understand the problem. How can I solve this issue? The game gets really boring when the player is so slow so he has to be faster (like move(6))
danpost danpost

2019/1/4

#
Randomness wrote...
Well it wasn't planned that the player is influenced by the collision because I think it's too hard. But now I understand the problem. How can I solve this issue? The game gets really boring when the player is so slow so he has to be faster (like move(6))
I guess there are a couple of things you could try. One is making the player only move as fast as the ball when colliding with it. Another is to have the player make the ball move faster when "pushing it".
Randomness Randomness

2019/1/4

#
isn't it also possible to use the smoothmover class in greenfoot to make it move.. smoother? if yes, how can I use this class? edit: just tried it.. still doesn't work
danpost danpost

2019/1/4

#
Randomness wrote...
isn't it also possible to use the smoothmover class in greenfoot to make it move.. smoother? if yes, how can I use this class? edit: just tried it.. still doesn't work
The SmoothMover class only smooths movement by tracking location coordinates more precisely, thereby eliminating loss of precision due to rounding to the nearest unit when moving from one location to another. It cannot fix excessive unwanted movement which can only be fixed by more or better coding. However, I have been working with a class that aids in smooth movement and rotation and have an idea for a demo (could be a while, though). But, I think what I stated in my last post still stands.
Randomness Randomness

2019/1/5

#
I tried some things but to be honest I'm not very happy with the results. My goal is to make smooth bounces so I need a .. smooth solution for this problem. Would be very happy if you help me with that!
Super_Hippo Super_Hippo

2019/1/5

#
Another way to prevent moving through objects and similar stuff is to move step by step:
1
2
3
4
5
for (int i=speed; i>0; i--)
{
    move(1);
    bounce();
}
Randomness Randomness

2019/1/5

#
doesn't really work. almost seems like it's a lot worse.. danpost do you have another idea? I recorded a video so you can see how it looks like https://www.youtube.com/watch?v=I0u1iLEJpz4
danpost danpost

2019/1/5

#
Randomness wrote...
doesn't really work. almost seems like it's a lot worse.. danpost do you have another idea?
Ideas? Maybe. How about cutting back on the speed of the actors as a way to avoid one actor over-passing another and compensating by increasing the frame rate of the scenario.
Randomness Randomness

2019/1/5

#
Actually a good idea :D but not a clean one. Would probably be better to code better because otherwise I have to change timers and so on in the game. Isn‘t there a not so complicated way to fix this
danpost danpost

2019/1/6

#
Randomness wrote...
Actually a good idea :D but not a clean one. Would probably be better to code better because otherwise I have to change timers and so on in the game. Isn‘t there a not so complicated way to fix this
I do not know. Even with this idea, I think one of my suggestions here is still needed. Getting back to the SmoothMover class, I was not saying that you should not use it. In fact, I believe it best that you do incorporate a smooth moving system. That way, the bounces are not restricted to specific angles. To illustrate, if an actor only moves one pixel at a time, there are only eight directions (angles) it can proceed from any location -- namely, to any of the eight surrounding pixel. It is therefore restricted to move only horizontally, vertically or diagonally. If it moves 2 pixels at a time, it is allowed another 8 possible angles to travel in. Sixteen out of 360 possible integer angles in degrees is still quite limited. The faster the actor moves, the more possible directions it can move until the limiting factor becomes the rotation (limited to 360 degrees). At this point, aiming becomes inaccurate where turning toward a location and then repeated moving, even at a good speed, will usually cause a target miss You may not need all that kind of accuracy, so the SmoothMover class may be sufficient for your needs.
Randomness Randomness

2019/1/6

#
I used the smoothmover class and changed the movement to move(0.5) and the speed of greenfoot high but it glitches .. actually it almost never bounces which I can't understand why..
danpost danpost

2019/1/6

#
Randomness wrote...
I used the smoothmover class and changed the movement to move(0.5) and the speed of greenfoot high but it glitches .. actually it almost never bounces which I can't understand why..
I would think a speed of 1 for the ball and a high speed of 3 for the player would be about right.
Randomness Randomness

2019/1/6

#
well I used smoothmovement now and your method that it moves(-1) when touching the ball. The problem I have now is that I still can move through the ball at the beginning, later I can move through but bouncing only works 50% of the time. Here is a video to demonstrate it! https://youtu.be/CUP1eX6vcCY
danpost danpost

2019/1/6

#
Randomness wrote...
well I used smoothmovement now and your method that it moves(-1) when touching the ball. The problem I have now is that I still can move through the ball at the beginning, later I can move through but bouncing only works 50% of the time.
Your ball does not seem to have smooth moving implemented for it.
There are more replies on the next page.
1
2
3
4
5