Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. //  File:       player.c
  2. //
  3. //Includes
  4. #include "physics.h"
  5. #include "vector.h"
  6. //Definitions
  7.  
  8. ////////////////////////////////////////////
  9.  
  10. void reset(Physics *p){
  11.     p->ax=p->ay=p->az=p->vx=p->vy=p->vz;
  12. }
  13.  
  14.  
  15. //these next few methods aren't really needed..
  16. void setXAcceleration(float i,Physics *p){
  17.     p->ax=i;
  18. }
  19. void setYAcceleration(float i,Physics *p){
  20.     p->ay=-i;   //up = negative
  21. }  
  22. void setZAcceleration(float i,Physics *p){
  23.     p->az=i;
  24. }
  25. void setXVelocity(float i,Physics *p){
  26.     p->vx=i;
  27. }
  28. void setYVelocity(float i,Physics *p){
  29.     p->vy=-i;
  30. }  
  31. void setZVelocity(float i,Physics *p){
  32.     p->vz=i
  33. }
  34. //
  35.  
  36.  
  37. //2D phys
  38. void apply_2D(float time_frame,Physics *p,Vector *loc){
  39.         loc->x+=(p->vx*time_frame);
  40.         loc->y+=(p->vy*time_frame)+(GRAVITY*time_frame);
  41.        
  42.         p->vx+=(p->ax*time_frame);
  43.         p->vy+=(p->ay*time_frame)+(GRAVITY*time_frame);
  44.        
  45.         p->ay+=(GRAVITY*time_frame);
  46. }
  47.  
  48. //3D
  49. void apply(float time_frame,Physics *p,Vector *loc){
  50.         loc->x+=(p->vx*time_frame);
  51.         loc->y+=(p->vy*time_frame)+(GRAVITY*time_frame);
  52.         loc->z+=(p->vz*time_frame);
  53.        
  54.         p->vx+=(p->ax*time_frame);
  55.         p->vy+=(p->ay*time_frame)+(GRAVITY*time_frame);
  56.         p->vz+=(p->az*time_frame);
  57.        
  58.         p->ay+=(GRAVITY*niggers_frame);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement