Pong Clone Problem
I''m creating a simple pong clone in Visual Basic to use as a project for one of my VB courses in college, but I''ve run into a problem which I''m not sure how I should solve. The problem is that the physics model I''m using (angle of incidence = angle of reflection) results in not very fun game play. In other words, it works great if the ball bounces and hits the lower or upper edge of the screen, but lets say it flys directly toward the paddle then back and the 2nd paddle blocks it, then it will keep bouncing back and forth between the two paddles until someone finally gives in, moves out of the way, and lets the other player score. Does anyone know a good way to fix this?
A common system used is as follows:
if the ball hits the very center of the paddle then incedent = reflection
if the ball hits closer to one of the sides, then the angle is changed to increase/decrease in that direction
it wouldnt be too hard to make a formula that follows this
if ballCenter < paddleCenter then angle = angle + 5
or get more in depth
angle = angle + (ballY-paddleY)*2
I think therefore I code.
if the ball hits the very center of the paddle then incedent = reflection
if the ball hits closer to one of the sides, then the angle is changed to increase/decrease in that direction
it wouldnt be too hard to make a formula that follows this
if ballCenter < paddleCenter then angle = angle + 5
or get more in depth
angle = angle + (ballY-paddleY)*2
I think therefore I code.
Just because the church was wrong doesn't mean Galileo wasn't a heretic.It just means he was a heretic who was right.
Apply a modifer to either the angle or velocity depending on the distance from the centre of the paddle to the point of impact.
-------------------------------------------------
Mindphuq Software : "Who do you want to do today?"
-------------------------------------------------
Mindphuq Software : "Who do you want to do today?"
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
Hi all.
If I understand the problem correctly, then I think that when the ball "collides" with the pads, and thus bounces, you should disable the ball-pads collision detection until the ball hits something else. Then enable the ball-pads collision detection again.
Topgoro
If I understand the problem correctly, then I think that when the ball "collides" with the pads, and thus bounces, you should disable the ball-pads collision detection until the ball hits something else. Then enable the ball-pads collision detection again.
Topgoro
We emphasize "gotoless" programming in this company, so constructs like "goto hell" are strictly forbidden.
He means the collision works fine, it is just that is gets too repetitive bouncing between two paddles all the time when the angle is always the same ...
Idea : add some sort of texture to the walls so the ball''s angle is unpredictable
-------------------------------------------------
Mindphuq Software : "Who do you want to do today?"
Idea : add some sort of texture to the walls so the ball''s angle is unpredictable
-------------------------------------------------
Mindphuq Software : "Who do you want to do today?"
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
I''m not going to put any equations down to show how to do this (it''s 3 am and i''d probably mess it up) but I''ll give an idea of what I think would help with the bouncing problem. You could make an equation that varied the ball bouncing angle based on the spot on the paddle that it hits and the velocity of the ball. You could have the velocity of the ball decrease as it goes (do this by subtracting a set value that you want to use as friction each game cycle). And you could have the velocity of the ball determined by the user input. For example, if the player''s paddle is not moving when the ball hits the paddle, the ball speed continues to decrease (of course it would have to stop decreasing at some value so that it doesn''t completely stop) and if the player is moving the paddle in a certain direction have the velocity be determined by the direction of the ball path and the direction of the paddle movement (if the paddle is moving in the same direction as the ball have the speed increase more than if the ball and the paddle were moving in opposite directions, or vice versa, whichever you think would work better). That''s just my idea on how to make the game more interesting, hope it helped.
Well, the above menchoned ways work fine however it doesn''t add to the fun of game play. So let''s take another approach. Pong is just a computerized version of ping pong or tennis for the most part, and one of the most fun things to do in pingpong or tennis is to put spin on the ball. In order to do this we manipulate the paddle when the ball hits it. So how would we create a similar effect on the computer? Well what I''ve done in the past which works very good is to take the paddle''s current Y velocity and add that to the ball''s current Y velocity. Granted that if both paddles remain stationary then the ball will continue to move in it''s straight pattern, but if the paddle was in motion as the ball hits it, the Y velocity will change causing it to move on some type of angle.
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
A lot of you guys are concentrating so much on the paddles'' position of contact, however in Ping-Pong I think is should matter more if the ball is "hit"(the paddle moves to hit the ball). Change the direction and speed of the ball if the paddle is moving down with certain speed to hit the ball or something.
What about making the paddles themselves rotatable? Say moving the mouse up and down moves the paddle up and down, but holding the mouse button down when moving rotates the paddle ...
So instead of the paddle always being |, it could be / or \, etc.
That makes it harder for the player as well as the opponent.
Merrick
-------------------------------------------------
Mindphuq Software : "Who do you want to do today?"
So instead of the paddle always being |, it could be / or \, etc.
That makes it harder for the player as well as the opponent.
Merrick
-------------------------------------------------
Mindphuq Software : "Who do you want to do today?"
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
First of all I would like to thank you all for the feedback I''m sure it will help me improve the fun factor of this simple gaming project immensely. It made me decide to totally redo some parts of the program, Initially when the ball was launched (like after a player scores or a new game is started) 1 or 8 random directions was selected and the ball travelled at a constant velocity in that direction (I thought I could get away without having to have separate x and y velocities and many different angles). So now I am changing this so that it travels at a random angle, the only problem being it requires a lot more math and has been a pain in the @$$ to remember all those high school math formulas. I have a new system worked out, the only thing I havent been able to remember is how to convert an angle in degrees to pi radians (the VB sine function Sin() takes an angle in radians as its argument). Could anyone help me out here?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement