more

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.

more math (coalesce notes)

m1v1 + m2v2 = m1v1f + m2v2f

m1v1f = m1v1 + m2v2 - m2v2f

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] v1f =

  • v1 + m2(v2 - (v22 - m1(v12 - v1f2) / m2))) / m1 [sic]
  • v1 + m2(v2 - (v22 - (m1v12 - m1v1f2) / m2)) / m1
  • v1 + m2v2 - m2(v22 - (m1v12 - m1v1f2) / m2) / m1
  • v1 + m2v2 - (m2v22 + m1v12 - m1v1f2) / m1
  • v1 + m2v2 - m2v22 / m1 + v12 - v1f2
  • v1f + v1f2 = v1 + m2v2 - m2v22 / m1 + v12
  • [this next equation looks wrong]

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]

more coalesce notes

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.

coalesce notes (now with numbers)

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?

m1v1 + m2v2 = m1v1f + m2v2f

m1v12/2 + m2v22/2 = m1v1f2/2 + m2v2f2/2

v1 + v1f = v2 + v2f or v1 - v2 = v2f - v1f v1f = v1(m1 - m2)/(m1 + m2) + v2(2m2)/m1 + m2)

v2f = v1(2m1)/(m1 + m2) + v2(m2 - m1)/(m2 + m1) </strong> sm = m1 + m2

But that’s only good for head-on collisions. “scattering” is more complicated.

v2 = v((2m1) / (m1 + m2))cosΘ v11 = v …

coalesce notes

So my linked list code is broken, somehow. I guess this is a time for Unit Testing. This’d be a whole lot easier if I was using objects. And why isn’t the timer working at all? Or am I doing something (else) wrong?


Organize & streamline code. Is MVC something that really applies to games? I don’t see why it wouldn’t be. Every now & again I’m still getting crashes. Pointers to addresses that aren’t ships. But the speed is much better, now. Should look into timing routines some more. I think there’s something I don’t quite understand about how they work. Objects need to be erased before they’re deleted. Let’s start w/a Space-Invader type enemy. One that moves across the screen horizontally, moves closer, then goes back in the other direction, slowly (or not so slowly) getting closer. Something simple. Oh, and I suppose that whole “dying” and “killing things” thing. Weapon attrs: .multishot .spread (rapidfire) .laser .seeker .flock .power .spread Bosses will drop lots of powerups. Should also be special weapons. Vampire ship?