Issue #43 resolved

The Pong Game - Improved bouncing

Jordan F
created an issue

So it may just be me, but upon reading the tutorial I could not figure out where the last set of "if" statements for bouncing off of walls went, since they do not following the typical flow of the rest of the tutorial by filling in near some other code as a hint. I had to read the source code for the example to find where they went. Perhaps to better follow the flow of the tutorial change:

if self.ball.sprite.y <= self.miny or \
        self.ball.sprite.y + self.ball.sprite.size[1] >= self.maxy:
    self.ball.velocity.vy = - self.ball.velocity.vy

if self.ball.sprite.x <= self.minx or \
        self.ball.sprite.x + self.ball.sprite.size[0] >= self.maxx:
    self.ball.velocity.vx = - self.ball.velocity.vx

to be:

class CollisionSystem(sdl2ext.Applicator):
    [...]

    def process(self, world, componentsets):
        [...]
        if self.ball.sprite.y <= self.miny or \
                self.ball.sprite.y + self.ball.sprite.size[1] >= self.maxy:
            self.ball.velocity.vy = - self.ball.velocity.vy

        if self.ball.sprite.x <= self.minx or \
                self.ball.sprite.x + self.ball.sprite.size[0] >= self.maxx:
            self.ball.velocity.vx = - self.ball.velocity.vx

Comments (1)

  1. Log in to comment