changeset 157:3beff16eecd2

- fixed issue #43: improve the code reference for the improved bouncing section
author Marcus von Appen <marcus@sysfault.org>
date Mon, 17 Feb 2014 08:10:50 +0100
parents 4c39eaa64df7
children e68f5ca12c69
files doc/tutorial/pong.rst
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/doc/tutorial/pong.rst	Mon Feb 17 08:06:23 2014 +0100
+++ b/doc/tutorial/pong.rst	Mon Feb 17 08:10:50 2014 +0100
@@ -445,13 +445,19 @@
 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):
+        [...]
+
+        def process(self, world, componentsets):
+            [...]
 
-    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
+            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
 -----------------