/*********************** * Johnny Jetpack * by Paul Adam and Jamie Bradley * * physics.c * * this file contains velocity modification functions as well as * geometric tranformation functions. *************************/ #include #include #include #include #include "johnny.h" void UpdateVelocity(void) { int temp; /*temp = nextVelocity[Yv];*/ /*Velocity[Yv] = Velocity[Yv] + (Thrust - Gravity); if (Velocity[Yv] > MAX_VELOCITY_Y_UP) Velocity[Yv] = MAX_VELOCITY_Y_UP; if (Velocity[Yv] < MAX_VELOCITY_Y_DOWN) Velocity[Yv] = MAX_VELOCITY_Y_DOWN; */ nextVelocity[Yv] = Velocity[Yv] + (Thrust - Gravity); if (nextVelocity[Yv] > MAX_VELOCITY_Y_UP) nextVelocity[Yv] = MAX_VELOCITY_Y_UP; if (nextVelocity[Yv] < -50) nextVelocity[Yv] = MAX_VELOCITY_Y_DOWN; Velocity[Yv] = nextVelocity[Yv]; } void RotateVector(int angle, int vector[3], int cx, int cy) { int xp, yp; float radangle; radangle = angle * RADIANS; xp = vector[Xv]; yp = vector[Zv]; xp -= cx; yp -= cy; xp = (vector[Xv] * cos(radangle)) - (vector[Zv] * sin(radangle)); yp = (vector[Xv] * sin(radangle)) + (vector[Zv] * cos(radangle)); xp += cx; yp += cy; vector[Xv] = xp; vector[Zv] = yp; }