Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ((SDL_GetTicks() - time) > 250) {
- if (((ping.x + ping.w) - dot.x) == 0) {
- dot_hit_ping = true;
- dot_hit_pong = false;
- }
- else if ((pong.x - (dot.x + dot.w)) == 0) {
- dot_hit_pong = true;
- dot_hit_ping = false;
- }
- if (! dot_hit_ping && ! dot_hit_pong)
- dot.x -= dot_x_velocity;
- else if (dot_hit_ping) {
- if (dot.y >= ping.y && (dot.y + dot.h) <= (ping.y + (ping.h / 2))) {
- dot_hit_ping_up = true;
- dot_hit_ping_down = false;
- } else if (dot.y > (ping.y + (ping.h / 2)) && (dot.y + dot.h) <= (ping.y + ping.h)) {
- dot_hit_ping_up = false;
- dot_hit_ping_down = true;
- }
- if (dot_hit_ping_up) {
- dot.x += dot_x_velocity;
- dot.y -= dot_y_velocity;
- } else if (dot_hit_ping_down) {
- dot.x += dot_x_velocity;
- dot.y += dot_y_velocity;
- } else {
- dot.x += dot_x_velocity;
- }
- }
- else if (dot_hit_pong) {
- if (dot.y >= pong.y && (dot.y + dot.h) <= (pong.y + (pong.h / 2))) {
- dot_hit_pong_up = true;
- dot_hit_pong_down = false;
- } else if (dot.y > (pong.y + (pong.h / 2)) && (dot.y + dot.h) <= (pong.y + pong.h)) {
- dot_hit_pong_up = false;
- dot_hit_pong_down = true;
- }
- if (dot_hit_pong_up) {
- dot.x -= dot_x_velocity;
- dot.y -= dot_y_velocity;
- } else if (dot_hit_pong_down) {
- dot.x -= dot_x_velocity;
- dot.y += dot_y_velocity;
- } else {
- dot.x -= dot_x_velocity;
- }
- }
- time = SDL_GetTicks();
- }
Add Comment
Please, Sign In to add comment