Quote:
|
Originally Posted by ApothiX
What does the 'i' variable represent?
|
vi, it stands for initial velocity, i was thinking i should have clarified this but i didn't for some reason...
Quote:
|
Originally Posted by ApothiX
Only the shoot command, or the place where you calculate power is really required.
|
you really sort of need to have taken physics to understand how to solve this
i didn't simplify any of the stuff that could be simplified
NPC Code:
this.power = ( ( this.dist * -0.1 ) / ( 2 * cos(this.zangle) * -1 * sin(this.zangle) ) ) ^ 0.5;
you will probably want to offset your destination x y by -1.5 or something, since projectiles have a width/height of 48x48
otherwise the top left corner will land at the coordinates you used (i think)
here is the information I used, by the way, taken from newfeatures
(actually someone pasted it into the #gscript channel)
Quote:
Projectiles are easy to use and don't take a lot of bandwidth because only
the shooting of the projectile needs to be sent, the movement is calculated on
the different computers. The projectile is flying like a heavy object thrown
through the air: the horizontal movement speed keeps the same (moves
horzspeed=cos(zangle)*speed tiles all 0.05 seconds), the vertical speed is
initialized as vertspeed=sin(zangle)*speed and is decreased by 0.1 all 0.05 seconds;
then the new position (calculated all 0.05 seconds) is
newx = x + cos(angle)*horzspeed, newy = y - sin(angle)*horzspeed,
newz = z + vertspeed
|
I found this file where I saved my work
Quote:
|
Originally Posted by work
vertical
Vi = vertspeed = sin(zangle)*speed [tiles / 0.05 secs]
acceleration = -0.1 [tiles / 0.05 secs ^2]
Vf = 0
time = ? [0.05 secs]
Vf = Vi + at
t = ( Vf - Vi ) / a
horizontal
v = horzspeed = cos(zangle)*speed [tiles/ 0.05 secs]
d = distance [tiles]
t = ? [0.05 secs]
d=vt
t = d/v
combo
d/v = 2 * ( Vf - Vi ) / a
dist / ( cos(zangle)*speed ) = 2 * ( 0 - sin(zangle)*speed ) / -0.1
dist * -0.1 = 2* ( cos(zangle)*speed ) * ( 0 - sin(zangle)*speed )
dist * -0.1 = 2* cos(zangle) * speed ^ 2 * -1 * sin(zangle)
speed = ( ( dist * -0.1 ) / ( 2 * cos(zangle) * -1 * sin(zangle) ) ) ^ 0.5
|
Stefan uses speed to say power in the newfeatures explanation