Commits

Marcus von Appen  committed 3beff16

- fixed issue #43: improve the code reference for the improved bouncing section

  • Participants
  • Parent commits 4c39eaa

Comments (0)

Files changed (1)

File doc/tutorial/pong.rst

 This means that we just need to invert the vertical velocity, once the
 ball hits the top or bottom. ::
 
-    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
+    class CollisionSystem(sdl2ext.Applicator):
+        [...]
 
-    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
+        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
 
 Creating an enemy
 -----------------