{"id":854,"date":"2026-09-08T08:41:29","date_gmt":"2026-09-08T08:41:29","guid":{"rendered":"https:\/\/x.sheep-mine.ts.net\/index.php\/why-is-my-ball-clipping-through-the-paddle\/"},"modified":"2026-09-08T08:41:29","modified_gmt":"2026-09-08T08:41:29","slug":"why-is-my-ball-clipping-through-the-paddle","status":"publish","type":"post","link":"https:\/\/x.sheep-mine.ts.net\/index.php\/why-is-my-ball-clipping-through-the-paddle\/","title":{"rendered":"Why is my ball clipping through the paddle?"},"content":{"rendered":"<p><br \/>\n<\/p>\n<p>I&#8217;m a young C++ developer, and it&#8217;s my first time transitioning to real programs instead of boring terminal ones like hangman or calculators.<\/p>\n<p>I tried making Pong. I made 2 player paddles, a net, and a moving ball.<\/p>\n<p>However, I encountered an error when I wanted to add collision detection between the paddle and the ball. I tried making my own one, but I ended up looking up code and implementing it my own way.<\/p>\n<p>Here&#8217;s the code for my collision detection:<\/p>\n<pre class=\"lang-c prettyprint-override\"><code>void CheckPaddleAndBallCollision(Paddle& paddle, Ball& ball)\n{\n    if (SDL_IntersectRect(&paddle.getPaddleRect(), &ball.getBallRect(), nullptr))\n    {\n        ball.setVelocityX(-ball.getVelocityX());\n    }\n}\n<\/code><\/pre>\n<p>I thought reversing the velocity automatically makes the ball go the opposite direction when it touches the paddle, but it&#8217;s not consistently deflecting away.<\/p>\n<p><br \/>\n<br \/><a href=\"https:\/\/gamedev.stackexchange.com\/questions\/217407\/why-is-my-ball-clipping-through-the-paddle\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a young C++ developer, and it&#8217;s my first time transitioning to real programs instead&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1789,1790,1791,1793,1792],"tags":[],"class_list":["post-854","post","type-post","status-publish","format-standard","hentry","category-c","category-collision-detection","category-physics","category-pong","category-sdl2"],"_links":{"self":[{"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/posts\/854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/comments?post=854"}],"version-history":[{"count":0,"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/posts\/854\/revisions"}],"wp:attachment":[{"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/media?parent=854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/categories?post=854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/x.sheep-mine.ts.net\/index.php\/wp-json\/wp\/v2\/tags?post=854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}