Hi all, im trying to create my own version of the classic Pong with realistic physics.
I have the game set up for testing at the moment, i want to get things right so i can have the ball bounce of all 4 sides of the form. Unfortunatley my coding only works on the top and left walls where I have set the value 0.
On the right and bottom walls the ball just continues right on through rather than bouncing back. I've tried using specific values to make the ball bounce as well as using the forms width added to the left and height added to the top but still to no avail.
Can someone have a look an see where I've gone wrong, im assuming its something I've done or missed.
Many Thanks
Ben
Last edited by lil_bugga; Aug 13th, 2007 at 07:18 PM.
ok i was wrong. Your problem is a little more simple than that. You are mixing data types. You are treating xangle and yangle as strings by using the replace function on them. This is wrong. When you replace -10 with a + it makes it 10, not +10, so when you get to the other side of the screen and check for the boundary, there is no + to replace.
ok i was wrong. Your problem is a little more simple than that. You are mixing data types. You are treating xangle and yangle as strings by using the replace function on them. This is wrong. When you replace -10 with a + it makes it 10, not +10, so when you get to the other side of the screen and check for the boundary, there is no + to replace.
Ok im with you there and now you've pointed it out to me it makes sence.
Is there a way in which i can still get the same effect that I was aiming for in my attempt, whats the best way for me to do this, to mirror the angle of bounce that is?
As far as im aware i should be working in twips, and its 1 pixel to 15 twips i believe.
To get the figures for the right and bottom i placed the image of the ball at the furthest point i want it to be then took the left and top co ords
This is exactly why microsoft did away with twips in vb.net.
there is not a standard relationship between twips and pixels. The number changes depending on monitor size and screen resolution. It's supposed to be something like 1000 per inch, no matter what. As you can see the ration would change if you had less pixels per inch or more from changing display settings or having a bigger monitor. You would have a much easier time of it i think if you used pixels, but in your particular case, it might be easier to make the ball move at angles more precisely using twips because of the multiple-twips-per-pixel.