Guest User

Untitled

a guest
Oct 23rd, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. if ((SDL_GetTicks() - time) > 250) {
  2.             if (((ping.x + ping.w) - dot.x) == 0) {
  3.                 dot_hit_ping = true;
  4.                 dot_hit_pong = false;
  5.             }
  6.             else if ((pong.x - (dot.x + dot.w)) == 0) {
  7.                 dot_hit_pong = true;
  8.                 dot_hit_ping = false;
  9.             }
  10.  
  11.             if (! dot_hit_ping && ! dot_hit_pong)
  12.                 dot.x -= dot_x_velocity;
  13.             else if (dot_hit_ping) {
  14.                 if (dot.y >= ping.y && (dot.y + dot.h) <= (ping.y + (ping.h / 2))) {
  15.                     dot_hit_ping_up = true;
  16.                     dot_hit_ping_down = false;
  17.                 } else if (dot.y > (ping.y + (ping.h / 2)) && (dot.y + dot.h) <= (ping.y + ping.h)) {
  18.                     dot_hit_ping_up = false;
  19.                     dot_hit_ping_down = true;
  20.                 }
  21.  
  22.                 if (dot_hit_ping_up) {
  23.                     dot.x += dot_x_velocity;
  24.                     dot.y -= dot_y_velocity;
  25.                 } else if (dot_hit_ping_down) {
  26.                     dot.x += dot_x_velocity;
  27.                     dot.y += dot_y_velocity;
  28.                 } else {
  29.                     dot.x += dot_x_velocity;
  30.                 }
  31.             }
  32.             else if (dot_hit_pong) {
  33.                if (dot.y >= pong.y && (dot.y + dot.h) <= (pong.y + (pong.h / 2))) {
  34.                     dot_hit_pong_up = true;
  35.                     dot_hit_pong_down = false;
  36.                 } else if (dot.y > (pong.y + (pong.h / 2)) && (dot.y + dot.h) <= (pong.y + pong.h)) {
  37.                     dot_hit_pong_up = false;
  38.                     dot_hit_pong_down = true;
  39.                 }
  40.  
  41.                 if (dot_hit_pong_up) {
  42.                     dot.x -= dot_x_velocity;
  43.                     dot.y -= dot_y_velocity;
  44.                 } else if (dot_hit_pong_down) {
  45.                     dot.x -= dot_x_velocity;
  46.                     dot.y += dot_y_velocity;
  47.                 } else {
  48.                     dot.x -= dot_x_velocity;
  49.                 }
  50.             }
  51.  
  52.             time = SDL_GetTicks();
  53.         }
Add Comment
Please, Sign In to add comment