|
-
Oct 28th, 2000, 12:33 PM
#1
Thread Starter
Frenzied Member
In my hockey game, shooting the puck is becoming a problem. How do I make t always shoot at the net?
-
Oct 28th, 2000, 01:05 PM
#2
find the differences between the coordinates and use trigonometry to give you a heading to the net. you shouldnt need Tan(), just Sin() or Cos().
Can't help much more without seeing your program.
-
Oct 28th, 2000, 01:07 PM
#3
Thread Starter
Frenzied Member
I know of the functions, but I don't know trig yet
-
Oct 28th, 2000, 01:16 PM
#4
ok, gimme some numbers to play with and i'll try to work something our for you
-
Oct 28th, 2000, 01:44 PM
#5
Thread Starter
Frenzied Member
the net is always here:
Net.x = 120
Net.y = 0
the player is all over
the screen is about 270
the height is about 300
-
Oct 29th, 2000, 10:06 AM
#6
bear with me, i'm talkin to someone knowledgeable in this kinda thing.
-
Oct 29th, 2000, 02:27 PM
#7
OK here goes, the following is not VB code, so you'll have to decypher it, (should be easy)...
Bearing = arcsin[ |x| / sqrt(x²+y²)] + 90(x>=0)(y<=0) + 180(x<=0)(y<=0) + 270(x<=0)(y>=0)
|x| means absolute value of x
sqrt means square root
(y<=0) etc. are logical operators.
x,y are the differences in positions.
-
Oct 29th, 2000, 04:06 PM
#8
transcendental analytic
am I too late to join this discussion? Maybe you would like to work with vectors 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 29th, 2000, 08:00 PM
#9
Thread Starter
Frenzied Member
Whatever would be easier, wossname's or kedaman if you think vectors are easier than please post
-
Oct 29th, 2000, 08:26 PM
#10
transcendental analytic
Vectors are of course easier, they save a lot of time, both in programming and runtime trigs just consume a lot, hehe-.
Currently do you have a angle/speed set up? Or do you have anything else like vectors for the movement
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 29th, 2000, 09:08 PM
#11
transcendental analytic
Anyway i'm introducing you to vectors! Because that's exactly what you need The speed is composed by x and y components so addition goes with no trigs at all, that means a lot of speed gain when calculating new position for each each sequence. To handle the coordinates you use an UDT, for instance here's Coordinate32:
Code:
Type Coordinate32
x As Single
y As Single
End Type
Function Scalar32ProjG2Vector(Target As Coordinate32, source As Coordinate32, Velocity As Single) As Coordinate32
Dim k As Single
k = speed / ((Target.y - source.y) ^ 2 + (Target.x - source.x) ^ 2) ^ 0.5
With Scalar32ProjG2Vector
.x = k * (Target.x - source.x)
.y = k * (Target.y - source.y)
End With
End Function
Function Vector32Add(V1 As Coordinate32, V2 As Coordinate32) As Coordinate32
With Vector32Add
.x = V1.x + V2.x
.y = V1.y + V2.y
End With
End Function
Now the two functions i pasted here, the first one should project the result speed vector of target and source coordinates, whereas you set the target to the net and keep the source as the puck. VectorAdd should be just fine for moving the puck, just set the puck coordinate to what you return by adding the puck to the speed.
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 30th, 2000, 01:12 PM
#12
Fanatic Member
Kedaman, you like physics don't you? One of my favorite classes back in college (until we got into E&M and ticked off the prof).
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
-
Oct 30th, 2000, 01:39 PM
#13
transcendental analytic
hey Kaverin (friend)
I love physics and math, especially in combination with VB
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 30th, 2000, 02:22 PM
#14
If you ever need help with Particle/Wave Duality problems, then I'm your guy!
I got 97% in that module in college, but i still got a "D" overall, go figure!
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
|