Pong, Python & Pygame 10 - Computerphile

  Рет қаралды 37,856

Computerphile

Computerphile

Күн бұрын

Squash-Pong needs a ball and a paddle - Dr Isaac Triguero continues the PyGame mini-series.
Watch part 11 before it goes live: • Pong, Python & PyGame ...
Thorsten & Isaac's Python programming book: bit.ly/2p3r5IT
/ computerphile
/ computer_phile
This video was filmed by Sean Riley and Isaac Triguero and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

Пікірлер: 100
@dcc1165
@dcc1165 4 жыл бұрын
Yeah, at risk of embarrassing myself, I saw the title and thought "What happened to the other 9 episodes??" So much for 40 years of computer science experience...lol
@Acceleronics
@Acceleronics 4 жыл бұрын
More, please! These are very interesting videos.
@Siemius
@Siemius 4 жыл бұрын
You know, youre dealing with real nerds, when they count the episodes in binary.
@benmills9638
@benmills9638 4 жыл бұрын
Siem Schutte are you counted as a nerd because you knew?
@JNCressey
@JNCressey 4 жыл бұрын
I've got a feeling episode 5 will be rather basic.
@dirk9787
@dirk9787 4 жыл бұрын
Haha, I thought I missed quite a few episodes.
@Siemius
@Siemius 4 жыл бұрын
@@benmills9638 probably yes
@coppersandwich
@coppersandwich 4 жыл бұрын
Love watching coding videos on your channel and studying coding logic. Thank you @Isaac Triguero!
@TimL_
@TimL_ 4 жыл бұрын
Love the series, keep it up! Also, thanks for using light mode!
@napicella
@napicella 4 жыл бұрын
Very cool series, thank you - I'd love to see more :)
@PR0MINENCE
@PR0MINENCE 4 жыл бұрын
We need more!
@uncle-ff7jq
@uncle-ff7jq 2 жыл бұрын
Fire content. Love the personality and enthusiasm for the project. Great description of the code. Excited to learn how to implement.
@turpialito
@turpialito 4 жыл бұрын
Thanks, Computerphile. Brill, as always! I've done Pong in Java before and it's great to see it done in Python.
@JNCressey
@JNCressey 4 жыл бұрын
wow. episode 10 already? I must have missed a few.
@bbq1423
@bbq1423 4 жыл бұрын
There are 10 kinds of people in the world: the ones who know binary and the ones that don’t.
@johngalmann9579
@johngalmann9579 4 жыл бұрын
There are 10 kinds of people in this world: those who understand binary, those who don't, and those who didn't expect this joke to be in ternary.
@yuvaltasher2054
@yuvaltasher2054 4 жыл бұрын
@@bbq1423 r/woooosh
@markusTegelane
@markusTegelane 4 жыл бұрын
10 people explained the title
@lgib3121
@lgib3121 4 жыл бұрын
@@yuvaltasher2054 shup reddit weeb
@ManyManyPandas
@ManyManyPandas 4 жыл бұрын
Ha! I just discovered this series of videos! I actually created this EXACT thing (of course, with various differences in how systems work) with a partner for our final project in 9th-grade computer science. Watching this, I can see the various mistakes that my partner and I made. Specifically regarding the ball, we defined four possible directions UpRight, UpLeft, DNRight, DNLeft. Our mistake here is only allowing these diagonal directions in our physics engine, as opposed to supporting dynamic velocities like this class did. I think it's really cool to see what mistakes I made, as well as how to improve on it, were I to rewrite it.
@minijimi
@minijimi 4 жыл бұрын
Keep the series going...
@felixmuhlenberend7919
@felixmuhlenberend7919 4 жыл бұрын
Fantastic Video! This is a really fun series. A Nit-Picky / interesting detail: you actually only need to mark a variable as global when you change the value of the variable itself (e.g. assign a new screen to it) not if you just modify the object :D.
@alicebingham9796
@alicebingham9796 4 жыл бұрын
very excited
@barrotem5627
@barrotem5627 4 жыл бұрын
AMAZING ! As a Java and Python ambitious programmer, I love those videos ! I'm waiting to have free time to implement those ideas. Maybe make a similar yame
@rahulr6723
@rahulr6723 4 жыл бұрын
Loved the title ♥
@Yupppi
@Yupppi 3 жыл бұрын
All the self in python is maddening. What would happen if you have a function inside the class for something and you don't use function(self, parameters)? What if you put something else to self? Does it go crazy? The first hit in the squash court was so powerful that it went through the back wall.
@ranapazza1
@ranapazza1 4 жыл бұрын
Thorsten and Isaac have mostly written the book together, but they led different chapters; you are challenged to guess who wrote what... So finally I discover who write the wonderful Squash-Pong game :D Thanks Prof. Isaac
@audiohutch
@audiohutch 4 жыл бұрын
I just made Brick Breaker in Java on my channel :) I also made the classic Tetris game which everyone loves to build in java since it utilizes the object-oriented style.
@peymanx
@peymanx 4 жыл бұрын
amazing job
@laxmikarki9615
@laxmikarki9615 4 жыл бұрын
Of course we want more. And fast!
@rajeshprajapati1851
@rajeshprajapati1851 4 жыл бұрын
Very Well !!! Continue
@TheeBuddylee
@TheeBuddylee 4 жыл бұрын
Will this be on github once complete?
@Oladipupo_
@Oladipupo_ 3 жыл бұрын
Did you end up finding it?
@user-zu6ts5fb6g
@user-zu6ts5fb6g 4 жыл бұрын
Love the alliteration in the title.
@alexismandelias
@alexismandelias 4 жыл бұрын
Lovely tutorial, the best way to get into pygame
@black_platypus
@black_platypus 4 жыл бұрын
Heh, I thought I missed 9 episodes. There are 10 types of people: Those who know binary and those who don't. Although: The max index of types of people according to whether they understand zero-based indexing is 1. Damn, I tried to make a corrected version of what I'd written earlier ("1 type of people" - sounds better but is wrong), but I butchered it, it's so inelegant. Can somebody make this work in a less clunky way?
@koppadasao
@koppadasao 4 жыл бұрын
Krakout!
@Hatchet2k4
@Hatchet2k4 4 жыл бұрын
I twitched a little when update and show were mixed.. I always keep my update logic separate from drawing..
@Ghost-Raccoon
@Ghost-Raccoon 4 жыл бұрын
But aren't you always drawing after updating?
@marcjall
@marcjall 4 жыл бұрын
Interesting way to continue the order of the video.
@DenisovichDev
@DenisovichDev 4 жыл бұрын
We want more! #WeWantMore
@justpaulo
@justpaulo 4 жыл бұрын
Yes! 1st game I wrote in Python.
@Buoy2
@Buoy2 4 жыл бұрын
5:45 no
@alex-bj3lh
@alex-bj3lh 4 жыл бұрын
why?
@greg1695
@greg1695 4 жыл бұрын
​@@alex-bj3lh It's a long-ish explanation, but basically the global statement isn't needed in this case. (Note he doesn't use it when accessing any other global variables.)
@samberg3864
@samberg3864 4 жыл бұрын
@@alex-bj3lh He doesn't need the global statement because because he's not assigning to or changing anything about the screen. Let's say you were making a game with multiple different screens somehow. If he were to assign screen to one of the other screens(I'm pretty sure that's not how you would actually do this in pygame, in reality you would just redraw everything to the same screen variable, but this is just an example about global), then he would get an error about local variable used before assignment or something like that (if he left out global), and global would solve that. There you go, an explanation that it both terrible, and only like at best 70% accurate.
@alex-bj3lh
@alex-bj3lh 4 жыл бұрын
@@samberg3864 I see
@Buoy2
@Buoy2 4 жыл бұрын
alex The only case where you need to use the global keyword is if you are assigning a new value to the name using the =-operator. In that case you must use the keyword to specify that you want to change the value assigned to the global name, rather than creating a new name in the local scope. In all other cases (including modifications, like screen.foo = 1), the meaning is unambiguous and you don't need to do anything. For example, in this case, Python would see that the name "screen" does not exist in the local scope, and therefore has to be in the outer (global) scope.
@stupossibleify
@stupossibleify 3 жыл бұрын
Wish you'd linked to the previous epidies, as I've been recommended only to this Part
@MiteshBhanushali08
@MiteshBhanushali08 4 жыл бұрын
Really nice video and would like to see more in detail
@jokkerBANG
@jokkerBANG 4 жыл бұрын
I loved this video. I’ve never used pygame before but this looks easy. I can’t wait to try
@EsronDtamar
@EsronDtamar 4 жыл бұрын
You are going to make an AI to we play against? This series is awesome, keep going.
@isaactriguero3155
@isaactriguero3155 4 жыл бұрын
Yes, coming up soon :-)
@w3w3w3
@w3w3w3 4 жыл бұрын
@@isaactriguero3155 are you the person in the video? if so... hai! :) I enjoy the video haha, nice :)
@isaactriguero3155
@isaactriguero3155 4 жыл бұрын
w3w3w3 heh, yes it is me :). Glad to hear you enjoy it!
@w3w3w3
@w3w3w3 4 жыл бұрын
@@isaactriguero3155 Ah awsome! Intersting little project. Please do more haha :)
@Raghav1205
@Raghav1205 4 жыл бұрын
Yes more
@anusha8085
@anusha8085 4 жыл бұрын
When is Part 11 going to come out? I just can't wait for it anymore! I love this series
@Computerphile
@Computerphile 4 жыл бұрын
Don't, ahem, look in this video's description....
@anusha8085
@anusha8085 4 жыл бұрын
@@Computerphile Oh! I didn't find it when I searched for it, it never occurred that you'd update the description and put the link there. Thank you so much!
@II_xD_II
@II_xD_II 4 жыл бұрын
finally saw the implementation of pass
@mantictac
@mantictac 4 жыл бұрын
You think 10 episodes are a lot? Just wait until 100.
@farenhite4329
@farenhite4329 4 жыл бұрын
There are 10 types of people, those who think the title is normal, and those that wonder why he skipped 9 episodes.
@elissonsilvasantos9716
@elissonsilvasantos9716 4 жыл бұрын
I was expecting 2, but in truth it is in the binary form, very enteristing
@yearswriter
@yearswriter 4 жыл бұрын
Wait, part 10 0_o Last one I saw in my subscription was number 2
@yearswriter
@yearswriter 4 жыл бұрын
Nvm I got it it is 00 01 10 11 100 101 110 111
@omthakkar87
@omthakkar87 4 жыл бұрын
Binary episode number 🤩🤩🤩
@danielrdzulloa3478
@danielrdzulloa3478 4 жыл бұрын
Los títulos de esta serie de PONG están en binario 🤓
@hikaruyoroi
@hikaruyoroi 4 жыл бұрын
Should prefix with 0b
@cinnamonsquash
@cinnamonsquash 3 жыл бұрын
He looks like Lorne malvo from Fargo series.
@chicodavid1211
@chicodavid1211 4 жыл бұрын
I love this! Please release the code once done. I’d love to challenge myself by attempting this. (Copy pasta)
@Computerphile
@Computerphile 4 жыл бұрын
You'll definitely want to watch to the end of episode 11 :) -Sean
@rewrose2838
@rewrose2838 4 жыл бұрын
So ,reupload?
@lucrainville4372
@lucrainville4372 4 жыл бұрын
Episode 10? Clearly the bell is broken :P
@WojciechKuakowski
@WojciechKuakowski 4 жыл бұрын
10 is 2 in binary :D
@rowan2231
@rowan2231 4 жыл бұрын
how are there 2k views on a 30 second old video
@Siemius
@Siemius 4 жыл бұрын
Look in the desc. You can Preview the next episode.
@rowan2231
@rowan2231 4 жыл бұрын
@@Siemius ah
@realeques
@realeques 4 жыл бұрын
took me a sec to get the binaric counting lol
@salamona03
@salamona03 4 жыл бұрын
import pygame as ga #------------variabler------------ BRED = 1200 HÖJD = 600 tjocklek = 20 framfärg = ga.Color("green") bakfärg = ga.Color("black") HASTIGHET = 1 #----------klasser----------- class Boll: RADIE = 10 def __init__(self,x,y,vx,vy): self.x = x self.y = y self.vx = vx self.vy = vy def visa_boll(self, färg): ga.draw.circle(yta, färg, (self.x, self.y), self.RADIE) def upp_pos(self): nyx = self.x+self.vx nyy = self.y+self.vy if nyx > tjocklek + self.RADIE: self.vx = -self.vx elif nyy < tjocklek + self.RADIE or nyy > HÖJD-tjocklek-self.RADIE: self.vy = -self.vy else: self.visa_boll(bakfärg) self.x = self.x+self.vx self.y = self.y+self.vy self.visa_boll(framfärg) class Paddle: pass #-----------skapa_objekt----------------- lekboll = Boll(BRED-Boll.RADIE,HÖJD//2,-HASTIGHET,-HASTIGHET) #-----------start------------------------ ga.init() yta = ga.display.set_mode((BRED, HÖJD)) ga.draw.rect(yta, framfärg, ga.Rect((0, 0), (BRED, tjocklek))) ga.draw.rect(yta, framfärg, ga.Rect((0, 0), (tjocklek, HÖJD))) ga.draw.rect(yta, framfärg, ga.Rect((0, HÖJD - tjocklek), (BRED, tjocklek))) while True: avsluta = ga.event.poll() if avsluta.type == ga.QUIT: break lekboll.upp_pos() ga.display.flip() ga.quit() #For some reason I can't get the ball to show upp
@absolutechaos6308
@absolutechaos6308 4 жыл бұрын
Hey! You have a problem with your "if" condition in your if-elif-else statement. Try making the '>' a '
@salamona03
@salamona03 4 жыл бұрын
@@absolutechaos6308 Thank you so much !!!
@davidmurphy563
@davidmurphy563 4 жыл бұрын
Global variables.. Tut, tut, tut.
@framegrace1
@framegrace1 4 жыл бұрын
Didn't knew python was not OO from the origin and still uses the "self" arg trick. Wow.
@RockRespawn
@RockRespawn 4 жыл бұрын
Yaay im early :D
@GuilhermeDiGiorgi
@GuilhermeDiGiorgi 4 жыл бұрын
0 -> 1 -> 10 haha binary
@charlescox290
@charlescox290 4 жыл бұрын
A shame no one actually designs thier software before they start coding anymore. It comes out with fewer unnecessary appendages and catches things like, "oh, I need some velocities", ahead of time so you don't go back and forth between class and functions so much.
@isaactriguero3155
@isaactriguero3155 4 жыл бұрын
Agreed, but in this case, I did it on purpose. I wanted to show the idea of velocity later on, when we were looking at how to make the ball draws.
@olijon7300
@olijon7300 4 жыл бұрын
This code is horrible; global values, unnecessary functions and variables, bad syntax and poor use of the library
@martinder3199
@martinder3199 4 жыл бұрын
I am a beginner and it absolutely makes no sense. Why do we need to declare bgColor and gfColor as global but then can use BORDER and HEIGHT just as is within def update. Also, mixing of COLOR and colour is a hoorrrible naming scheme...
@tooru
@tooru 4 жыл бұрын
can you hire someone who actually knows what they're doing?
@SwordQuake2
@SwordQuake2 4 жыл бұрын
Your code is bad and you should feel bad. This is horrendous.
Pong, Python & Pygame 00 - Computerphile
15:59
Computerphile
Рет қаралды 90 М.
Rust and RAII Memory Management - Computerphile
24:22
Computerphile
Рет қаралды 217 М.
터키아이스크림🇹🇷🍦Turkish ice cream #funny #shorts
00:26
Byungari 병아리언니
Рет қаралды 26 МЛН
Василиса наняла личного массажиста 😂 #shorts
00:22
Денис Кукояка
Рет қаралды 9 МЛН
TCP Meltdown - Computerphile
14:52
Computerphile
Рет қаралды 219 М.
Slopes of Machine Learning - Computerphile
18:45
Computerphile
Рет қаралды 71 М.
Dealing With Big Data - Computerphile
16:16
Computerphile
Рет қаралды 75 М.
Vintage Chemistry Computer Game - Periodic Table of Videos
9:03
Periodic Videos
Рет қаралды 141 М.
Python Sudoku Solver - Computerphile
10:53
Computerphile
Рет қаралды 1,1 МЛН
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Popular Technologies that Won't be Around Much Longer...
14:36
Sideprojects
Рет қаралды 147 М.
What NOT to do: Self Modifying Code - Computerphile
11:34
Computerphile
Рет қаралды 183 М.