title
Python Game Tutorial: Pong
description
A Pong clone game tutorial for beginners using Python 3.
⭐️Course contents ⭐️
⌨️ (00:00) Part I: Introduction and the basic window setup
Code: http://christianthompson.com/sites/default/files/Pong/Pong1.py
⌨️ (03:32) Part II: Add game objects to the screen (Paddles and Ball)
Code: http://christianthompson.com/sites/default/files/Pong/Pong2.py
⌨️ (09:15) Part III: Moving the Paddles
Code: http://christianthompson.com/sites/default/files/Pong/Pong3.py
⌨️ (15:06) Part IV: Moving the ball
Code: http://christianthompson.com/sites/default/files/Pong/Pong4.py
⌨️ (24:10) Part V: Colliding with the Paddles
Code: http://christianthompson.com/sites/default/files/Pong/Pong5.py
⌨️ (30:47) Part VI: Scoring
Code: http://christianthompson.com/sites/default/files/Pong/Pong6.py
⌨️ (37:57) Part VII: Adding Sound
Code: http://christianthompson.com/sites/default/files/Pong/Pong7.py
🔈 Sound file: http://christianthompson.com/sites/default/files/Pong/bounce.wav
💻 Finished Code: http://christianthompson.com/sites/default/files/Pong/pong.py
Tutorial from Christian Thompson. Check out his YouTube channel: https://www.youtube.com/channel/UC2vm-0XX5RkWCXWwtBZGOXg
--
Learn to code for free and get a developer job: https://www.freecodecamp.org
Read hundreds of articles on programming: https://medium.freecodecamp.org
detail
{'title': 'Python Game Tutorial: Pong', 'heatmap': [{'end': 1269.175, 'start': 1242.905, 'weight': 0.948}, {'end': 1670.959, 'start': 1583.61, 'weight': 0.826}, {'end': 1751.372, 'start': 1685.862, 'weight': 0.783}, {'end': 1799.747, 'start': 1769.345, 'weight': 1}], 'summary': 'Learn to build a classic pong game using python 3, focusing on the turtle module for graphics, creating elements with specific coordinates and attributes, troubleshooting errors, implementing collision logic, adding a scoring system, and integrating sound effects for a complete gaming experience.', 'chapters': [{'end': 125.257, 'segs': [{'end': 28.707, 'src': 'embed', 'start': 0.149, 'weight': 0, 'content': [{'end': 2.91, 'text': 'Simple Pong in Python 3 for Beginners Part 1.', 'start': 0.149, 'duration': 2.761}, {'end': 5.171, 'text': "Let's take a look at what we're going to be building today.", 'start': 2.91, 'duration': 2.261}, {'end': 7.111, 'text': 'Classic Pong game.', 'start': 5.871, 'duration': 1.24}, {'end': 8.832, 'text': "So we've got a paddle on the right.", 'start': 7.611, 'duration': 1.221}, {'end': 11.392, 'text': "We've got a paddle on the left.", 'start': 10.292, 'duration': 1.1}, {'end': 15.034, 'text': "And we've got a ball in the center.", 'start': 13.253, 'duration': 1.781}, {'end': 18.175, 'text': 'Okay, and the ball goes off the screen.', 'start': 15.054, 'duration': 3.121}, {'end': 25.637, 'text': 'And the opposite player gets a point and the ball continues.', 'start': 20.355, 'duration': 5.282}, {'end': 28.707, 'text': "Okay, so that is what we're gonna be working on.", 'start': 26.766, 'duration': 1.941}], 'summary': 'Building classic pong game with paddles and ball in python 3.', 'duration': 28.558, 'max_score': 0.149, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w149.jpg'}, {'end': 78.964, 'src': 'embed', 'start': 50.455, 'weight': 1, 'content': [{'end': 52.076, 'text': "It's great for getting started with games.", 'start': 50.455, 'duration': 1.621}, {'end': 56.337, 'text': 'A lot of tutorials use Pygame, which is amazing.', 'start': 52.716, 'duration': 3.621}, {'end': 58.158, 'text': "It's got a lot of great features.", 'start': 57.017, 'duration': 1.141}, {'end': 61.779, 'text': "But for beginners, this is a lot simpler, and it's built in.", 'start': 58.218, 'duration': 3.561}, {'end': 63.96, 'text': "You don't have to install it like you do with Pygame.", 'start': 61.799, 'duration': 2.161}, {'end': 70.441, 'text': "So now that I've got my turtle, imported, the module, I need to create a window.", 'start': 64.879, 'duration': 5.562}, {'end': 71.781, 'text': "So I'm going to call it WN.", 'start': 70.461, 'duration': 1.32}, {'end': 74.622, 'text': 'You can call it Win, W-I-N, or whatever you want to call it.', 'start': 72.262, 'duration': 2.36}, {'end': 76.743, 'text': 'But I use WN.', 'start': 75.923, 'duration': 0.82}, {'end': 78.964, 'text': "And it's turtle.screen.", 'start': 77.483, 'duration': 1.481}], 'summary': 'Turtle module is simpler than pygame for beginners, built-in without installation.', 'duration': 28.509, 'max_score': 50.455, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w50455.jpg'}, {'end': 130.822, 'src': 'embed', 'start': 99.135, 'weight': 2, 'content': [{'end': 101.437, 'text': 'Do feel free to leave comments.', 'start': 99.135, 'duration': 2.302}, {'end': 104.819, 'text': 'I do keep a close eye on things.', 'start': 101.657, 'duration': 3.162}, {'end': 105.88, 'text': 'If you have any trouble, let me know.', 'start': 104.879, 'duration': 1.001}, {'end': 110.084, 'text': 'And I want to change the background color of the window to black.', 'start': 106.72, 'duration': 3.364}, {'end': 111.345, 'text': "It's classic Pong.", 'start': 110.545, 'duration': 0.8}, {'end': 113.848, 'text': 'And I want to change the size of the window.', 'start': 111.846, 'duration': 2.002}, {'end': 115.45, 'text': 'And I want the width to be 800.', 'start': 114.349, 'duration': 1.101}, {'end': 121.336, 'text': 'And I want the height to be 600 pixels.', 'start': 115.45, 'duration': 5.886}, {'end': 125.257, 'text': "And then I'm going to do something called Wind Tracer.", 'start': 122.995, 'duration': 2.262}, {'end': 130.822, 'text': "This one's a little bit hard to explain, but basically what that does is it actually stops the window from updating.", 'start': 125.697, 'duration': 5.125}], 'summary': 'Modify window to black, classic pong game, set window size to 800x600 pixels, implement wind tracer feature', 'duration': 31.687, 'max_score': 99.135, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w99135.jpg'}], 'start': 0.149, 'title': 'Python pong game tutorial', 'summary': 'Covers building a classic pong game using python 3. it focuses on the turtle module for basic graphics and creating a window with a title, background color, and size.', 'chapters': [{'end': 125.257, 'start': 0.149, 'title': 'Python pong game tutorial', 'summary': 'Covers building a classic pong game using python 3, focusing on the turtle module for basic graphics and creating a window with a title, background color, and size.', 'duration': 125.108, 'highlights': ['The chapter covers building a classic Pong game using Python 3, focusing on the turtle module for basic graphics and creating a window with a title, background color, and size.', 'The tutorial emphasizes building the game using Python 3 and the turtle module, which is simpler and built-in compared to Pygame, making it suitable for beginners.', "The chapter describes creating a window named 'WN' with a title 'Pong by at Tokyo EdTech' and changing the background color to black, with a size of 800x600 pixels."]}], 'duration': 125.108, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w149.jpg', 'highlights': ['The chapter covers building a classic Pong game using Python 3, focusing on the turtle module for basic graphics and creating a window with a title, background color, and size.', 'The tutorial emphasizes building the game using Python 3 and the turtle module, which is simpler and built-in compared to Pygame, making it suitable for beginners.', "The chapter describes creating a window named 'WN' with a title 'Pong by at Tokyo EdTech' and changing the background color to black, with a size of 800x600 pixels."]}, {'end': 673.957, 'segs': [{'end': 153.502, 'src': 'embed', 'start': 125.697, 'weight': 0, 'content': [{'end': 130.822, 'text': "This one's a little bit hard to explain, but basically what that does is it actually stops the window from updating.", 'start': 125.697, 'duration': 5.125}, {'end': 133.504, 'text': 'And so we have to manually update it.', 'start': 131.562, 'duration': 1.942}, {'end': 137.628, 'text': 'What this lets us do is basically speed up our games quite a bit.', 'start': 133.544, 'duration': 4.084}, {'end': 140.41, 'text': "If we didn't do that, things would run much, much slower.", 'start': 138.088, 'duration': 2.322}, {'end': 144.654, 'text': 'So every game needs something called a Main Game Loop.', 'start': 141.051, 'duration': 3.603}, {'end': 149.498, 'text': 'And this is where basically all the meat and potatoes of your game goes to.', 'start': 145.174, 'duration': 4.324}, {'end': 153.502, 'text': "So we're going to make a loop while true.", 'start': 149.518, 'duration': 3.984}], 'summary': 'Using a main game loop can speed up games by preventing window updates, improving performance significantly.', 'duration': 27.805, 'max_score': 125.697, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w125697.jpg'}, {'end': 263.619, 'src': 'embed', 'start': 219.306, 'weight': 2, 'content': [{'end': 226.611, 'text': "In this part of the tutorial, we're going to add our paddles to the screen, and we're going to add the ball to the screen as well.", 'start': 219.306, 'duration': 7.305}, {'end': 227.892, 'text': "So let's get started with that.", 'start': 226.971, 'duration': 0.921}, {'end': 238.759, 'text': "So basically what we have in Pong is we have, I'm gonna call it Paddle A, we have Paddle B, and we have a ball.", 'start': 229.213, 'duration': 9.546}, {'end': 242.55, 'text': 'So those are the three items that we need to add to the screen.', 'start': 239.409, 'duration': 3.141}, {'end': 251.314, 'text': 'Now, as I mentioned earlier in the previous video, we are using the Turtle module to add our graphics and to open our windows and things like that.', 'start': 243.131, 'duration': 8.183}, {'end': 252.334, 'text': "It's very, very convenient.", 'start': 251.354, 'duration': 0.98}, {'end': 254.435, 'text': 'It works great for basic games.', 'start': 252.634, 'duration': 1.801}, {'end': 257.136, 'text': 'A lot of people use Pygame, which is great.', 'start': 254.455, 'duration': 2.681}, {'end': 260.617, 'text': 'But for simple games, this is probably an easier way to get started.', 'start': 257.776, 'duration': 2.841}, {'end': 263.619, 'text': 'So everything in our game needs a name.', 'start': 261.317, 'duration': 2.302}], 'summary': 'Adding paddles and ball to the screen using the turtle module for pong game.', 'duration': 44.313, 'max_score': 219.306, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w219306.jpg'}, {'end': 476.508, 'src': 'embed', 'start': 448.074, 'weight': 1, 'content': [{'end': 454.358, 'text': "Okay, so you can see now we've got a paddle over here.", 'start': 448.074, 'duration': 6.284}, {'end': 457.76, 'text': '20 pixels wide by 20 pixels high.', 'start': 454.978, 'duration': 2.782}, {'end': 461.662, 'text': "So that's paddle A.", 'start': 460.121, 'duration': 1.541}, {'end': 464.144, 'text': "Now I'm kind of a lazy guy, so I'm just going to copy.", 'start': 461.662, 'duration': 2.482}, {'end': 474.906, 'text': "So what I always recommend if something's similar, similar styles or similar, you know functions, you know, get it working right once and copy it,", 'start': 465.878, 'duration': 9.028}, {'end': 476.508, 'text': 'paste it and just make the necessary changes.', 'start': 474.906, 'duration': 1.602}], 'summary': 'Creating a 20x20 paddle a and suggesting to copy and paste for similar elements.', 'duration': 28.434, 'max_score': 448.074, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w448074.jpg'}, {'end': 522.613, 'src': 'embed', 'start': 495.508, 'weight': 4, 'content': [{'end': 500.689, 'text': "A lot of beginners, I don't know why, they insist on typing the whole program in and then trying to test it.", 'start': 495.508, 'duration': 5.181}, {'end': 506.311, 'text': "And you'll never be able to figure out where the problems are, especially as a beginner, unless you do it step by step like this.", 'start': 500.809, 'duration': 5.502}, {'end': 508.491, 'text': 'So we got our left paddle.', 'start': 506.891, 'duration': 1.6}, {'end': 509.552, 'text': 'We got our right paddle.', 'start': 508.671, 'duration': 0.881}, {'end': 511.352, 'text': 'So I just called it, I said, Paddle A, Paddle B.', 'start': 509.772, 'duration': 1.58}, {'end': 515.573, 'text': 'And then the last thing we need is going to be our ball.', 'start': 511.352, 'duration': 4.221}, {'end': 517.794, 'text': "So I'm going to just go ahead and copy this.", 'start': 516.212, 'duration': 1.582}, {'end': 520.03, 'text': "because it's basically the same thing.", 'start': 518.951, 'duration': 1.079}, {'end': 522.613, 'text': "I don't need it stretched.", 'start': 521.172, 'duration': 1.441}], 'summary': 'Beginners should code step by step to find problems. creating left and right paddles and a ball for a program.', 'duration': 27.105, 'max_score': 495.508, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w495508.jpg'}], 'start': 125.697, 'title': 'Creating pong game elements in python', 'summary': 'Discusses optimizing game performance, using the turtle module for graphics, and creating pong game elements with specific coordinates and attributes, focusing on functional programming. it covers setting up paddles and a ball, stretching the paddle width, copying elements, and testing the program at each stage.', 'chapters': [{'end': 394.212, 'start': 125.697, 'title': 'Simple pong in python 3', 'summary': 'Discusses the optimization of game performance through the main game loop, the usage of the turtle module for graphics, and the step-by-step creation of pong game elements, emphasizing the functional programming style and providing specific coordinates and attributes for the paddle.', 'duration': 268.515, 'highlights': ['The Main Game Loop is crucial for game performance optimization, as it allows manual screen updating to speed up the games significantly.', 'The usage of the Turtle module for graphics is highlighted for its convenience in creating basic games, with a focus on functional programming style and setting specific attributes and coordinates for the paddle.', 'The step-by-step creation of Pong game elements, such as paddles and the ball, is outlined, emphasizing the use of the Turtle module and providing specific coordinates and attributes for the paddle to ensure proper functionality and appearance.', 'The chapter also introduces the concept of object-oriented programming and classes, emphasizing a straightforward, old-school programming methodology suitable for beginners and providing detailed instructions for setting up the game elements.']}, {'end': 673.957, 'start': 394.212, 'title': 'Python programming: paddle and ball setup', 'summary': 'Covers setting up paddles and a ball in a python program, stretching the paddle width by five to make it 100 pixels tall and 20 pixels wide, copying and pasting similar elements to save time, and the importance of testing the program at each stage.', 'duration': 279.745, 'highlights': ['The chapter covers setting up paddles and a ball in a Python program, stretching the paddle width by five to make it 100 pixels tall and 20 pixels wide.', 'The importance of testing the program at each stage is emphasized, as beginners tend to type the whole program in and then try to test it, making it difficult to figure out problems.', 'Copying and pasting similar elements with necessary changes is recommended to speed up programming and avoid errors.', 'The process of moving the paddles using the keyboard involves creating functions for moving paddle A up, moving paddle A down, moving paddle B up, and moving paddle B down, with a focus on defining and testing one function at a time.', "Understanding the y-coordinate and using the Turtle module's y-core method to return the y coordinate for moving the paddle are explained in detail."]}], 'duration': 548.26, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w125697.jpg', 'highlights': ['The Main Game Loop is crucial for game performance optimization, allowing manual screen updating to speed up games significantly.', 'The chapter covers setting up paddles and a ball, stretching the paddle width by five to make it 100 pixels tall and 20 pixels wide.', 'The usage of the Turtle module for graphics is highlighted for its convenience in creating basic games, with a focus on functional programming style and setting specific attributes and coordinates for the paddle.', 'The step-by-step creation of Pong game elements, such as paddles and the ball, is outlined, emphasizing the use of the Turtle module and providing specific coordinates and attributes for the paddle to ensure proper functionality and appearance.', 'The importance of testing the program at each stage is emphasized, as beginners tend to type the whole program in and then try to test it, making it difficult to figure out problems.']}, {'end': 1055.925, 'segs': [{'end': 700.138, 'src': 'embed', 'start': 674.497, 'weight': 2, 'content': [{'end': 679.061, 'text': "So then what I want to do, if I'm going to go up on the screen, it's this way, so up.", 'start': 674.497, 'duration': 4.564}, {'end': 683.345, 'text': 'So Y increases as we go up.', 'start': 679.541, 'duration': 3.804}, {'end': 685.186, 'text': 'It decreases as we go down.', 'start': 683.645, 'duration': 1.541}, {'end': 686.787, 'text': "So what I'm going to do is I'm going to add.", 'start': 685.206, 'duration': 1.581}, {'end': 689.775, 'text': '20 to y.', 'start': 688.355, 'duration': 1.42}, {'end': 690.756, 'text': 'And this is the way you do that.', 'start': 689.775, 'duration': 0.981}, {'end': 693.736, 'text': 'You say y plus equals 20.', 'start': 691.376, 'duration': 2.36}, {'end': 697.057, 'text': 'So that will add 20 pixels to the y coordinate.', 'start': 693.736, 'duration': 3.321}, {'end': 700.138, 'text': "So now notice we've just calculated the y.", 'start': 698.317, 'duration': 1.821}], 'summary': 'Demonstrating adding 20 pixels to y coordinate on screen.', 'duration': 25.641, 'max_score': 674.497, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w674497.jpg'}, {'end': 893.176, 'src': 'embed', 'start': 864.199, 'weight': 0, 'content': [{'end': 872.344, 'text': "So if you keep your naming consistent, it makes it very, very easy to do what I'm doing, which is to be lazy and just use copy and paste.", 'start': 864.199, 'duration': 8.145}, {'end': 881.569, 'text': "And then here, now for paddle B, I'm going to use the arrow keys.", 'start': 873.745, 'duration': 7.824}, {'end': 884.991, 'text': "And then for the up arrow, it's a little bit different.", 'start': 882.43, 'duration': 2.561}, {'end': 886.812, 'text': "Use up, notice it's capitalized.", 'start': 885.131, 'duration': 1.681}, {'end': 889.494, 'text': 'And down is the down arrow.', 'start': 888.033, 'duration': 1.461}, {'end': 891.575, 'text': 'So again, I made a couple changes.', 'start': 890.074, 'duration': 1.501}, {'end': 893.176, 'text': "I'm going to test my code.", 'start': 891.595, 'duration': 1.581}], 'summary': 'Consistent naming eases copy-paste; using arrow keys with capitalization. making changes and testing code.', 'duration': 28.977, 'max_score': 864.199, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w864199.jpg'}, {'end': 995.558, 'src': 'embed', 'start': 939.431, 'weight': 1, 'content': [{'end': 947.537, 'text': "with the ball is I want to separate the ball's movement into two parts, an x movement and a y movement.", 'start': 939.431, 'duration': 8.106}, {'end': 951.661, 'text': "So what I'm going to call that, I'm going to say ball.dx.", 'start': 948.258, 'duration': 3.403}, {'end': 954.003, 'text': 'D means delta or change.', 'start': 952.321, 'duration': 1.682}, {'end': 957.285, 'text': 'You can call it x speed or whatever you want to.', 'start': 954.883, 'duration': 2.402}, {'end': 959.227, 'text': 'But dx works very, very well.', 'start': 957.625, 'duration': 1.602}, {'end': 964.17, 'text': 'Now, on my computer, I found that the number 2 works very, very well.', 'start': 960.047, 'duration': 4.123}, {'end': 967.773, 'text': 'My computer at home, actually, it was like 0.1.', 'start': 964.851, 'duration': 2.922}, {'end': 969.354, 'text': "It's much, much faster.", 'start': 967.773, 'duration': 1.581}, {'end': 970.475, 'text': "I don't quite know why.", 'start': 969.374, 'duration': 1.101}, {'end': 975.919, 'text': 'So you might have to play with the numbers here to get it to where you feel the game should be.', 'start': 970.495, 'duration': 5.424}, {'end': 980.914, 'text': 'So dx and dy equals 2.', 'start': 978.553, 'duration': 2.361}, {'end': 987.075, 'text': 'So what that means is every time our ball moves, it moves by 2 pixels.', 'start': 980.914, 'duration': 6.161}, {'end': 990.997, 'text': "So since x is positive, it's going to move to the right 2.", 'start': 987.536, 'duration': 3.461}, {'end': 993.177, 'text': "And since y is positive, it's going to move up 2.", 'start': 990.997, 'duration': 2.18}, {'end': 995.558, 'text': "So it'll be kind of moving up and diagonally.", 'start': 993.177, 'duration': 2.381}], 'summary': 'Separate ball movement into dx and dy, where dx=2 pixels, dy=2 pixels.', 'duration': 56.127, 'max_score': 939.431, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w939431.jpg'}], 'start': 674.497, 'title': 'Python paddle game and ball movement', 'summary': 'Demonstrates creating a python paddle game with keyboard bindings, adding 20 pixels to the y coordinate per key press, and moving the ball with dx and dy variables, initially set to 2 pixels per move.', 'chapters': [{'end': 893.176, 'start': 674.497, 'title': 'Python paddle game tutorial', 'summary': 'Demonstrates how to create a python paddle game, including adding 20 pixels to the y coordinate when the user presses a key, and testing the functionality of moving the paddle up and down with keyboard bindings.', 'duration': 218.679, 'highlights': ["The chapter demonstrates how to add 20 pixels to the y coordinate when the user presses a key, using the 'y plus equals 20' method.", 'The tutorial explains the process of setting up keyboard bindings for moving the paddle up and down, using specific keys for each direction.', 'The instructor tests the functionality of moving the paddle up and down by pressing the designated keys on the keyboard to ensure the code works as expected.']}, {'end': 1055.925, 'start': 895.128, 'title': 'Moving the ball in game programming', 'summary': "Focuses on moving the ball in game programming, emphasizing the use of dx and dy to control the speed and direction of the ball's movement, with a recommended initial value of 2 pixels per move.", 'duration': 160.797, 'highlights': ["The concept of separating the ball's movement into x and y components using dx and dy is introduced, with a suggested initial value of 2 pixels for each movement.", "The importance of adjusting the speed and direction of the ball's movement is highlighted, with a recommendation to experiment with different values to achieve desired gameplay.", "Demonstrating the use of dx and dy to control the ball's movement by incrementing the current coordinates by the respective dx and dy values within the main game loop."]}], 'duration': 381.428, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w674497.jpg', 'highlights': ['The tutorial explains the process of setting up keyboard bindings for moving the paddle up and down, using specific keys for each direction.', "Demonstrating the use of dx and dy to control the ball's movement by incrementing the current coordinates by the respective dx and dy values within the main game loop.", "The chapter demonstrates how to add 20 pixels to the y coordinate when the user presses a key, using the 'y plus equals 20' method.", "The concept of separating the ball's movement into x and y components using dx and dy is introduced, with a suggested initial value of 2 pixels for each movement.", "The importance of adjusting the speed and direction of the ball's movement is highlighted, with a recommendation to experiment with different values to achieve desired gameplay.", 'The instructor tests the functionality of moving the paddle up and down by pressing the designated keys on the keyboard to ensure the code works as expected.']}, {'end': 1454.516, 'segs': [{'end': 1096.676, 'src': 'embed', 'start': 1055.945, 'weight': 0, 'content': [{'end': 1062.05, 'text': "So I'm going to save that, and I'm going to test it and see what happens.", 'start': 1055.945, 'duration': 6.105}, {'end': 1063.981, 'text': 'You see some red lines here.', 'start': 1063.021, 'duration': 0.96}, {'end': 1066.302, 'text': "I think there's going to be a problem.", 'start': 1064.021, 'duration': 2.281}, {'end': 1070.264, 'text': "So I'm going to run that and explain why it's not going to work.", 'start': 1066.762, 'duration': 3.502}, {'end': 1072.825, 'text': "So you can see here I've got an error.", 'start': 1071.044, 'duration': 1.781}, {'end': 1078.126, 'text': "And this is something, again, beginners, I don't know why, do not want to read error messages.", 'start': 1073.365, 'duration': 4.761}, {'end': 1080.607, 'text': "The error messages basically tell you what's wrong.", 'start': 1078.927, 'duration': 1.68}, {'end': 1084.849, 'text': 'So you see here it says tab error, inconsistent use of tabs and spaces.', 'start': 1081.628, 'duration': 3.221}, {'end': 1088.011, 'text': 'Okay, so I mentioned this in an earlier video.', 'start': 1085.589, 'duration': 2.422}, {'end': 1091.793, 'text': "So here I used four spaces, but here it's a tab.", 'start': 1088.591, 'duration': 3.202}, {'end': 1094.215, 'text': "You've got to use the same thing each time.", 'start': 1092.714, 'duration': 1.501}, {'end': 1095.416, 'text': "So I'm going to go with four spaces.", 'start': 1094.235, 'duration': 1.181}, {'end': 1096.676, 'text': "That's actually the preferred method.", 'start': 1095.456, 'duration': 1.22}], 'summary': 'Inconsistent tab usage causes error, prefer using four spaces.', 'duration': 40.731, 'max_score': 1055.945, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1055945.jpg'}, {'end': 1145.055, 'src': 'embed', 'start': 1123.257, 'weight': 3, 'content': [{'end': 1131.644, 'text': "So what do we want to happen when the ball hits the border? Okay, so since it's moving up and to the right, we'll do the top border first.", 'start': 1123.257, 'duration': 8.387}, {'end': 1135.087, 'text': "Once we get the top border working, then it's easy to get the bottom border working.", 'start': 1132.024, 'duration': 3.063}, {'end': 1140.651, 'text': "So what we have to do is we have to compare the ball's Y coordinate.", 'start': 1136.087, 'duration': 4.564}, {'end': 1145.055, 'text': 'Okay, so once it gets to a certain point, we want it to bounce.', 'start': 1141.372, 'duration': 3.683}], 'summary': 'Developing the game logic to make the ball bounce at specific y coordinates.', 'duration': 21.798, 'max_score': 1123.257, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1123257.jpg'}, {'end': 1269.175, 'src': 'heatmap', 'start': 1242.905, 'weight': 0.948, 'content': [{'end': 1246.762, 'text': 'Now since This is working exactly as we want it.', 'start': 1242.905, 'duration': 3.857}, {'end': 1253.726, 'text': "I'm just going to copy and paste that and just make some changes.", 'start': 1246.782, 'duration': 6.944}, {'end': 1261.671, 'text': "So on the other end, if it's less than negative 290, we set it to negative 290, and that is that.", 'start': 1254.186, 'duration': 7.485}, {'end': 1262.531, 'text': "So let's test that.", 'start': 1261.711, 'duration': 0.82}, {'end': 1269.175, 'text': "To test that, we'll need to start the ball off with a negative dy for now.", 'start': 1263.072, 'duration': 6.103}], 'summary': 'Adjusting values to ensure it stays above -290. testing with negative dy.', 'duration': 26.27, 'max_score': 1242.905, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1242905.jpg'}, {'end': 1316.595, 'src': 'embed', 'start': 1281.438, 'weight': 5, 'content': [{'end': 1282.379, 'text': "So that's the borders.", 'start': 1281.438, 'duration': 0.941}, {'end': 1284.261, 'text': "That's the top and bottom borders.", 'start': 1282.399, 'duration': 1.862}, {'end': 1290.006, 'text': 'Now, the next thing we need to do is the left and right border.', 'start': 1285.762, 'duration': 4.244}, {'end': 1300.535, 'text': 'So this is where it gets not more tricky or anything, but you gotta think about what we want to happen.', 'start': 1292.888, 'duration': 7.647}, {'end': 1307.749, 'text': "So in this case, because we're looking at left and right, Okay, we're not looking at the y coordinate, we're looking at the x coordinate.", 'start': 1300.595, 'duration': 7.154}, {'end': 1316.595, 'text': 'And now what we wanna do is if the x coordinate, basically if it goes off the right side.', 'start': 1308.73, 'duration': 7.865}], 'summary': 'Setting borders on all sides, focusing on x coordinate.', 'duration': 35.157, 'max_score': 1281.438, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1281438.jpg'}, {'end': 1382.83, 'src': 'embed', 'start': 1335.828, 'weight': 4, 'content': [{'end': 1351.238, 'text': "Okay, so if that's the case, basically we're going to put the ball back to the center, zero.", 'start': 1335.828, 'duration': 15.41}, {'end': 1359.763, 'text': 'And then what I can do is I can maybe ball.dx, maybe have it reverse direction.', 'start': 1351.778, 'duration': 7.985}, {'end': 1363.386, 'text': "Okay, so let's take a look at that.", 'start': 1362.366, 'duration': 1.02}, {'end': 1368.667, 'text': "Again, I'm testing it to make sure it works, and if it does, then I can copy and paste and do the other side.", 'start': 1363.926, 'duration': 4.741}, {'end': 1377.709, 'text': 'Okay, so we got an error.', 'start': 1368.687, 'duration': 9.022}, {'end': 1382.83, 'text': 'Ah, okay.', 'start': 1378.929, 'duration': 3.901}], 'summary': 'Testing ball movement, encountered error.', 'duration': 47.002, 'max_score': 1335.828, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1335828.jpg'}], 'start': 1055.945, 'title': 'Troubleshooting and ball movement', 'summary': 'Covers troubleshooting tab error in python, emphasizing the importance of consistent use of tabs and spaces, and creating border checking for ball movement to ensure the ball stays within window dimensions.', 'chapters': [{'end': 1096.676, 'start': 1055.945, 'title': 'Troubleshooting tab error in python', 'summary': 'Highlights the importance of reading error messages, specifically addressing a tab error due to inconsistent use of tabs and spaces in python code, emphasizing the preferred method of using four spaces consistently.', 'duration': 40.731, 'highlights': ["The error messages basically tell you what's wrong.", 'Addressing tab error due to inconsistent use of tabs and spaces in Python code.', 'Emphasizing the preferred method of using four spaces consistently.']}, {'end': 1454.516, 'start': 1098.378, 'title': 'Creating border checking for ball movement', 'summary': 'Discusses setting up border checking for a ball movement, including adjusting the y coordinate for top and bottom borders, and adjusting the x coordinate for left and right borders, ensuring the ball bounces back within the window dimensions.', 'duration': 356.138, 'highlights': ['Adjusting Y coordinate for top and bottom borders', 'Reversing ball direction on Y axis', 'Adjusting X coordinate for left and right borders']}], 'duration': 398.571, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1055945.jpg', 'highlights': ["The error messages basically tell you what's wrong.", 'Addressing tab error due to inconsistent use of tabs and spaces in Python code.', 'Emphasizing the preferred method of using four spaces consistently.', 'Adjusting Y coordinate for top and bottom borders', 'Reversing ball direction on Y axis', 'Adjusting X coordinate for left and right borders']}, {'end': 1840.126, 'segs': [{'end': 1486.77, 'src': 'embed', 'start': 1454.516, 'weight': 0, 'content': [{'end': 1458.597, 'text': "So in this lesson we're going to learn how to get the ball to collide with the paddles.", 'start': 1454.516, 'duration': 4.081}, {'end': 1460.438, 'text': "So let's see what we have so far.", 'start': 1459.318, 'duration': 1.12}, {'end': 1461.338, 'text': "So we've got our ball.", 'start': 1460.558, 'duration': 0.78}, {'end': 1463.299, 'text': "It's bouncing off the top of the screen.", 'start': 1461.779, 'duration': 1.52}, {'end': 1467.321, 'text': 'And at the edge of the screen it goes back to the center which is what we want.', 'start': 1464.14, 'duration': 3.181}, {'end': 1472.083, 'text': "So what we've got to do is we've got to make it so that when it touches the paddles it will reverse.", 'start': 1467.341, 'duration': 4.742}, {'end': 1480.026, 'text': "And how we're going to do that is basically what we're going to do is we're going to compare the x and y coordinates of the paddle and the ball.", 'start': 1472.603, 'duration': 7.423}, {'end': 1486.77, 'text': 'So if we look at our code, we put paddle B at 350.', 'start': 1480.906, 'duration': 5.864}], 'summary': 'Lesson on making ball collide with paddles using x and y coordinates.', 'duration': 32.254, 'max_score': 1454.516, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1454516.jpg'}, {'end': 1552.299, 'src': 'embed', 'start': 1501.083, 'weight': 2, 'content': [{'end': 1509.133, 'text': "we need to make sure the ball is basically between here and here and that it's basically between here and here.", 'start': 1501.083, 'duration': 8.05}, {'end': 1511.394, 'text': "If it is, then we'll call that a bounce.", 'start': 1510.053, 'duration': 1.341}, {'end': 1515.196, 'text': 'Let me play the math a little bit on that and give that a shot.', 'start': 1512.234, 'duration': 2.962}, {'end': 1519.419, 'text': "Again, as I mentioned before, we're just going to try and get the right paddle working.", 'start': 1516.317, 'duration': 3.102}, {'end': 1523.161, 'text': "If we get the right paddle working, then it's easy to get the left paddle working.", 'start': 1520.199, 'duration': 2.962}, {'end': 1529.965, 'text': "I'm going to say paddle and ball collisions.", 'start': 1524.081, 'duration': 5.884}, {'end': 1543.512, 'text': "Okay, so if the ball dot x-core, so if the ball's x-coordinate is greater than so, we said 350, it's 10 wide.", 'start': 1531.903, 'duration': 11.609}, {'end': 1549.637, 'text': "so it's greater than, say, 340, and the ball?", 'start': 1543.512, 'duration': 6.125}, {'end': 1550.438, 'text': "well, actually, I'll leave it at that.", 'start': 1549.637, 'duration': 0.801}, {'end': 1552.299, 'text': "I'll leave it at that, and then we'll come back and fix it in a bit.", 'start': 1550.458, 'duration': 1.841}], 'summary': 'Code discussion on ball and paddle position for collision detection.', 'duration': 51.216, 'max_score': 1501.083, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1501083.jpg'}, {'end': 1670.959, 'src': 'heatmap', 'start': 1583.61, 'weight': 0.826, 'content': [{'end': 1589.652, 'text': 'Ball.YCore is greater than PaddleB.', 'start': 1583.61, 'duration': 6.042}, {'end': 1602.877, 'text': 'b dot y-core minus 50.', 'start': 1593.815, 'duration': 9.062}, {'end': 1607.818, 'text': "OK, so I'm glad that's scrolling over.", 'start': 1602.877, 'duration': 4.941}, {'end': 1611.139, 'text': 'So let me explain that real quick.', 'start': 1607.838, 'duration': 3.301}, {'end': 1615.78, 'text': "So if that's the case, OK, I'm going to tether.", 'start': 1611.399, 'duration': 4.381}, {'end': 1630.474, 'text': 'If that is the case, basically we just want the dx, same thing we did at the top, times equals one, although this is x not y.', 'start': 1621.184, 'duration': 9.29}, {'end': 1631.234, 'text': 'Sorry, negative one.', 'start': 1630.474, 'duration': 0.76}, {'end': 1635.919, 'text': "So if it's going this way, the dx is positive, it's gonna bounce and go back this way.", 'start': 1631.835, 'duration': 4.084}, {'end': 1643.24, 'text': 'So what we wanna see, is the ball X coordinate greater than 340? That means the edges are basically touching.', 'start': 1636.6, 'duration': 6.64}, {'end': 1649.885, 'text': 'And is it between the top of the paddle and the bottom of the paddle? Actually, I think it should be 50.', 'start': 1644.14, 'duration': 5.745}, {'end': 1652.227, 'text': 'It should probably be 40 because of the size of the ball.', 'start': 1649.885, 'duration': 2.342}, {'end': 1654.028, 'text': "Let's play around with that.", 'start': 1653.228, 'duration': 0.8}, {'end': 1655.229, 'text': "Let's test it out and see what happens.", 'start': 1654.048, 'duration': 1.181}, {'end': 1657.491, 'text': "Okay, so I'm going to run that.", 'start': 1656.651, 'duration': 0.84}, {'end': 1670.959, 'text': 'Oops Okay, so did you see what happened there? which is not what we wanted.', 'start': 1661.494, 'duration': 9.465}], 'summary': 'Adjust ball-paddle collision logic for better gameplay experience.', 'duration': 87.349, 'max_score': 1583.61, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1583610.jpg'}, {'end': 1751.372, 'src': 'heatmap', 'start': 1680.741, 'weight': 4, 'content': [{'end': 1682.882, 'text': 'But watch what happens if I miss it.', 'start': 1680.741, 'duration': 2.141}, {'end': 1685.302, 'text': "See, there's like a little bit of a glitch there.", 'start': 1683.502, 'duration': 1.8}, {'end': 1692.543, 'text': "It's because even though it's behind, the x coordinate is greater than 340 and it's between here.", 'start': 1685.862, 'duration': 6.681}, {'end': 1695.844, 'text': "Okay, so you see how that's kind of acting weird.", 'start': 1692.563, 'duration': 3.281}, {'end': 1699.905, 'text': "So what we need to do is I'm going to add this condition.", 'start': 1696.844, 'duration': 3.061}, {'end': 1709.518, 'text': "And ball.xCore is less than, we'll say, 350.", 'start': 1703.414, 'duration': 6.104}, {'end': 1713.761, 'text': 'So that gives it basically to the middle of the paddle.', 'start': 1709.518, 'duration': 4.243}, {'end': 1720.406, 'text': "So we'll say ball.setX to 340.", 'start': 1716.123, 'duration': 4.283}, {'end': 1722.928, 'text': 'So that moves it back to the left a little bit.', 'start': 1720.406, 'duration': 2.522}, {'end': 1730.013, 'text': 'And then it reverses the direction, which is what we wanted.', 'start': 1724.029, 'duration': 5.984}, {'end': 1737.365, 'text': "Okay, so let me test that one more time, make sure it's working.", 'start': 1735.384, 'duration': 1.981}, {'end': 1743.028, 'text': 'So it bounces, which is good.', 'start': 1741.787, 'duration': 1.241}, {'end': 1751.372, 'text': "Let's let it get past and see.", 'start': 1750.011, 'duration': 1.361}], 'summary': 'Adjusting x-coordinate condition to fix glitch and ensure proper ball movement.', 'duration': 33.02, 'max_score': 1680.741, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1680741.jpg'}, {'end': 1799.747, 'src': 'heatmap', 'start': 1769.345, 'weight': 1, 'content': [{'end': 1771.888, 'text': "And I'm just going to do the same thing on the other side.", 'start': 1769.345, 'duration': 2.543}, {'end': 1778.394, 'text': 'So minus 340 greater than minus 350.', 'start': 1771.928, 'duration': 6.466}, {'end': 1779.695, 'text': "And the top and bottom doesn't matter.", 'start': 1778.394, 'duration': 1.301}, {'end': 1784.84, 'text': "But in this case it's going to be paddle A, not paddle B.", 'start': 1780.375, 'duration': 4.465}, {'end': 1786.621, 'text': 'That would give you definitely some weird glitches.', 'start': 1784.84, 'duration': 1.781}, {'end': 1791.786, 'text': "And then same thing, we're going to reverse the ball.", 'start': 1790.405, 'duration': 1.381}, {'end': 1792.687, 'text': "So let's test it again.", 'start': 1791.806, 'duration': 0.881}, {'end': 1799.747, 'text': "Okay, so over here, we're using the up and down arrows.", 'start': 1797.506, 'duration': 2.241}], 'summary': 'Testing paddle a with arrow keys, encountering glitches.', 'duration': 30.402, 'max_score': 1769.345, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1769345.jpg'}, {'end': 1846.128, 'src': 'embed', 'start': 1820.638, 'weight': 3, 'content': [{'end': 1826.3, 'text': "After every little bit of code, I knew that the problem had to be in here somewhere, because that's the only thing I changed.", 'start': 1820.638, 'duration': 5.662}, {'end': 1832.663, 'text': "I can't emphasize that enough, because my students, like I said, they always want to type the whole thing in and then debug,", 'start': 1827.001, 'duration': 5.662}, {'end': 1833.843, 'text': 'which is never a good idea.', 'start': 1832.663, 'duration': 1.18}, {'end': 1838.245, 'text': "Okay, so let's test it one more time.", 'start': 1833.863, 'duration': 4.382}, {'end': 1840.126, 'text': 'So you can see this process.', 'start': 1839.165, 'duration': 0.961}, {'end': 1846.128, 'text': "We're iterating, we're testing, and just making sure everything is working as expected before we move on.", 'start': 1840.146, 'duration': 5.982}], 'summary': 'Emphasizing testing and iterative debugging to ensure code works as expected.', 'duration': 25.49, 'max_score': 1820.638, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1820638.jpg'}], 'start': 1454.516, 'title': 'Paddle and ball collision logic', 'summary': 'Explains the process of debugging and correcting the collision logic between the paddle and ball in a game, adjusting the x coordinates, testing the movement, and ensuring the ball behaves as intended, ultimately achieving the desired functionality.', 'chapters': [{'end': 1643.24, 'start': 1454.516, 'title': 'Paddle and ball collisions', 'summary': 'Explains how to make the ball collide with the paddles by comparing the x and y coordinates, setting conditions for collision, and handling the bounce, aiming to get the right paddle working first.', 'duration': 188.724, 'highlights': ['The chapter explains how to make the ball collide with the paddles by comparing the x and y coordinates, setting conditions for collision, and handling the bounce.', 'The chapter aims to get the right paddle working first before focusing on the left paddle.', "The chapter discusses setting specific conditions for collision, such as checking if the ball's x-coordinate is greater than 340 and the ball's y-coordinate is within a specific range of the paddle's y-coordinate."]}, {'end': 1840.126, 'start': 1644.14, 'title': 'Paddle and ball collision logic', 'summary': 'Demonstrates the process of debugging and correcting the collision logic between the paddle and ball in a game, adjusting the x coordinates, testing the movement, and ensuring the ball behaves as intended, ultimately achieving the desired functionality.', 'duration': 195.986, 'highlights': ['The chapter focuses on debugging and correcting the collision logic between the paddle and ball in a game to ensure desired functionality, emphasizing the process of testing and making incremental changes for resolution.', "Adjusting the x coordinates and implementing conditions for the ball's xCore to be less than 350 to position it within the middle of the paddle to reverse the direction, with a specific emphasis on ensuring the ball behaves correctly.", 'The demonstration highlights the importance of testing after every modification, emphasizing the process of incremental changes and debugging to identify and correct errors in the code.', 'The process of testing and debugging is underscored, advising against typing the entire code before debugging and instead advocating for making incremental changes and testing at each step for efficient error identification and resolution.']}], 'duration': 385.61, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1454516.jpg', 'highlights': ['The chapter explains how to make the ball collide with the paddles by comparing the x and y coordinates, setting conditions for collision, and handling the bounce.', 'The chapter focuses on debugging and correcting the collision logic between the paddle and ball in a game to ensure desired functionality, emphasizing the process of testing and making incremental changes for resolution.', "The chapter discusses setting specific conditions for collision, such as checking if the ball's x-coordinate is greater than 340 and the ball's y-coordinate is within a specific range of the paddle's y-coordinate.", 'The demonstration highlights the importance of testing after every modification, emphasizing the process of incremental changes and debugging to identify and correct errors in the code.', "Adjusting the x coordinates and implementing conditions for the ball's xCore to be less than 350 to position it within the middle of the paddle to reverse the direction, with a specific emphasis on ensuring the ball behaves correctly.", 'The chapter aims to get the right paddle working first before focusing on the left paddle.', 'The process of testing and debugging is underscored, advising against typing the entire code before debugging and instead advocating for making incremental changes and testing at each step for efficient error identification and resolution.']}, {'end': 2230.47, 'segs': [{'end': 1894.815, 'src': 'embed', 'start': 1865.963, 'weight': 1, 'content': [{'end': 1867.324, 'text': "it's doing everything it needs to do.", 'start': 1865.963, 'duration': 1.361}, {'end': 1871.306, 'text': "next we want to add a scoring system, so let's uh.", 'start': 1867.324, 'duration': 3.982}, {'end': 1872.987, 'text': 'go ahead and take a look at that uh.', 'start': 1871.306, 'duration': 1.681}, {'end': 1878.551, 'text': "so basically what we want to do is we want to draw the score on the screen and here's how we're gonna do that uh.", 'start': 1872.987, 'duration': 5.564}, {'end': 1881.407, 'text': 'in Python using the turtle module.', 'start': 1878.551, 'duration': 2.856}, {'end': 1884.349, 'text': "So what we're going to do is we're actually going to create a pen.", 'start': 1881.427, 'duration': 2.922}, {'end': 1888.851, 'text': "Okay, I just call it a pen, but it's actually just a turtle, just like the ball and like the paddle.", 'start': 1884.369, 'duration': 4.482}, {'end': 1894.815, 'text': 'But the turtle module gives these turtles, objects, a lot of different abilities.', 'start': 1889.172, 'duration': 5.643}], 'summary': "Adding a scoring system using python's turtle module for creating a pen and drawing the score on the screen.", 'duration': 28.852, 'max_score': 1865.963, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1865963.jpg'}, {'end': 2004.226, 'src': 'embed', 'start': 1974.795, 'weight': 2, 'content': [{'end': 1977.636, 'text': "So, that means it's 0 to 300 here.", 'start': 1974.795, 'duration': 2.841}, {'end': 1981.077, 'text': 'So, we want the score to be right around this part of the screen.', 'start': 1977.696, 'duration': 3.381}, {'end': 1985.358, 'text': 'And then it gets pretty easy at this point, is we use the write method.', 'start': 1982.257, 'duration': 3.101}, {'end': 1990.601, 'text': "So we want to write, and I'm going to write player A.", 'start': 1986.759, 'duration': 3.842}, {'end': 1992.601, 'text': 'And now when the game starts, the score of course is zero.', 'start': 1990.601, 'duration': 2}, {'end': 1997.824, 'text': 'Two spaces, player B, zero, comma.', 'start': 1993.182, 'duration': 4.642}, {'end': 2004.226, 'text': 'And then you want to align equals center, because that will center the text for us around that point.', 'start': 1997.884, 'duration': 6.342}], 'summary': 'Setting up score display for players a and b with initial score of 0.', 'duration': 29.431, 'max_score': 1974.795, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1974795.jpg'}, {'end': 2106.067, 'src': 'embed', 'start': 2070.452, 'weight': 0, 'content': [{'end': 2079.998, 'text': "it's going to be 0 and score B is going to be 0, now down here.", 'start': 2070.452, 'duration': 9.546}, {'end': 2088.194, 'text': 'Okay, so we get a score when the ball goes off the screen.', 'start': 2082.79, 'duration': 5.404}, {'end': 2090.396, 'text': "So here's the right side.", 'start': 2089.054, 'duration': 1.342}, {'end': 2097.221, 'text': 'So if the ball goes off the right side, think to yourself, who gets the score? Of course, that is gonna be player A.', 'start': 2090.416, 'duration': 6.805}, {'end': 2102.645, 'text': 'So what I can do is score A plus equals one.', 'start': 2097.221, 'duration': 5.424}, {'end': 2106.067, 'text': "That adds one to player A's score.", 'start': 2102.665, 'duration': 3.402}], 'summary': 'Player a scores 1 when ball goes off right side.', 'duration': 35.615, 'max_score': 2070.452, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w2070452.jpg'}, {'end': 2202.24, 'src': 'embed', 'start': 2171.016, 'weight': 3, 'content': [{'end': 2176.278, 'text': 'so we use the format method on our string and we want score A and score B.', 'start': 2171.016, 'duration': 5.262}, {'end': 2182.41, 'text': 'So what that does is it puts score A here and score B there.', 'start': 2177.668, 'duration': 4.742}, {'end': 2185.852, 'text': "So I'm going to again make sure I'm using spaces.", 'start': 2182.591, 'duration': 3.261}, {'end': 2191.415, 'text': "I'm going to copy that because I'm pretty sure this is correct.", 'start': 2187.773, 'duration': 3.642}, {'end': 2202.24, 'text': 'So basically every time I update the score I need to update the actual printed score on the screen or the displayed score I should say.', 'start': 2195.357, 'duration': 6.883}], 'summary': 'Using the format method to display score a and score b.', 'duration': 31.224, 'max_score': 2171.016, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w2171016.jpg'}], 'start': 1840.146, 'title': 'Adding scoring system to pong game', 'summary': 'Covers adding a scoring system to the pong game using the turtle module in python, creating a pen to display the scores, initializing score variables, updating scores when the ball goes off the screen, and correcting the display by clearing it before updating.', 'chapters': [{'end': 2230.47, 'start': 1840.146, 'title': 'Adding scoring system to pong game', 'summary': 'Covers adding a scoring system to the pong game using the turtle module in python, creating a pen to display the scores, initializing score variables, updating scores when the ball goes off the screen, and correcting the display by clearing it before updating.', 'duration': 390.324, 'highlights': ['Creating a pen to display scores using the turtle module in Python.', 'Initializing score variables for player A and player B to 0.', 'Updating scores when the ball goes off the screen and displaying them using the write method.', 'Correcting the display by clearing it before updating the scores.']}], 'duration': 390.324, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w1840146.jpg', 'highlights': ['Initializing score variables for player A and player B to 0.', 'Creating a pen to display scores using the turtle module in Python.', 'Updating scores when the ball goes off the screen and displaying them using the write method.', 'Correcting the display by clearing it before updating the scores.']}, {'end': 2639.662, 'segs': [{'end': 2309.779, 'src': 'embed', 'start': 2261.283, 'weight': 0, 'content': [{'end': 2262.383, 'text': 'Player B just got a point.', 'start': 2261.283, 'duration': 1.1}, {'end': 2265.424, 'text': 'And so on and so forth.', 'start': 2263.363, 'duration': 2.061}, {'end': 2269.854, 'text': "So, yeah, so basically we've got a pretty well-working game here.", 'start': 2266.428, 'duration': 3.426}, {'end': 2271.036, 'text': 'Again, the game never ends.', 'start': 2270.134, 'duration': 0.902}, {'end': 2276.064, 'text': 'You just go until, you know, until you give up and get bored, which is pretty easy with Pong.', 'start': 2271.056, 'duration': 5.008}, {'end': 2283.483, 'text': "I'm going to show you how to add a little bit of sound to your game.", 'start': 2280.202, 'duration': 3.281}, {'end': 2289.365, 'text': 'So just basically what you need to do to get started with that is you need to have a sound.', 'start': 2284.444, 'duration': 4.921}, {'end': 2291.026, 'text': 'You need to have a sound file.', 'start': 2289.805, 'duration': 1.221}, {'end': 2295.007, 'text': "And what I've done is I have downloaded this file from.", 'start': 2291.566, 'duration': 3.441}, {'end': 2305.075, 'text': "I forgot the site now, but it is bounce.wav and it's like kind of a classic old school bouncing sound.", 'start': 2297.108, 'duration': 7.967}, {'end': 2305.955, 'text': "You'll hear it in a minute.", 'start': 2305.095, 'duration': 0.86}, {'end': 2309.779, 'text': 'Now, Python is generally pretty cross-platform.', 'start': 2306.736, 'duration': 3.043}], 'summary': 'Python game has a well-working system; includes adding sound. game continues until giving up, with a classic bouncing sound file available.', 'duration': 48.496, 'max_score': 2261.283, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w2261283.jpg'}, {'end': 2356.353, 'src': 'embed', 'start': 2335.238, 'weight': 3, 'content': [{'end': 2344.864, 'text': 'So the first thing I got to point out is that the sound that I found bounce.wav and wav files generally are more compatible cross-platform compatibility.', 'start': 2335.238, 'duration': 9.626}, {'end': 2349.991, 'text': 'is in the exact same folder as my Python file.', 'start': 2346.71, 'duration': 3.281}, {'end': 2353.232, 'text': "So right now I'm on Pong 7, and Pong 7's in there.", 'start': 2350.411, 'duration': 2.821}, {'end': 2354.913, 'text': 'So they are in the same folder.', 'start': 2353.272, 'duration': 1.641}, {'end': 2356.353, 'text': "That's a really important point.", 'start': 2354.933, 'duration': 1.42}], 'summary': 'Wav files are more cross-platform compatible and should be in the same folder as the python file.', 'duration': 21.115, 'max_score': 2335.238, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w2335238.jpg'}, {'end': 2601.376, 'src': 'embed', 'start': 2568.496, 'weight': 4, 'content': [{'end': 2575.746, 'text': 'Basically, in Windows, instead of importing OS, you import WinSound, which is a little module that only exists on Windows.', 'start': 2568.496, 'duration': 7.25}, {'end': 2584.798, 'text': 'And then when you want to play your sound, instead of this OS.SystemStuff, you would type WinSound.', 'start': 2576.707, 'duration': 8.091}, {'end': 2591.092, 'text': 'dot, play sound again, pay attention to the capitalization.', 'start': 2586.63, 'duration': 4.462}, {'end': 2601.376, 'text': "okay, small w, capital, P, capital, S and in parentheses, so you don't need the ampersand here,", 'start': 2591.092, 'duration': 10.284}], 'summary': 'In windows, use winsound module to play sound, instead of os.systemstuff.', 'duration': 32.88, 'max_score': 2568.496, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w2568496.jpg'}], 'start': 2232.031, 'title': 'Sound in pong game', 'summary': 'Covers adding sound to a pong game using the turtle module, allowing continuous play, and earning points by player a and player b. it also explains implementing sound effects in a pong game using python on mac, with insights on cross-platform compatibility and instructions for linux and windows.', 'chapters': [{'end': 2283.483, 'start': 2232.031, 'title': 'Adding sound to pong game', 'summary': 'Covers adding sound to a pong game using the turtle module, with the game allowing continuous play and points being earned by player a and player b.', 'duration': 51.452, 'highlights': ['The game allows continuous play and does not have an end, making it easy for players to get bored.', 'Points are earned by Player A and Player B during the game.']}, {'end': 2639.662, 'start': 2284.444, 'title': 'Implementing sound in pong game', 'summary': 'Explains how to add sound effects to a pong game using python, demonstrating the process on a mac, with insights on cross-platform compatibility and instructions for linux and windows.', 'duration': 355.218, 'highlights': ['The process of adding sound effects to a Pong game is demonstrated on a Mac using Python, with insights on cross-platform compatibility and instructions for Linux and Windows.', "The sound file 'bounce.wav' is used for the demonstration, emphasizing its cross-platform compatibility and importance of placing it in the same folder as the Python file.", "Instructions for implementing sound effects on Linux involve using the 'APlay' command, while Windows requires importing the 'WinSound' module and using the 'play sound' function with specific parameters."]}], 'duration': 407.631, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/C6jJg9Zan7w/pics/C6jJg9Zan7w2232031.jpg', 'highlights': ['The game allows continuous play and does not have an end, making it easy for players to get bored.', 'Points are earned by Player A and Player B during the game.', 'The process of adding sound effects to a Pong game is demonstrated on a Mac using Python, with insights on cross-platform compatibility and instructions for Linux and Windows.', "The sound file 'bounce.wav' is used for the demonstration, emphasizing its cross-platform compatibility and importance of placing it in the same folder as the Python file.", "Instructions for implementing sound effects on Linux involve using the 'APlay' command, while Windows requires importing the 'WinSound' module and using the 'play sound' function with specific parameters."]}], 'highlights': ['The tutorial emphasizes building the game using Python 3 and the turtle module, which is simpler and built-in compared to Pygame, making it suitable for beginners.', 'The chapter covers building a classic Pong game using Python 3, focusing on the turtle module for basic graphics and creating a window with a title, background color, and size.', 'The Main Game Loop is crucial for game performance optimization, allowing manual screen updating to speed up games significantly.', 'The chapter covers setting up paddles and a ball, stretching the paddle width by five to make it 100 pixels tall and 20 pixels wide.', 'The chapter explains how to make the ball collide with the paddles by comparing the x and y coordinates, setting conditions for collision, and handling the bounce.', 'The tutorial explains the process of setting up keyboard bindings for moving the paddle up and down, using specific keys for each direction.', "The concept of separating the ball's movement into x and y components using dx and dy is introduced, with a suggested initial value of 2 pixels for each movement.", "The chapter discusses setting specific conditions for collision, such as checking if the ball's x-coordinate is greater than 340 and the ball's y-coordinate is within a specific range of the paddle's y-coordinate.", 'The process of testing and debugging is underscored, advising against typing the entire code before debugging and instead advocating for making incremental changes and testing at each step for efficient error identification and resolution.', 'Initializing score variables for player A and player B to 0.', 'The game allows continuous play and does not have an end, making it easy for players to get bored.', 'The process of adding sound effects to a Pong game is demonstrated on a Mac using Python, with insights on cross-platform compatibility and instructions for Linux and Windows.']}