coding ne_city

i’m a little disgruntled atm.  yesterday i managed to code up accelerating/decelerating movers in a couple of hours.

they work fairly well and look very cool.

i’m disgruntled because i banged my head against them for a week trying to get them into quoth 2.  annoyingly, they were pretty easy to code up and it’s really my fault i couldn’t do it the first time.  should have paid attention in high school algebra more.

what follows is a bunch of math stuff that’ s not really important…

turns out, you just need to break everything down into stages and then solve your equation.

the movers function just like in doom3.  you specify moveTime which is your total movement time.  then you can specify accelTime and decelTime to control how long is spent accelerating or decelerating.

well, gee, the formula ends up being pretty damn simple, i’m just a moron, it seems.

we know the total time (moveTime), we also know the total distance.  what i couldn’t figure out last time was what variable i needed to find out.

the important number you need to know is the velocity during your linear movement stage.

take your standard physics formula: distance = (v1 + vf)/2 *t.

but this is only useful for 1 of the 3 movement stages.  so add them up.  now you’ve got 3 of those with a different t (one for accelTime, decelTime and moveTime (remember, moveTime is actually total time accelTime decelTime)).

now it’s a simple matter of solving for vf.  once you got that, you can easily change velocity by calling the function and updating every frame based on x/totalStageTime.

—————————————-

well, enough of that math stuff.

i think the best thing about the mover code is that it was extremely easy to plug it into every original mover, like doors, plats, trains and buttons.

there’s also a doom3 style gui triggering mechanism.  it’s not graphically fancy, and it doesn’t do anything more than fire it’s targets, but it allows you to walk up to a button and ‘click’ it to use it (as opposed to just bumping into it).

i won’t be using it for normal buttons (because, quake is after all, about bumping into buttons– fast, simple gameplay), but for puzzles with multiple buttons in the same spot, it may be useful.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: