|
-
Oct 14th, 2000, 04:24 PM
#1
Thread Starter
Lively Member
I'm looking for a way for a ball to bounce off a line.
ok i have a ball going on a 90' angle to a
line (152,200)-(192,160) which has a slop of -1
-
Oct 14th, 2000, 04:26 PM
#2
transcendental analytic
any gravity? Any friction? Any collision detection? Is it only the graphical part your interested in? What are you trying to accomplish?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 14th, 2000, 04:28 PM
#3
Thread Starter
Lively Member
-
Oct 14th, 2000, 04:33 PM
#4
transcendental analytic
start position of the ball? does it have a radius?
velocity? in pixels please
image/picturebox? shapecontrol ddraw, how do you draw the ball?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 14th, 2000, 04:56 PM
#5
Thread Starter
Lively Member
B_angle(1)=90
B_Velocity(1)=1
angleofball = B_angle(ball) * (2 * 3.14159265358979) / 360
X = Pball(ball).Left + Cos(angleofball) * B_Velocity(ball)
Y = Pball(ball).Top + Sin(angleofball) * B_Velocity(ball)
This works
i have the ball at 50,10
I'm making pong
the line with the slop is the thing to hit the ball back
[Edited by BIacksun on 10-14-2000 at 05:59 PM]
-
Oct 14th, 2000, 05:08 PM
#6
transcendental analytic
The ball doesn't hit the wall, do you want me to change the values so that you have it bounce with slopes?
BTW, don't calculate ball position by trigonometry, calculate vectors by angle instead.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 14th, 2000, 05:11 PM
#7
I sent you an example of a Ping Pong game, check your mail. It's not the most advanced, but it works .
Hope that helps.
-
Oct 14th, 2000, 05:18 PM
#8
Thread Starter
Lively Member
i want somthig like this
If Y > (?line.Y2?) Then
m = (.Y2 - .Y1) / (.X2 - .X1)
B_angle(ball) = ???????????????????
End If
so when the ball hits the line, the ball will change it's
angle.
[Edited by BIacksun on 10-14-2000 at 06:23 PM]
-
Oct 14th, 2000, 06:36 PM
#9
transcendental analytic
The math behind it was a bit hard to figure out and i'm still not sure if it will work, anyway here's the collision point and the exit angle:
Code:
kw = (y2 - y1) / (x2 - y1)
kb = Tan(angle)
bw = y1 - k * x1
bb = ballY - k * ballX
'collision point
cx = (kw * x1 + bw - bb) / kb
cy = kw * cx + bw
'exit angle
angle = Tan(kw) + 180 - Atn(Abs((kw - kb) / (1 + kw * kb)))
x1,y1,x2y2, the wall coordinates
angle, the angle of the ball velocity
BTW, i have an old vb3 sample that demonstrate this better, but it's a real mess to understand it, anyway it works
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 14th, 2000, 07:46 PM
#10
Thread Starter
Lively Member
what is "k"
and what do i do with
IS this for the ball to make it to the line?
bw = y1 - k * x1
bb = ballY - k * ballX
'collision point
cx = (kw * x1 + bw - bb) / kb
cy = kw * cx + bw
I need a example of this stuff
[Edited by BIacksun on 10-14-2000 at 08:53 PM]
-
Oct 14th, 2000, 08:09 PM
#11
transcendental analytic
k is the k in line equation: y=kx+b
ah sorry should be kb for the ball and kw for the wall
bw = y1 - kw * x1
bb = ballY - kb * ballX
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 14th, 2000, 08:22 PM
#12
Thread Starter
Lively Member
is it not
y=mx+b
m = rise/run (slop)
-
Oct 14th, 2000, 08:33 PM
#13
transcendental analytic
whatever, were talking about the same thing
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 14th, 2000, 08:46 PM
#14
Thread Starter
Lively Member
thanx for the help
but i faild.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|