Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. void logic() {
  2.     kb_key_t key;
  3.     uint16_t physicsTime = timer_1_Counter / 3276.8 - game.lastPhysics;
  4.  
  5.     kb_Scan();
  6.     key = kb_Data[7];
  7.     if(key & kb_Left) game.position.rot -= game.rotAmount;
  8.     if(key & kb_Right) game.position.rot += game.rotAmount;
  9.  
  10.     game.position.x += game.position.velocity_x * physicsTime;
  11.     game.position.y += game.position.velocity_y * physicsTime;
  12.  
  13.     game.position.velocity_x += game.acceleration * physicsTime * cos(M_PI * (float)game.position.rot / 128) / 128;
  14.     game.position.velocity_y += game.acceleration * physicsTime * sin(M_PI * (float)game.position.rot / 128) / 128;
  15.     game.lastPhysics += physicsTime;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement