4 ms·
Firefox 3.6.12 on a Mac. For what it's worth: Interesting behavior on the left side, the ball occassionally sticks to the paddle and vibrates, travels up the p
by mbyrne 16y ago
Firefox 3.6.12 on a Mac.
For what it's worth:
Interesting behavior on the left side, the ball occassionally sticks to the paddle and vibrates, travels up the paddle and then scores a point against itself. (This is not a set up for a punchline.) Also, both sides show some stuttering in the ball movement.
- nitrogen 16y agoI wrote a simple pong game once for a CS class, and in my case a vibrating ball was caused by simply negating velocity on a collision rather than setting its sign. It's better to do something like this (using C pseudocode as that's my native language): if(collision) { switch(side_of_screen) { case LEFT: horiz_speed = abs(horiz_speed); break; case RIGHT: horiz_speed = -abs(horiz_speed); break; case TOP: // Positive Y is downward vert_speed = abs(vert_speed); break; case BOTTOM: vert_speed = -abs(vert_speed); break; } }
- waterhouse 16y agoChrome 7.0.517.41 on a Mac. I got a score of 9135 (I stopped when it exceeded 9000). http://img201.imageshack.us/img201/8486/screenshot20101102at305.png http://img201.imageshack.us/img201/8486/screenshot20101102at... Method: Get the ball to hit a paddle on the top or bottom. It seems the code that deals with paddle collisions only imagines horizontal collisions, so, every frame (or whatever unit of time it uses), it registers a collision and reverses its horizontal direction. This is the "sticks to the paddle, vibrates, and travels up the paddle" behavior you describe. Move the paddle up and down to follow the ball's vertical movement, so it doesn't fall off. You rack up a lot of collisions very quickly like this. This works much better on the left side, for whatever reason. I've succeeded twice in getting the ball to vibrate on the paddle while moving slow enough vertically that I can follow it and prevent it falling off. I haven't managed to do it on the right side; I have gotten it to vibrate, but only for a short time before it gets flung away. Also, sometimes the ball vibrates on the top or bottom surface for a little while (fraction of a second). This has happened only on the left side so far.