Why does 0 % 5 return 0?
<p>I am making a game of pong right now, and I want the ball to speed up every 5 hits, but when I run the ball just starts speeding off in its starting direction.</p>

<p>It runs fine without the speeding up of the ball so the problem isn't previous code.</p>

<p>When trying to implement this I made a variable in my Ball class called <code>self.num_hits</code> and made it initially 0. Then in my game loop every time the ball collides, I increment the <code>ball.num_hits</code> and reverse its x_speed.</p>

<pre><code>collide_list = pygame.sprite.spritecollide(ball, players, False)
if collide_list != []:
    ball.x_speed *= -1
    hit.play()
    ball.num_hits += 1
</code></pre>

<p>In the Ball() class:</p>

<pre><code>if self.num_hits % 5 == 0:
        if self.x_speed &gt; 0:
            self.x_speed += 2
        else:
            self.x_speed -= 2
</code></pre>

<p>But that made the ball speed off in its starting velocity, so I checked what <code>self.num_hits % 5</code> was returning, and it always returns 0. I always thought that <code>0 % number = number</code>, so my question is why does 0 % 5 return 0? And is there any other way I can make the ball speed up every 5 hits if I can't get around the 0 % 5 problem?</p>
