 Okay, okay, let's start Good afternoon. Welcome and thank you for coming. I'm pleased to introduce the engineer Daniel Pope who talks about pale game zero No, ah, okay. Hi. I'm Dan I am a reliability engineer by day But for many years my hobby has been programming games. I remember my first computer was an Atari ST and I Had ST basic and stuff and I immediately put that to one side because it came with loads of games And so my my interest in programming came from my my love of games and I continued to Program games in my spare time Particularly during two weeks of the year which are Pi week so Pi week is a week-long games programming contest Where you are challenged to write a game from scratch in Python On a topic that is given to you at the moment the contest starts So you have exactly one week to write a game and then you have to upload it and I've taken part in Pi week about ten times, but I've won it twice so I That that kind of background Was particularly of interest to Nicholas when he set up the PyCon UK education track And he kept saying well Dan you have to kind of get involved with this because teachers we love this kind of stuff So About is it four years ago the first five years ago the the first PyCon UK education track rolled around and We were challenging we were putting into groups and challenged to groups where teachers met developers and challenged to come up with some course material that the teachers could teach And so I from from my Pi game or Pi week and Pi game background I dashed off the simplest possible Pi game program It's about sort of 20 lines to do import pi game in pi game in it while loop something you know, whatever and One of the teachers said no, that's that's too difficult that can't work in a classroom Because the amount of code that he would have to teach for a student to be to get something productive by the end of the lesson was too much so the the the best program was in the class the people with Who got it would race away and be bored and the people who didn't get it would not have got it by the end of the lesson so that problem sat around with me in in my brain for three or four years and then In 2014, I think the October 2014 Pi week I sat down to write a game and the theme was one room I thought I'm gonna write this in a kind of way that I would write it if I was Creating a framework for complete beginners to Pi game and then last year I Turned that into a library, which is Pi game zero So this is a library that takes all of the boilerplate out of Pi game Pi game is a library for Access to graphics and sound and input But wrapping that with a kind of thin Python layer that lets you Training wheels for Pi game as it were so you can get up speed faster The teachers can teach like a couple of lines at a time and make sure the class is caught up But then it is just Pi game underneath so you can throw away the the training wheels at some point and migrate to Pi game proper If you want, so I'm gonna show Pi game zero today I've written a blank file that's called demo dot Pi The secret of Pi game zero is that it doesn't run with the standard Python interpreter you run it with PGZ run So PGZ run is all their clever machinery a blank File is a valid Pi game zero program It creates a blank window, but you can quit it Which is great because you can't do that with a blank time by game. So that proves you've got things installed then you can say So two lines of code And I put a blue screen So Let's write a little game. I'm going to So that's a couple more lines, but that is using Pi game zero magic The sorry the this mouth refers to an image. So if I do I've got a directory called images And that's where my my image files are so I don't need to do any Fafting to load those path manipulation They are just as sort of available as as strings You can also this We can access them as objects in order to get the width and the height if you want But the actor there has a width and height. It's a Pi game rectangle, which is why I could position it by Mid-bottom. It's got all of the Pi game Attributes by left right X and Y So I'm going to have another thing. You're gonna be very topical. So I've got a pinch. Oh These were drawn an inkscape by the way and then exported as pings and Pi game can load Sorry, pi game zero can load pings or jpegs So whatever file format you could you should just be able to save something off the internet maybe and use it immediately in the game And then I draw a great function called update So a couple more lines so two lines at a time. That's what we're aiming for so if I say if keyboard left Shouldn't I should have chosen a word that's easier to spell And then I said these these actors are I'll just RET so I could do if So I Think that program is easy enough to grasp I think the by moving all of the complexity out of Out of the pi game program that you would write into pi game zero We've created something that is much simpler to get started on just at that that level where you're transitioning from something like Scratch so kids will do scratch up to the age of 10 9 Like subtle nods and then in the UK curriculum they have to transition to a textual programming language but scratch has the ability to create characters and move them around Out of the box so that stuff is very accessible for Python programming. I think we're in a situation where the out-of-the-box experience is Worse I think you if you if your basic programs are What is your name hello name That's a big gap from where you work just were in scratch to where you are in Python so pi game zero sort of fills that niche for getting up to speed You know Getting something graphical on the screen to keep kids engaged as they as their programming career continues This was written in Python 3 I think that's important as well so the background for Pi game and Python 3 is is sort of a bit incomplete Teachers told told me that they wanted just pi get a Python 3 stuff They wanted to be able to teach one language and so the Python 2 3 split was a big problem When this was written, and I think this is still the case. There is no official release of Pi game for Python 3 so a part of this was Actually finding ways to install pi game and Python 3 And that is all in the documentation so There are ways of doing it it works But pi game is catching up actually so there are now binary wheels on pi pi, but I think off of the Pre-release tags, so you have to say PIP Minus minus pre or something, but you can install pi game And Okay, so I was going to show you Some of the other things that pi games era can do so Draw an update or your basic bread and butter for creating games for animation So draw will draw the screen that will be called whenever pi games area wants to update Draw the screen refresh the screen update is called 60 times a second anyway so if you don't define update you can create games that are Click-driven. I'll show you the click API. So Right, so all I needed to do was create a function called on on mouse down and Pi game zero will call that function If I wanted to know what button I what button was clicked I could go Do anything with a button so you see I've got Pi game zero is adapting to the the callback that I define and I Was demoing this to I was sharing this around the internet with some of the teachers who've been involved in the Python UK education track and Dave Had said it doesn't work. It's just not working. He'd written that and I was dismayed that the very first experience he had with this this tool was Something that just didn't work and didn't give me any feedback on why so If you misspell a function It's got a spell checker and will tell you that you might have misspelled things I think that's the the kind of philosophy of pi game zero is that we've done a lot of work actually in sort of catching Errors re-raising them with better messages because that kind of feedback about If you if something breaks and it doesn't give you any information as to why That is a An obstacle to Continuing your your learning so Every time we could take something That the the underlying pi game was doing and make it more explicit. We've done that I Think I will stop there and invite questions because the questions have been very good in the previous times I've taken this talk and I'd rather sort of I Want to know what you want to out of this this tool, so any questions? Do you want a Yeah, so I just wanted to ask if there is like an included way like For easy publishing of your game especially for kids. Yeah, so because like they won't go into different No, but Pi game zero was created with a an understanding of the kind of portability problems that show up on When you when you distribute games so having done pie week a lot of times every time you use open gel for example It will work perfectly on all of the machines that you develop on and then somebody will run it and there's a driver problem So pi game is ideal for the distribution of games because it just works if it's there It just works. It's CPU rendering which is slow, but it's Incredibly reliable also pi games area will catch problems with file names for example, so if I if I rename Then it will give me an error that my game could possibly not be exchanged with somebody with a different file system That was case-intensive Case yeah case-intensive so that kind of problem is To the best of my ability sort of dealt with by by pay game zero the actual sort of packaging of games Distributing them. I think is a is a future problem, but something I think we would like to solve Why sorry? Well, yeah, it's a problem for everybody. Yeah Yes, so packaging yes and distribution Yes, I think that comes later. I think that's something that we should we should build the Pi game zero Distribution is just like a directory really so if you have pi game zero installed zipping up a directory and just sharing the Images directory and the sounds directory and the script And generally it's assumed there is one script. This is for For programs that are simple enough to be in one module Then that can be run on any computer with pi game zero There is another project I've got internet I can I've been working on something called the edgy bundle Which is an attempt to provide a redistributable sort of bundle for Python for education that has pi game zero pi game Pi Qt Nicholas's mu editor available so I think By pursuing all of these avenues we can make games easier for and Python easier for kids to to use at school run at home Yeah What about networking because in in games it's also interesting if you're I don't know you're a colleague from school can play Right your latest game. Um, yes, so Nicholas is putting his hand up So there's network zero for that we're gonna answer more for you So inspired by Dan's awesome work with pi game zero As I mentioned in my keynote other people have been doing something something zero libraries Following the same philosophy that Dan has And Tim Golden who's Python core developer based in London has created network zero He tried out at the London Python code ojo and we had an awful lot of fun Breaking it the important thing is is that Tim has also been trying it out with teachers as well and getting their feedback And just to echo what Dan was saying I'm getting teachers involved in this is essential because they are the experts in dealing with children as developers we we can think Kids might want to do but it's teachers who actually deal with them every day, but there's network zero I can't see why network zero couldn't work with pi game zero and you're right and Ben Nuttle of the Raspberry Pi Foundation created GPIO zero and also the hashtag zero all the things so what you need to do is create a Pi game zero project that uses GPIO zero on a pi zero Raspberry Pi zero with network zero as well And then you've zeroed all the things and you can legitimately use that hashtag. Hi so we talked yesterday evening and I just want to Repeat this suggestion you can actually bundle this thing with the pi two extra to have a single executable file that doesn't need installation I think that would be a good thing to have but I have not written that yet Yeah, of course, but I'm just saying that maybe that's a good thing to look into and Also, you could run the zip files directly, right? Yes, like zip app. Yeah Yeah, so I I guess as you suggest features I should mention that this is on bit bucket G zero and so pull requests are Accepted and this is a community You pointing Okay thumbs up right. Okay. Yes it's community project and and and it sort of relies on the feed, but I'm not a teacher I Going on feedback from teachers, but I need the feedback of people who have tried teaching kids with this to improve it And any time that you see an error message that is opaque Or something doesn't work And doesn't give a trace back or doesn't give any indication as to why it's not working that could be considered a bug So, please report it if nothing else Okay So since arriving in Bilbao, where am I? Sorry? Hello? Right right at the back. Okay, we're underneath the light since arriving at Bilbao I've discovered that my Spanish is exactly zero and a lot of Spanish people's English is also zero What options are there for internationalizing so that an 11 year old Spanish kid? For example doesn't have to learn English to do on mouse down, etc um Yeah, I think it's probably Difficult to conceive of a way that you could internationalize this without Making incompatibility problems. I think also that English is the language of programming and You know the Python libraries are And the and the Python keywords are English On the other hand, I think it's very reasonable that the documentation should be translated So if anybody would like to contribute a translation for the documentation Or I'll contribute any kind of tutorial or blog post that would be appreciated Okay, the last question Thanks very much. Um, this looks like it would be quite a nice way of building Not just games, but generic interfaces for interaction with all kinds of things How suited is it to playing the role of a kind of generic graphical interface builder? You can write Full graphical interfaces in Pygame and people have done it But I think at that point you're probably not you're probably best if you you want to attack that kind of problem using Pygame itself and there are libraries that do sort of the GUI widgets for A Bedding in a Pygame game that sort of mimic the the kind of platform widgets But I think it's not That that kind of programming becomes more complicated than I think Pygame zero is targeting So I think if you want to do that that's and I certainly could see that if Pygame zero was Was to include some GUI tools To share games for example To like to bundle them up to sort of enter some some details and an icon or something Then that could be done with a GUI that was written in in Pygame, but may not use Pygame zero to do it Okay, okay. Thank you Daniel for your interest companies and thank you very much