Learn Python Skills While Creating Games | Real Python Podcast #2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to the real Python podcast this is episode 2 and my name is Christopher Bailey your host this week I talked to John Fincher one of the author's here at real Python we discuss a couple articles he's written recently for the site on PI game and arcade and how writing games can help you develop your Python skills so let's get started [Music] the real Python podcast is a weekly conversation about using Python in the real world interviews with experts in the community and discussions about the topics articles and courses found at real Python comm after the podcast join us and learn real-world Python skills with a community of experts at real Python comm hey Jon welcome to the podcast Hey how you doing good so why don't you give us a little bit of your programming background sure I actually learned a code back in high school I was lucky enough this is back in the dating myself here back in the early 1980s and there was a programming class I remember having some of the high school kids come to the junior high to show off these new Apple 2 computers that they had yeah and I was in I was enamored with with all the graphics and all the cool stuff that they could do on them and so I thought hey I got to learn how to how to do this stuff and so got into a programming class in high school was playing video games you know old style you know pixelated video games snake bite and Bomberman and you know loadrunner yeah Llodra oh I love loadrunner yeah you know we we played all these games I'm like I gotta learn how to write these games got further and further into it and as I went along I discovered that hey you know what operating systems and databases are really really cool because I also I like math I was you know really big into math and kind of joining the two of them I remember my math teacher she made some offhand comment about some graphing software that we were using how they were graphing the equations and how it worked and it was just a throwaway comment on her part but I sat there and said she said like how you know it's some difficult way that they're using to graph these things and I sat there and looked at and said how hard can it be and that was pretty much it from there you're hooked huh yeah I definitely hooked went to college got my degree in college worked at a couple little places before you know doing database programming and such before I got hired on Microsoft and I did I'd been doing database programming and they were just coming out this was 1995 I got hired a couple weeks after Windows 95 launched Wow and office 95 to come out and they were looking for support people to help support all their new offerings for office so I wound up being a support person for Access 95 because I'd been doing you know debates and access programming and in my previous life that turned into doing support for the operating system which turned into doing support for this thing called Windows Embedded which was a scaled-down embedded version of Windows and that led me to you know a 20 some-odd year career at Microsoft well and I pause you there for a second sure what would it be embedded into Windows Embedded would go into things like cash registers they would go into things like slot machines video slot machines used him a lot oh okay they had that C II version for a little while Windows CE II that was like an a Dreamcast right right yeah so when dos EE was its own little operating system that turned into Windows Mobile that you know eventually became Windows Phone at some point yeah okay windows and Windows Embedded started big it started with Windows NT and tried to make it as small as it could and then Windows XP embedded you know and so that went into dedicated devices that could handle something as big as NT more as big as XP okay but in it in a dedicated way and so from there I was doing servicing work for it and that led me into what was then called Windows se and I started doing servicing for the operating system basically the reason why if you have a Windows machine that you have to reboot it once a month yeah because of security updates that was us okay we're the reason we were doing security updates and other updates for it and I'm about four or five years ago I learned about this group called teals which would take computer professionals from industry and put them into schools to help teach kids computer science teaching programming and such and so the schools wanted to have a computer science program but they didn't have teachers who knew computer science okay so we came in we got a couple weeks of here's how you teach and then got put into classrooms to help teach kids and I found I loved doing that I absolutely loved it so after doing that volunteering for a couple years and just growing disillusioned with what I was doing at Microsoft I left and started teaching I'd been teaching in high schools for a while that's actually where I learned Python that's we were teaching Python I didn't know it so I figured I better learn Python if I'm gonna teach this stuff yeah so cool and then for the past year I've been semi-retired we moved from the Seattle area moved to Illinois there's not a lot of teaching opportunities around here so I've been I've been sitting at home writing a lot just trying to keep my keep my creative juices flowing sure know I can understand that and that's how you kind of got wired into the real Python I guess yeah yeah I started I was still doing volunteer teaching when Dan put out a call he said he wanted writers and I thought hey I could write this stuff why not I started that was about two years ago I've written I know seven or eight articles so far and I love doing that I love doing the writing I love doing the research that goes into it all the learning the new stuff because you know I'm writing about some stuff that I I know a little bit about but not a lot so I need to get up to speed really quickly and I really enjoy doing that cool it sounds like you've been into games your whole career early on and then now you're kind of getting into it with again with all your writing yeah I started like you know like I said I wanted to learn how to write games found out that it's you know they're they're really tough they're they're not easy things to learn to do I've started with games way back in the way back but didn't do much with it okay a couple years ago when I started teaching one of the things that we did with the kids when we were teaching them how to how to write code because they don't want to learn machine learning they don't that's not interesting to them what's interesting to them is let's make these really cool goofy little games yes he's moving around on the screen yeah stuff they can control share with their friends yeah exactly you know so we started working with them with scratch and then moved to Python that's when okay so how do you do all this stuff in in Python how do you how do you make these things move how do you know scratch and snap kind of block languages have got a lot of that stuff built in Python doesn't so we had to figure out how do you make sprites how do you make a move how do you move them around on the screen how do you keep score how do you handle collisions things like that so it kind of brought it all back to me and I decided hey I really like doing this let me see I've got a couple of game ideas in mind let me see what I can do with those so do you think that game programming is a good way for someone to learn programming in general yeah I do a lot of the basic ideas of computer science come into it in computer programming you know you need to have loops you know in order to keep the game going you need to have conditional so you can tell you know when you know when a game is over when you've collected a coin or when you've hit a bad guy or when you've fallen off the edge of the edge of the world you know you need to know how to do how to do things repeat them over and over again so that leads you into okay maybe I write a function to do this right I want to have different kinds of enemies maybe one of them flies one of them walks but other than that they're both the same kind of thing so okay now we start talking about classes and objects and so it can lead you into object-oriented coding yeah so a lot of the basics are there and you wind up learning a lot of the stuff with without even knowing that you're doing it you just kind of fall into it because oh I wanted to make my sprite guy I wanted to make him run so I needed to have this little loop that would animate the sprite all of a sudden you now you know how a loop works so yeah so I was thinking that too when I was getting into converting your article on my game and I said that would be a good course to recreate you know as a video lesson and I really found it fascinating how much you practice all of these game techniques the especially object-oriented stuff as a person writing it think to yourself okay well I don't want to have to rewrite all this code and I want to be efficient and like you said like there can be two different types of enemies they're both enemies they might have similar you know attributes like health or something like that but then they might vary from there and then that you go into like okay this one has flying characteristics and this one has ground-based characteristics or what have you and and yeah it's just such a great way to really practice all of those techniques you're always wanting to make it more efficient because you want the game to be efficient also you know which is right which is a big part of it right and even in that game you know you've got the the enemies the one that's in the the PI game article you've got the enemies that are flying at you and you've got clouds as well in the clouds fly too right now it's not just you can make a class out of out of just enemies but enemies in clouds fly that's their commonality so it gets you to think in in different terms kind of outside the box that ya the clouds are just background they don't really interact with anything but they really behave just like those flying missiles do they you know they travel from left to right when they're off screen you need to get rid of them so maybe there's a flying thing class and you just need to differentiate between what's the thing that I can hit the clouds and what's the thing that I can't hit the missiles so it really gets you to kind of think outside the box which is 90% I think of programming it's not the language it's the how do you think of the problem how do you think through the problem right and one of things that you mentioned you have this background and data it's odd to think about it but games also have data structures oh yeah I have a another article coming out it's it's waiting on tech review at this point on writing platformer games okay so there's the arcade article that just came out and then it's okay let's expand on that how do you make a platformer so it would be an example of platformer somebody's not familiar something like a Super Mario Brothers okay even loadrunner loadrunner could be a platformer it's it's you have a character you have a number of platforms on which they can run there's usually enemies that are chasing you you've got ways to get between platforms and ways to hopefully defeat or avoid enemies yeah okay sometimes they scroll sometimes they're you know they're side scrollers is another term for them trying to to write this there's a number of different ways that you can that you can code up you know the data that makes up the the actual world in which you are and what you're interacting you know you can either write it in Python code and just straight code okay I want you know this tile here I want this kind of thing to be a wall I want this thing to be a floor okay you know I want a floating platform or there are tools that you can use that can define the world for you and then you save that off as data it would create like a level would be a set of maps of repeating data exactly you'd have you'd have the map saved off as data and then you just read it all in how do you create those Maps how do you read all that stuff in a lot of it is a lot of the good frameworks arcade actually has a very good set up for that where you can use a tool called tiled okay which is a map editor org and you can define your world using tiled and then arcade can read that data in and build the world for you and then you can just start interacting but there are other things like okay where are where the enemy is located how do I put an enemy in place how do i how do I make my platforms move okay you know there-there's different different aspects there so maybe if you want to place your enemies you might be able you might do that in code or you might have another data file that says okay for this level here's where all my enemies are located and so now you've got to be able to read in data you got to be able to write data out if you want to save a game you need to be able to write things out and read them back in again right kind of like the concept of state like exactly you know if somebody were to want to jump back into the game and it's not like a a simple arcade game where you want it to remember that where they were and continue on from there you need to have a system in place for that exactly if you want to have a save point in your game you know you get to the middle of it you want to be able to say okay you've made progress to here now you can you know you can save it at this point if you wanted to to have a save point or you know something where you know you get past a certain point and if you if your character dies after that instead of respawning at the very beginning you respawn there in the middle okay you need to be able to save that state off somewhere so how do you do that so these are some of the problems that you wind up thinking through and how do you save that in an efficient way that makes sense that you can then get back to fairly quickly some of the sounds kind of overwhelming and one of the things that I liked in your article on my game was this idea of setting limits initially when you're creating this game the sort of idea maybe what doesn't my game do initially yeah yeah can you expand on that yeah this is great Raymond Chen is he's Microsoft employees and I was software engineer principle level maybe he's he's been at Microsoft he's forgotten more about the Microsoft interface programming the most people know sure I've had the privilege of working with him on a project before and he has a blog called the old new thing way back I don't know it was 2004 he had written a blog article and one of the things that he had was you don't know what you do until you know what you don't do and this it's kind of along the lines of you know if everything is priority one nothing is priority one you have to limit yourself as to what it is that your games going to do and maybe the first iteration of the game is very simple it's it's very basic it's let me just see if I can get this this jet to move around the screen and not fly off the screen and that could be the first step and then you start to add in okay let's let's add in the missiles how do I make them come along right you'll notice the game doesn't have any kind of way to shoot that could be an interesting addition how do you make it shoot you know maybe there are different kinds of power-ups that that come along that'd give you invulnerability or that would give you you know an extra life or these are all things that you can add later there's another great saying that I like which is don't compare your chapter one to someone else's chapter 20 sure my first games there they're bad they're they're not that great these games that I've been working on I had the benefit of when I wrote the initial Pi game article it was actually a rewrite of a previous article so there was a game there all I had to do was was look at the game make sure that it still worked make sure I understood it and then add to it anything that I wanted to and I used that same game for the arcade article so now it was a matter of okay there's a set game that I know and I understand how do you make it work in arcade okay so the next one the platformer was okay I understand arcade how do I do something brand new because I'd never done a platformer before I had no idea what to do so I had to learn how to do a platformer and that's where this this next article is coming from is me learning how to write a platformer and hopefully write bread a decent platformer is gonna compete with Mario no but it competes it competes very well against the the previous shooter game that I did because it's it's much more complicated it's much more complex and I'm building on my skills and that's that's what all these things are they just keep building on your skills your first couple of games that they'll be okay but they're not going to be you know they're not gonna burn the barn down the next games that you do just keep adding something new keep doing something a little a little better keep pushing it a little more and you know before you know it now you're writing the next Gears of War sure I think that it teaches you a lot about development in general and the idea of evolution of the waterfall to methodologies for development now but games can be kind of a similar similar concept there yeah agile like us yeah agile I've done a lot with scrum in the past and you can apply a lot of the scrum techniques to to individual efforts as well because that's what all these are from your individual efforts I don't have anybody else working with me you can apply a lot of those techniques where you know you just incrementally add more and more features as you go along you just set yourself a little goal you know like this week I want to do X ok that's what I'm doing like right now I'm I'm working on another game and I'm saying okay how do I add like title screens and game over screens and pause screen and make nice transitions between them because I've done the screens before now how do I do these and make some nice transitions between them make them kind of flow and not just be very abrupt hey the game's over with you're done you know I want to make a nice little like at the end of Mario when when Mario loses all of his lives and he does that dot that up up and he just kind of jumps up and falls off the screen how do you do that all right you know you know how does everybody else stop and you make that little thing happen so so that's kind of the next thing so you keep polishing it as you keep going along and exactly you know giving those little moments of excitement and kind of a break in the action yeah I like that when you were working at Microsoft were you a manager at some point so my title was was project manager or actually I'm sorry program manager okay so basically I didn't manage anybody I mentored a lot of folks I mentored a lot of new folks who come in I'm happy to see some of the folks that I mentored see them moving up the ladder at Microsoft which is which is great place basically the way I used to have explained program managing at Microsoft is you have developers who write all the code you have testers they test the code and you have the the program managers who do everything out okay some somebody described our job is making sure that the developers always had something the developers testers always had something to do sure you didn't want you know them sitting around getting bored and saying what's what's next what's going on so you know I wrote specs I dealt with customers or wrote documentation we bounced ideas off one another I can code as well and so I was able to talk with the system engineers the the software engineers rather developers and testers you get to be a translator in some ways between all those themes then sounds like yeah exactly exactly you know they could explain something to me they could show me in code and I could sit there and look at him so yeah I took part in code reviews and such so it was it was a great experience or was very rewarding experience I I really enjoyed doing it I never I people managed one person for like four or five months and I really didn't do very well at it so I like working with people I really don't like managing people all that much sure no I understand I guess why I brought it up is I was having a thought let's say you know somebody wants to build on their portfolio do you think adding games that someone's program would that be something a manager would be interested in looking at do you think that shows off certain sets of skills I think so because games are very easy to understand okay you know everybody understands what I think everybody understands what a game is it's it's meant to be a challenge for somebody it's meant to you know for somebody to have fun be a bit of a distraction from from the everyday if I'm looking at somebody's you know their github repository and I see all these different things on you know machine learning and a eyes and different things I'm looking at it going okay this is meant to solve a specific problem I I need to understand what the problem space is if I look and I see oh they've got a game up there I can download that I can run it I can you know see the game you know right off the top and see exactly how it's supposed to work right because I understand that and I think games are more Universal as I look around at people who are doing games I am amazed at some of the folks who can actually you know without a game in you know a three hour twitch stream oh wow I've seen a couple folks who've done that who decided okay they're just gonna put this game together and you know is it polished no does it have all the bells and whistles that it needs to know but the basic mechanics are there everything is in place you can see where everything you get hooked up they can go off and have artwork done and have a nice working game and do this within three hours because they understand you know the environment which they're working they understand the game and they understand how to put it all together and that's the kind of level of expertise that I think that everybody's looking for I find it amazing there's actually was it pi week coming up yeah I was just gonna mention that that it's March 29th explain what pi week is yeah pi week you've got a week to build a game in Python they set up different constraints the the game has got to be of a you know in a certain genre it's got to have certain theme whatever it is that they define so you get a week to build a game and this is great for for for beginners as well as experts because you've got a week you can put this you can put these things together and there's plenty of resources out there if you're not an artist you don't need to be an artist you can go out and find the art if you've got an idea for a game this is a great time for you to put the game together you know give yourself a week and just code up a game it is I'll be honest with you I've seen it I haven't partaken in that I'm looking forward to partaking in at this time or you are going to okay yeah yes I wondered about there's teams right so the idea is that if you wanted to join a small team or something like that that that might be a possibility twos am I right about that um I think so again I'm gonna have to take a look at it I was planning on just doing it solo I've got an idea for a game in my head I'm already kind of testing out some things that that would go along with it it's a recreation of a game that I played years and years ago sure I haven't haven't seen anybody else come up with a version of it since then so I'm kind of looking forward to seeing if I can actually pull it off or not you know within a week that's a an ambitious goal yeah it is talk about the idea of like a scrum or agile development getting a proof of concept and putting something on this legs you're going to having to do it yeah pretty quick and keep it small in some senses so you were talking a little bit about watching a twitch stream yeah I've seen that al Swaggart occasion will do that the guy wrote automate the boring stuff yeah he also has a couple books about gaming invent with Python I think yeah yeah he's got he's got some great books of his I've got ebook versions of most of his stuff automates boring stuff inventing computer games with Python good stuff they he doesn't go into into the graphical elements all that much goes more into the how do you construct the game and the flow of the game which is great for beginners sure laval stuff he's kind of like the the mack daddy of the Python world yeah I'll definitely include a lot of those links who were you watching on twitch there's there was one guy I watched a lot of his name was he went by quill quill dev I watched a lot of his YouTube streams after the fact and this is back before I was getting into Python and I was trying to learn unity and he did a lot of unity gaming okay yeah that's a popular platform yeah yeah unfortunately I run 21 years at Microsoft and now I don't have a Windows machine I have a Linux machine and unity doesn't run on Linux but still the the lessons are there there there is a game engine that runs on Linux Mac and Windows called Godot or Godot a lot of those lessons still still play into it so you can do a lot of a lot of really cool stuff with with game engines but if you're just starting out it's like maintaining a you know an address book at home using sequel server it's okay it's kind of overkill there's a you know there's an awful lot to it that you're never gonna use if you're just trying to make a little solitaire game sure this is where you know Python and some of the the libraries that are in Python come into play and really help people understand not only how how to write games but also how to code around games and how to solve some of the problems before they get into okay now I want to create this big immersive world and I really need a big engine great then you can move to those engines and you've got the coding background from Python that will make you a lot more successful in in that realm so I was thinking about that maybe we should dive a little bit into the different libraries talk about some of the advantages or disadvantages and mm-hmm probably the big one that I hear about and I think pi week is involved with someone as high game mm-hmm yeah and PI game has been around for for a long time originally started off as a wrapper over SDL okay you know it's been around for a while what's a steal what does it stand for what is this deal simple directmedia layer okay PI game is started off as a wrapper over SDL which gives you a way to control media and control graphics and give you an abstraction above the hardware layer of your individual sound card video card etc that you can address from Python built it up into into a larger engine that you can use to actually write games and when I first started teaching Python and started teaching gaming and Python that's what we use PI game okay it's been around for for a while people know it it's got tons of people who enjoy it and use it there are a couple of downsides to it in that it is old well olds not the right word it's been around for a long time and so some of the more modern object-oriented features of a game engine that that maybe people would want to use aren't there or need to be built-in what's kind of missing well there's things like you need to manage your own game clock which is a little odd you don't have to do that if you're using unity or unreal or or Godot they manage that for you they they handle all that stuff for you so a game clock what is that so the game clock dictates how fast your game graphics will update on the screen the faster you can update the graphics on the screen the the smoother your game will look okay but you have a much shorter time in between each update to actually figure out what the update should be if I need to move something if I need to move something on the screen in response to say player input I need to figure out okay how much does it need to move and how much time do I have to actually get it to move to get it there because I'm I need to you know make changes to the objects that I'm manipulating so how how quickly how much time do I to do that if you take more time to do it then you've got fewer updates that happen every second your game looks choppy err okay and if you try to make it try to accomplish a whole bunch of things within this loop if you will this cycle right and it's unable to accomplish them would that create a different type of choppiness yeah I can depending upon what's going on inside the game loop for example let's say you've got a game loop and you're trying to maintain of 30 frames a second which is a little faster than say what a movie would be a movie I think is at 24 frames a second sure okay so you so you want your game you know to go with 30 frames a second which is pretty much the bare minimum that gives you basically one thirtieth of a second to do all of your processing to do all the things that you need to do yeah and if it takes longer than that one thirtieth of a second then when the one thirtieth of a second is over and it's time to show the next frame you're still doing calculations the next frame can't be shown so we have to wait yeah and so that's what causes choppiness that's what causes the the kind of herky-jerky movements and so you know most games actually want to run at much higher frame rate you know one you know 60 frames a second is actually a pretty standard yeah that's a lot of things are bragging about over the last like 10 years so if this can run at 60 frames per second right I've heard it he even needs to be faster for VR makes people ill yeah yeah exactly so depending upon what you want to do you want to be able to do things and calculate things very quickly so you want to make sure that what you're doing in in your game loop to do your updates is as quick as it possibly can be and in Python you have to you have to manage your own game loop you have to setup your own game loop to basically say okay here's here's the end of my game loop and I want it to be 30 frames a second in something like arcade you don't need to do that oh you're saying that you said Python but you mean PI game right a PI game I'm sorry I said PI game you need to you need to basically say okay I'm at the end of my game loop and we're done okay in arcade you don't need to do that arcade has a default 60 frames the second game loop running oh wow that's nice and what happens is it maintains the game loop for you and it says every time through the loop I'm going to call the following functions I'm gonna call an on update function and get your updates and then I'm gonna call an on draw function at the end of it okay and I will call an on key press to get keyboard input and and so it defines a lot of this stuff for you so all you need to do is say okay in my on update what do I need to do I need to move things around and if you find that the game is choppy you can see that now you can say okay I need to speed this loop up somehow I need to speed up what I'm doing this is again where you start getting into more computer science type of thinking okay instead of doing calculations is there a way that I could do this faster and so you start to think of look-up tables instead of doing calculations you know you start to think about changing your data structures in such a way that they're they're faster to to access and to update and such so using something like a set versus a list or write write or dictionaries or things like that that are hashed right and you know if you're trying to simulate physics okay do I need to do actual calculations using you know Newton's constants for physics or can I just simulate that a lot a lot quicker will it look okay and in a lot of cases you find that it looks fine with just the the approximations you know you don't need to do actual physics unless that's exactly what it is that you're doing and now you need to maybe slow the game down a little bit so that you've got that extra time so these are kind of the trade-offs that you make as sure as you're designing your game as you're building your game I was playing around in iOS they had created a sprite library and it had a lot of the general physics stuff built in which helped a lot like you know here is gravity you could basically start using their api's and tools to kind of get things started is some of that stuff built into arcade or PI game it is arcade so PI game does not have a built in physics engine of of any kind if you need to do physics you need to manage it yourself and there are some great libraries out there to do it Wow okay pi monk is is a great physics library that you can use you can you can actually if you wanted to do more advanced physics you can incorporate PI monk into your arcade game as well okay but but for basic kind of physics things arcade has some built-in physics engines it's got one that will provide you with basic collisions it'll provide you with how to handle a sprite so that a sprite won't go through the ground you know it recognizes here's the ground yeah and I'm through the ground I can't walk through a wall it's got a platformer engine as well so and it'll handle automatically if you if you set them up properly it'll handle moving platforms so it'll just automatically animate your moving platforms you can have your sprites sitting on those moving platforms and it'll move them for you okay like they're attached somehow or something yeah exactly you jump on you know if you jump onto a moving platform and then you stop moving and the platform moves you will move with that moving platform okay it's really cool it also has support for animating your sprite so if you think of you know Mario or the loadrunner whenever they were running they look like they were running they actually moved and that's a Brent that's a feature called animated sprites our Kade has built-in support for animated sprites okay with with pygame you really have to you really have to handle your own sprite motion in your own sprite activity it's got sprite handling but it's not of the same caliber as arcade does so that's pretty big differences well it's more modern right when did arcade come alone arcade is I'd have to look back it's only a couple of years old it's not that old the the guy who maintains his name's Paul Craven he's a professor at a university in Iowa okay I've been back and forth with him an email when I wrote the first arcade article I actually sent a copy of it to him first to make sure that I wasn't oh wow cool didn't have any glaring errors and if he enjoyed it he liked it he liked the fact that the article was out there in the course of writing the next article I actually found a couple of issues in the in the library and I've issued a couple pull requests which he's pulled in we've talked back and forth he's very active on the reddit group for Python arcade which is our slash Python arcade so he is very responsive he's kept updates coming to arkaid for the past at least the past year since I've been playing around with it so it's a pretty active yes very active yeah I noticed that he has a sort of read the docs kind of page which is Arcade Academy and it looks like it has lots of nice resources ready to go on it - yeah he's got all sorts of tutorial games that are up there he actually just recently added one a Space Invaders clone oh good which is which is great because it solved the problem I wanted to write a Space Invaders clone but there I couldn't figure out in my head how to do the the blockades at the bottom and he's come up with a very elegant solution to doing the blockades at the bottom I learned something from from his most recent tutorial as well so yeah I really enjoy arcade but just like every other game engine it's got its downfalls as well obviously it's still under active very active development there's a lot of things that he adds sometimes he adds breaking changes so you know you have to go back and take a look and you know specifically aim your your game at a particular version he readily admits that the sound and music handling is subpar he doesn't doesn't like it and compared to PI game he's right my game has much better music handling than than arcade does okay I was wondering about that like there's certain things you need to do to get your audio ready for being a sound effect or being as background music for for both of them not really they both handle the major formats mp3 wav audio urbis OGG is probably the the more popular of them I was fascinated that OGG is like a really popular format for games why is that you know I don't know off the top of my head I know mp3s you know they're smaller but they're compressed right you know WAV files are gonna have a lot of fidelity but they're huge right they're gonna expand your game a lot right yeah yeah exactly you know I i've translated my stuff into aughh files you know the the size differences don't seem to don't seem to matter much I think a lot of it may have to do with proprietary versus non proprietary codecs as well okay so like licensing is more open yeah yeah as opposed do you have a good tool that you used to make those files cuz I really had to hunt around doing my video course to try to create like I created some custom music and some sound effects myself and wanted to get it ready to go and I was having problems with the mp3 playback and pygame and it seems like Aude worked really the smoothness out of everything that I tried and kept it fairly small so I could share the resources and I ended up fighting I'm trying to learn the name of the weird tool I found but do you have a suggestion so I kind of fall back to audacity okay I actually did some the sound effects that are in the PI game article that I did I actually just did an audacity I recorded my voice I added some filters okay and that was it I did a I did kind of a victory sound for this for game to support the my next article okay I used a tool called musescore to to just write a little piece of music and you know down at the time to put that and write okay just you know recorded it and then I you know I can use audacity to just you know kind of edit the Edit the sound and you know add echoes if I want to or compress it a little bit change format so audacity's worked very well for me it has some nice kind of effects ready to go in and just nice yeah there's two kind of areas I was wondering about one is you mentioned it briefly when thinking about high week in getting resources for your game you know maybe you're not an artist maybe you're not a musician or person who works on sound effects and you would you really just want to focus on the programming part but you'd like to not just have like flying around text characters or something like that you want something a little more interesting so what are some good resources alright probably the best resource that I found for a lot of this stuff is a website called open game art org okay there are you can sign up for a free account up there there are tons of resources for you to use you'll have both for 2d and 3d games so you can get two-dimensional sprites and sprite sheets you can get packs of sprites that you can use just to build platformers of every different kind you know if you want you know just dirt and grass because it's going to be nice little kind of Mario thing you can do that if you're gonna make it on some lava planet you can get lava and weird rock stuff you know if it's gonna be in space you know they've got backgrounds they've got sprites of all different colors where's that term sprite come from was that I don't know that it stands for anything I remember using it way back in the 80s it's basically just a small picture that you manipulate as one unit on the screen okay you can break out 2d game down into and do a bunch of different sprites yeah okay yeah I think then they're layered on top of each other yeah think of think of you know super mario brothers you know Mario is a sprite he's an animated sprite so there are a lot of little pictures that make up Mario same thing with the goombas you know as they're kind of walk you back and forth they're just sprites and then if they're walking to the left they're pointing in one direction they're walking to the right we just mirror them and make them walk in the other direction okay those are all just little pictures that are used and they they appear wherever you want them to appear they've got boundaries around them okay that dictate okay what happens you know where do I collide with this thing you know where's the actual edge of it and then yeah the the game engines all of them whether it's PI gamer arcade or you know unity or Godot or unreal they all know how to they just layered the sprites one on top of one another so you'll have a big background you'll have all your sprites for your your walls and your ground and your ladders and your background images and then you've got your sprites for your characters and sprites for your enemies and they all know how to how to interact with one another in one way or another whether that's encode or something that you define in the in the world itself so you're saying open game art is a good resource do they have does sound also yes they yeah they've got sounds I've downloaded a bunch of sounds from them again it depends on the type of game if you if you're doing a medieval sword & Sworcery game and you want you know swords clashing you want bunch of you know kind of the kind of sounds of you have a sword people right you know obviously I'm not a sound effect I've seen some games that are like that where the person literally created all the sentencer they're just their voice and and filters like you were saying for your game oh yeah yeah and and people who do just that I mean they you know there are people who will actually make money off this so you know open game art you can you can get things check the license on anything that you download though make sure that that the license is gonna work for you some some folks it'll be a Creative Commons license some folks use MIT or BSD or uh you know GPL license and make sure that the license fits with your game and that you can redistribute as well okay so the license would be something that as you look at one of these I know for better word assets these sprites or pieces of music or whatever yeah there'd be a license that is tagged there with it was the license say so so the license will be there though there probably be a little tag an asset is that you know it's the right word for all of this stuff anything that you put into your game is an asset the license will be tagged there there'll be a little tag that shows what the license is and then you can click on that and it'll go and take you to a page that will explain exactly what the license terms are because a lot of them are they're very generic a lot of people just use the same license all the time whether it's a you know Creative Commons license or GPL v2 or v3 the BSD license and you can go through the the terms there and it'll tell you what you can and can't do with those particular assets can I take these assets and put them into a game that I will then sell to people and the license will say yes or no you can't do that okay so you could do it for your own development and share it with your friends potentially but not nothing commercial depending on that the level of the license that you're looking at exactly especially with fonts you know I I did this with a with the font I downloaded a font that I wanted that wasn't available on my machine I thought it was a great fond I looked at it I thought it would work just fine I started looking at the license only to find out that no the version the free version of the font that I have is only for personal use I can't do anything I can't redistribute it I can't you know do anything else with it so I had to change fonts I had to go with something different so is this for your gamer for like an application you're putting on this is actually for the game that is supporting my next article okay I've downloaded the font I thought it worked great and then oh no I can't use it okay just in the code that I'm going to distribute I do not that font I don't have it referenced anywhere I think it looks great but we're just gonna have to drop back and use you know times new roman' something that's more open okay yeah yeah and and and there are plenty oh you can go out and buy and get free fonts too I think a there's a site called open fonts and you can get fonts that that have the same kind of licensing around them they're free to use you know you can redistribute them you can put them into things that you sell or things that you give away you know just make sure that you that you read the licenses that you comply with them because that's a really good way to get a cease and desist letter from somebody's lawyer if it becomes especially if you're creating something that's really nice and this becomes popular yeah what are the ways that that you give that credit is it something you were you put in the code or do you need to have like a credit screen yeah with the license dictate that stuff yeah it would and for folks who read both the PI game in the arcade article you'll notice that I've credited where I've gotten different things where I've gotten sound effects where I've gotten different sprites okay that's because that the license a you know either attribution is necessary or a lot of folks say that 3d use attribution would be nice but not necessary and you know attribution is easy I can put up a credit screen and say you know the sprites came from here okay I can definitely put it in the article I definitely put it in the code that I share you know make sure that those attributions are there again the license will tell you how you need to attribute it sometimes it's just in the code but you know it doesn't hurt to put it in the documentation as well certainly doesn't hurt to put it on a credit screen if you got one so the next thing I was thinking about is if you created this game and now you want to go to the step of sharing it with someone and not having to drag somebody over to your computer to play it and you know somebody within your own house I can understand staring with other people that work in Python and they could download the code from github or what have you have you gone through techniques of trying to compile the stuff and share it more wide than that none of my games have been of the caliber that I want to share him in that way I I put them up on github sure the next game yeah I really would like to put this out because I think it'd be a cool game this one that I've had in my head for a while there are ways to to package up a Python I think that there's actually a real Python article on packaging your Python app pre used with with other folks okay and I've actually recommended that to somebody else a real quick search on packaging your Python stuff will show real Python how to package it up and so that'll put the whole thing together into one executable that'll run on hopefully whatever system you have run Python run the game you just need to make sure that you've got everything packaged up properly one good way to do this is if you're a solo developer and you're and you're doing this stuff find reach out find somebody else who's willing to try it find somebody else who's willing just to download your github repo and just try it themselves okay see if they can do it because like say if I were to reach out to you and say can you try this game out really quick right and you download the repo and I say here's how you run it and you run it and it just doesn't run now I know there's a problem now it's it's something that is specific to my machine that is not on your machine and I need to fix that okay so that really helps you get past a lot of these issues another way to do that if you don't have anybody else to try fire up another account on your machine just add another another user account to your machine make sure that they don't have anything on that machine on that particular account and just try and download it and run it from there that way you kind of isolate any of the special sauce that you've got on your machine that you were using for development and debugging and everything else and just make sure that it runs for you know just a regular user on a normal machine one thing that I was looking at was a library called B where B EE W ar e which is a way to get Python code running natively on an android device okay which look really interesting when I first started digging into it I guess it was about this time last year I started looking at it it seemed like they still had a little ways to go and then I just read an article a day or two ago that said that they had just gotten a Python you know just straight up Python running on Android using all the native stuff on Android nice it looked really good and it's it's definitely something that I want to do because the mobile market is obviously Hugh especially mobile gaming if you've got a good idea for you know just a little time waster kind of game and you can get it out on the Apple Store or Google Play you can really kind of make a splash there something I'm developing as a weekly topic here is what you're excited about right now and the space of Python doesn't necessarily have to be about games could be an event a package or something else that you're kind of excited about in the Python world right now there's one thing that I've actually been reading about it and it is kind of game related it's a new library called or Sina you are s I and a or Sina like Earth's I'm like a bear sure okay it is a 3d library that is fully Python it's built on top of Panda 3d which i think is where they get the ear Cena from yeah okay it's a 3d gaming library and look it up or Sina and get to their website they've got a couple of really cool demos like they've got a Minecraft demo you know where you can just you know kind of build the world and click on things and it's nice it's it's just insane it's like less than a 1k of source code and the year Sina engine and you've got a world in which you can move around you can rotate you can do all sorts of stuff you can start building up they've got one that's just over it's not that much more code but it's it's the same kind of idea but it's hexagonal instead of square based and you can pull things up and push things down and move them around and it's really impressive what you can do with this engine in the 3d world no I haven't dulled delved into the 3d gaming at all but just the fact that you can do this stuff in Python with an engine and a couple of lines of code is just fascinating to me I'm always amazed at the new things that are coming out and this for for graphics for gaming for data visualization for just about anything this is this is a very cool new library that I've just learned about I'm just starting to play around with awesome that sounds great well what excited about is now that we're setting up this podcast dan and I are working on audience questions collect recordings of these questions that people are asking and then working toward creating a question and answer maybe monthly like a panel kind of thing or maybe depending on the guests able to answer a few questions one off but that's our one of our next big steps and I'm excited about getting the audience more involved in it and as we keep continuing this podcast I guess that would be my next new thing coming from the real Python space those are cool I always like going to those during conventions and conferences and stuff where you know you get four or five people sitting up on the stage and just talking amongst themselves and then people come up to mics and start asking questions back and forth always love being part of that and if not asking questions at least listening to all the questions and the answers and the banter back and forth that's lots of fun as we get close to the end of the podcast here is there anything that we missed the one thing I reiterate is you know if you're going if you're gonna write games you're gonna do this stuff and you want to learn this stuff just make sure that you're not judging what it is that you've done based upon what somebody else's has done who has been doing this for 10 or 20 years if you're just starting out be prepared to to get things wrong be prepared to have things break be prepared to say oh you know this isn't quite up to up to par that's fine go on get to the next thing try something new and just make sure that you're learning stuff that's that's the key nothing's ever finished there's a thing in the art world that says our artists never finished it's just abandoned right be ready to abandon something to go on to the next thing let's take into one other question for you in that vein like can you think of like what has been one of your biggest challenges that you faced in trying to make games I think one of my biggest challenges is looking at the games that I played when I was a kid like arcade games I've got this thing about recreating arcade games sure Galaga is one of my favorite games I love playing Galaga yeah and seeing what what folks did in in hardware and in very limited memory with very limited resources and being able to put these things out and have them be successful and and money making things and then looking at what they did and then trying to recreate it the big challenge for me is that I run into the limits of my own my own knowledge I run into limits of my own thinking you know I'll go back to Galaga if you're familiar with the Galaga game there's a bit where all of the enemies they fly in on the screen from the left and from the right and they fly in and they follow little patterns before they assemble themselves up at the top of the screen yeah how do they fly in on those patterns what is that pattern that they fly in on they come and they do a little loop the loop and then they get set up top and then the boss stages is when they're they fly down in set specific patterns well how are those patterns defined how do you know that you know they're supposed to fly into this loop to loop and then where do they go trying to figure that problem out trying to solve that problem is I keep running into my own I keep thinking I'm over complicating the solution I keep thinking I don't have the solution I have no idea where the solution is I it's time use me all the time as to how how do i how do I do that in a way that is computationally efficient and I can get it done inside of inside of my frame count yeah in such a way that I can actually define levels you know so I can put this stuff in data and say okay here's the pattern that it flies and how do i define that trying to trying to figure that out and then sit there and say yeah but I've got you know eight gigs of RAM and you know Python this guy had a bunch of transistors and he did it in machine language definitely kilobytes yeah you know you know he had K in machine language how the heck did he do it this gets back to measuring my chapter one against his chapter 20 he knew a lot more about that than I did sure so I'm I'm always always trying to learn and and so the biggest challenge is as you're figuring this stuff out try not to get discouraged by the fact that you know these guys did it already and they did it better than I'm gonna do it maybe it goes back to constraints a little bit you know the fact that you can't you have all this crazy memory and you're reading it on a desktop you know computer that's yeah thirty years removed from or even further almost almost 40 years removed from yeah when all these original arcade games came out yeah exactly and that's the kind of cool thing I think about the we were talking about with pi week this idea that hey you know you're not gonna be able to complete Elder Scrolls Skyrim or something like that and a week you know that games like in five years or longer and a team of hundreds of people yeah keep your goals within reach that you can kind of then build on top of them mm-hmm well thanks for joining me John I really there's been a great talk I've enjoyed it immensely thank you for the opportunity and uh really looking forward to hearing who else you get on the on the podcast I enjoyed the first one I'm looking trying to figure out why I'm why I'm here and I'm really looking forward to else who else you got all right okay well I'll keep you guessing okay thanks Chris all right bye I want to thank John Fincher for talking to me and I want to thank you for listening to the real Python podcast make sure that you subscribe to the podcast in your favorite podcast player and if you liked the show leave us a 5-star rating and a review you can find show notes with links to all the topics we spoke about inside your podcast player or at real Python comm slash podcast and while you're there you could leave us a question or a topic idea I've been your host Christopher Bailey I look forward to talking to you soon you
Info
Channel: Real Python
Views: 4,100
Rating: undefined out of 5
Keywords: python, realpython, python decorators, python podcast, real python, pygame, python games, game programming, game dev, gamedev
Id: d7_QXUzET8k
Channel Id: undefined
Length: 55min 14sec (3314 seconds)
Published: Fri Mar 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.