m1v1f = m1v1 + m2(v2 - v2f)
* v1f = (m1v1 + m2(v2 - v2f)) / m1
Then solve for v2f in the other equation & substitute? where exactly does the cosθ come from?
I'd have to figure that out, anyways, and I'm not 100% sure how. (Hell, I don't have a clue.)
m1v12 + m2v22 / 2 = ... wait ... why the x/2? Both sides of the equation are divided by 2. Couldn't I just get rid of it? The answer to that, of course, is yes.
but basically I'm solving for 4 unknowns. 2 vectors = 2 sets of 2 values each. Either force + angle or dx + dy. And I can convert between those.
m1v12 + m2v22 / 2 = m1v1f2 / 2 + m2v2f2
m1(v12 - v1f2) = m2(v22 - v2f2)
m1(v12 - v1f2) / m2 = v22 - v2f2
v2f2 = v22 - m1(v12 - v1f2) / m2
So I should treat all collisions (that don't destroy both objects) as collisions between spherical objects, at least as far as determining the post-collision movement vectors.
Then I need to determine the line connecting their centers, and calculate the objects' movement vectors (x,y components) relative to that line. The y component will remain unchanged.
[some notes pertaining to a graph that won't make sense w/o the image]
this doesn't help me!
a2 + b2 = c2 ? (Do I know either a or b? I don't think I do.)
This can't be that hard. Hell, if it helps I can even tweak the equation so one body is at "rest".
I need a good geometry / physics book. But I can't. I'm already behind on my bills. There's the internet, granted, but that's not the same.
[many more trig. notes that would be useless w/o the diagrams accompanying]
So the Mac version begins to experience slowdown at around 50 objects (on my computer, at least). The Windows version: 13. What the hell?
It's got me stumped. What the hell? Spending most of its time in some directx_unlock fn. I don't know what that does. I should probably post a plea for help on allegro.cc.
m1v1 + m2v2 = m1v1f + m2v2f
I know the momentum & stuff is conserved, but how do I figure it out? I'm looking for 2 variables!
Say m1 & m2 are both 1.
v1 + v2 = v1f + v2f
2 + -2 = 0 + 0
2 + -2
-2 + 2 seems this is "right"
That's if it's head-on, however. I'm not sure about otherwise
I need to add the vectors somehow. But which vectors is key – it's not velocity. Momentum. But momentum needs to be conserved.
So if they have the same mass, the velocities just switch. Different masses, though?
Ok gotta get to work. I need objects & I need them done. Then work on a couple different kinds of enemies, maybe, make it so enemies can't hurt one another...
I'm getting there... Lots to change. I'm not 100% sure even the code I've changed thus far is valid. We'll see.
Completed the switch to objective C. This'll be far better. Deleting objects is a little clunky right now... And I don't want to have to include the display.h in the object files. That's not such a big deal, though.
And... made the switch to Obj-C work in Windows. A couple minor changes.
Anyways, yes. Enemies. And improving the imput.
God damn this timer's giving me grief. What am I doing wrong?
Yay! Fixed! Now to enemies. And the killing / dying thing.
Hmm: how reasonable wd it be for the speed of objects to dictate how often they're updated, rather than how far they move per update?
Alright. Vectors. Now I can keep track of where the enemy ships are (rather, what direction they're moving in)
All going relatively well. I'm thinking maybe I should look into some sort of OO, though. I'm doing too much reusing code. I guess I can do much of this w/nested functions, however.
Ahh â except the case statements. I have to check every time what kind of structure it is. That's not something I know a good way around.
Objective C is a go. I'll have to do low-level(ish) memory management, but I can do objects. So that's the next thing to work on.