Learn Python with Talk Python's 270 hours of courses

#223: Fun and Easy 2D Games with Python Transcript

Recorded on Thursday, Jul 25, 2019.

00:00 Have you tried to teach programming to beginners?

00:01 Python is becoming a top choice for the language, but you still have to teach them how to work with the language

00:08 and understand core concepts like loops, variables, classes, and more.

00:11 It turns out video game programming, when kept simple, can be great for this.

00:16 Do you need to repeat items in a scene?

00:18 Well, there's a natural situation to introduce loops.

00:21 How about move an item around?

00:23 Maybe make a function to redraw it at a location.

00:25 On this episode, you'll meet Paul Craven, who created a new 2D game engine for Python

00:31 just for this purpose called Arcade.

00:33 And even if you don't teach or you're not learning Python, it's great to play with.

00:37 It's really easy to make 2D platformer and side-scroller games.

00:41 This is Talk Python to Me, episode 223, recorded July 25th, 2019.

00:47 Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.

01:07 This is your host, Michael Kennedy.

01:09 Follow me on Twitter, where I'm @mkennedy.

01:11 Keep up with the show and listen to past episodes at talkpython.fm.

01:14 and follow the show on Twitter via at talkpython.

01:17 This episode is sponsored by Indeed and Rollbar.

01:20 Please check out what they're offering during their segments.

01:23 It really helps support the show.

01:24 Paul, welcome to Talk Python.

01:26 Hey, great to be here.

01:27 Thanks for having me, Michael.

01:28 Yeah, it's great to talk to you again.

01:30 We got a chance to meet each other at the creator's booth part of the PyCharm booth at PyCon.

01:37 That was fun.

01:37 Yeah, I enjoy PyCon a lot.

01:39 Yeah, so did I.

01:40 I call it my geek holiday.

01:41 In August, I'm going to go on holiday with my family, but in May, I went on the holiday with my friends and my geek friends.

01:49 It was great.

01:49 Thankfully, it's the only conference I go to, and I look forward to it every year.

01:53 Yeah, yeah, absolutely.

01:54 And while we were there, you were presenting your project that ties in both to your teaching side of what you're doing at the university,

02:04 but also just making gaming and Python more fun, this thing called Python Arcade.

02:09 So I'm really looking forward to talking to you about that.

02:11 Yeah, it's a project I'm really passionate about.

02:14 Yeah, I can tell.

02:14 So before we get to that, though, let's start with your story.

02:17 How did you get into programming and then Python?

02:19 Video games, actually.

02:20 Long ago, I worked with an Apple IIe.

02:24 My dad had gotten one of those, and being the evil father that he was, he wasn't going to just pay for video games for me to play.

02:30 So he said if I wanted to play games, I'd have to program them myself.

02:36 And there's a few books out there by David All, more basic computer games and basic computer games.

02:43 And they basically just had computer games in basic that you could type in.

02:48 And I got started programming doing that.

02:51 And once you had the game in there, you could start modifying it and customizing it the way you wanted.

02:55 I just absolutely love that as a way of learning to program.

02:59 And that's how I introduce my college students, many of which haven't programmed at all, to try to get them hooked into programming.

03:08 Because it's not just me teaching them programming.

03:11 If they only take one semester, it's only a limited use.

03:13 But what I really want them to do is realize that programming can be fun and entertaining and a creative process that they can get into just because they plain like programming.

03:24 Yeah, absolutely.

03:25 I definitely think that that's an interesting angle to help people get more engaged.

03:29 So that's basic was the sort of entry point.

03:32 But where do you learn about Python?

03:34 I had a student actually present it.

03:36 We were teaching programming in Java, which is a terrible language to teach programming in.

03:42 It was the main way to do it for most schools for a long time.

03:45 Oh, it was a step backwards from like Pascal.

03:47 And that's how we were teaching it.

03:50 And he gave a presentation on Python.

03:52 Wasn't too interested in it at first because the last thing I needed to do was learn another computer programming language.

03:57 But his presentation was actually really good.

04:00 And it got me thinking about how simple and incredibly straightforward you could get somebody started with programming.

04:06 And then that just got the bug in my head that maybe this would actually not be a bad way of teaching programming.

04:13 So we started now it's pretty common to start teaching in Python.

04:16 But when we started teaching in Python, it was not the common first language by any means.

04:20 Yeah, absolutely.

04:21 It was all about Java.

04:22 When was this?

04:22 What time?

04:23 What year?

04:24 About?

04:24 I would guess it'd be about 11, 12 years ago now.

04:26 Yeah.

04:27 Okay.

04:27 Interesting.

04:28 So Python was not nearly as popular and clearly the right choice as it is today, I guess.

04:33 Yeah.

04:33 No, not at all.

04:34 And it took a little bit of convincing for me with the other people at the college in order to be able to do that.

04:40 And we started introducing it, you know, just a few weeks at first and then, you know, eventually moved on to the entire semester.

04:46 So our first semester is Python.

04:48 And then once they get hooked into programming, then we hit them with Java after it's too late and they've already signed up for second semester.

04:54 There you go.

04:55 They're already committed.

04:57 Well, I think that that's an interesting way to think about it because I think that a lot of the ways that programming is taught, and I don't just mean like self-taught, I mean like even in like universities and stuff, I think it's kind of broken.

05:09 I think it's taught with an expectation of extreme delayed gratification.

05:13 I've talked about this before, but basically like we're going to teach you loops.

05:18 We're going to teach you variables.

05:19 We're going to teach you memory.

05:20 We're going to teach you the heap.

05:21 We're going to teach you pointers.

05:22 We're going to teach you all these things.

05:24 So maybe at the end of the semester, you can do something sort of interesting, maybe.

05:29 But you might have to wait a couple of courses after that before you actually build something that you care about.

05:33 And that's just, it's crazy.

05:36 It's not just delayed gratification.

05:37 It's delayed explanation.

05:38 Public, static, void, main, string, args.

05:41 I mean, you can't explain all of that in their first lesson just to print something to the screen, right?

05:46 Just type this in and we'll explain maybe sometime later in the semester how it works.

05:50 That's not how I want to do it.

05:51 I want them to understand exactly what they're doing.

05:54 Yeah, exactly.

05:55 So I definitely like that you're starting with something that gets them to like these short little wins quicker.

06:00 Then you can move on to stuff where you're talking about static languages like Java or whatever.

06:04 When they're already understanding like, okay, if I go through this, the payoff is really big or here's how I'll use it or whatever.

06:11 Right.

06:11 That's exactly it.

06:12 It does assume that they'll like arcade games.

06:16 But a lot of my students aren't as interested in spreadsheets and are a lot more interested in arcade games.

06:23 So I can hook a fair percentage of them.

06:25 When we were talking, one of the things you said that I thought was pretty interesting is much of what you have to teach for programming, there's some kind of visual aspect to it, right?

06:34 Like lists or data structures or loops or whatever, right?

06:41 And it's one thing to just do that in like a terminal app or something like that.

06:45 But you can actually visualize it better potentially if you have this simple game platform to test to sort of teach these more abstract concepts in.

06:54 Right.

06:54 A student can get really frustrated if they're supposed to get a 10 as an output and instead they get a 12 as an output.

07:00 They don't really care.

07:01 But if they're like drawing a football field or they're drawing a unicorn or something like that on their screen, then they'll spend a fair bit of time trying to get things lined up or just right.

07:12 Right, right.

07:12 If the horn points down, that's not okay.

07:15 That's not okay.

07:16 For the occasional student, they do want to just sort of give up at that point.

07:20 But most students really will spend a lot more time if they see that visual image and try to get it just the way they want it.

07:28 Maybe give us some examples of the types of things that you're teaching them there with games.

07:33 Well, to start off with, one of the first things we do is just create an image.

07:37 And the thing I like about using Arcade for that is that you can do it without defining a function before you get to that point.

07:45 So you learn about how to call a function.

07:47 And even just by calling a function, I don't have to have them create classes.

07:51 I don't have to have them create functions.

07:53 All they have to do are simple calls.

07:56 And then they can actually build on that to create an image.

08:01 And then that introduces them to the coordinate system.

08:03 And you can go off of that so that if they want something like a fence and they don't want to create a drawing command for each individual post in a fence, then that just naturally leads itself to, oh, hey, wow, there's a solution for that.

08:18 Let's introduce loops.

08:19 Exactly.

08:19 Yeah, because it's really painful to write 50 little fence objects and move them around.

08:23 Exactly.

08:24 And it's very iterative.

08:26 And they can see the value in picking up that, hey, I need to learn about loops.

08:32 Hey, oh, if I create a function, then I can create a function that'll draw a snowman.

08:37 I can create a function then and call that function to draw a snowman here, here, and here, rather than just repeating the code over and over again.

08:44 Yeah, sure.

08:44 I do like that you can start in this really simple mode, kind of like the print of the world side of things.

08:50 You don't have to have all the extra stuff, but you do have a pretty rich API, which do you want to talk about and get into.

08:55 But maybe before we really dig into even to arcade, let's just kind of set the landscape for everybody.

09:01 You know, not everybody is creating games or maybe more like me.

09:06 They've messed with like creating games, but it was like 15 years ago and they haven't really done much since then.

09:10 Right.

09:10 So what are some of the options for building games?

09:13 You know, what's the spectrum of what we could do?

09:15 Well, at the low level, you've got the ability to just individually manipulate the dots, what I would call raster graphics.

09:23 It's a very slow way of doing graphics, but it's the original way a lot of people have done graphics.

09:28 Then there are a lot of libraries out there or APIs for like OpenGL, which is really big.

09:33 DirectX, which is OpenGL is cross-platform.

09:36 DirectX is very much Windows.

09:39 And Mac now has sort of gone away from OpenGL and they're pushing their own metal as a way of doing graphics.

09:46 So they have all these different APIs.

09:48 And then basically to make it easier to program those, there are a lot of game engines that sit on top of those.

09:56 You got the Unreal, Unity, GoDot.

09:59 There's several game engines that do that and take care of some of the underlying work for you in those OpenGL DirectX metal.

10:08 Yeah.

10:08 And a lot of times that means working like in C++, right?

10:11 Like with Unreal or some of those other real game engines or Unity is C# or things like that, right?

10:16 Right.

10:17 Unity can do like C# or JavaScript.

10:18 GoDot's fairly popular.

10:20 It's a lot more of a friendly type of language, but it's not Python.

10:24 So there's different options out there, but all of them take a fair bit to get up and going.

10:32 And I wanted something that was really easy for a beginning programmer to get working, but still allow a hobbyist or a more advanced user to create some cool games in their, you know, off time.

10:45 Right. Well, so that makes certainly makes sense for Python and then like even maybe a simple API on top of that.

10:52 Right. So, you know, you're not going to drop into like native OpenGL and C++ and say, we're going to teach you about data structures because like that's a deep world.

11:00 I spent a lot of time writing simulators and doing programming there and it's fun, but it's not a simple place.

11:05 Not necessarily friendly either.

11:06 No, no, no, not so much.

11:08 So in the Python world, I had heard of Pygame.

11:10 That's been around for quite a while.

11:12 I heard of Pygame Zero, which I didn't really know how that was different than Pygame until recently.

11:17 What else is there?

11:18 Obviously, there's Arcade as well.

11:20 Yeah, Piglet, a few other ones, Coco's or 2D, I think.

11:25 And Pygame by far is the most popular one.

11:28 And I taught using it.

11:29 In fact, even wrote a book on developing arcade games in Pygame.

11:34 And I really like Pygame, but it has been around a very long time.

11:41 So it kept a lot of backwards compatibility on Python.

11:46 So it didn't use any of the new Python 3 features.

11:49 And the maintenance on Pygame at the time had completely fallen off.

11:55 So where I would try to make improvements and do pull requests, absolutely nobody was doing anything with that.

12:02 Isn't that super frustrating when you're like working with this project, you love the project, you put a lot of energy into it.

12:08 You go so far as like actually creating a pull request and submitting it.

12:11 It's one thing for them to say, you know, it doesn't actually fit with our vision or we can't accept it or whatever.

12:16 But if it just goes unaddressed, like that is really not the best feeling.

12:20 Yeah.

12:20 So there was a lot of back and forth on that trying to resurrect some of the people that were working with it.

12:27 And I actually just try to do my own development because you could always create your own branch.

12:32 But Pygame was developed off of an old library called SDL, a C++ library.

12:37 And that library itself was pretty old.

12:42 There's an SDL 2 version of the library, which I also tried working with and didn't much care for.

12:47 The underpinnings on Pygame, just if you wanted to keep the backwards compatibility and update everything,

12:55 it just didn't seem to me to be a really worthwhile effort, particularly when there weren't maintainers at the time.

13:03 It's actually started to pick up on maintenance now, which is great.

13:06 But I wanted something better.

13:08 And I thought, gosh, since most of the people that I work with are starting from scratch,

13:13 I could actually just start a game engine from scratch using something more modern like OpenGL and work off of that.

13:23 Yeah.

13:23 And you get all the benefits of like high end modern graphics cards, graphics, GPU accelerated stuff and all that.

13:29 Right.

13:30 Yeah.

13:30 And I taught a long time using Pygame.

13:32 So I found a lot of things.

13:34 And there's a lot of things about Pygame I really like.

13:36 So I was able to take those ideas and move it forward, try to clean up the interface, use the new Python 3 features,

13:43 do the bugs that my students always complained about.

13:47 Because when I teach, there's always these little warts you have to sort of tell the students about.

13:51 And every hour you spend telling a student, oh, well, that coordinate system that you learned,

13:56 well, it's different in computers because zero zero is in the upper left instead of the lower left.

14:01 Or set mode is in order to open a window, you use a command called set mode.

14:07 I know it's called set mode, but you really don't want me to get into that.

14:10 And, oh, you want to make a football and rotating ellipse?

14:14 Yeah, sorry, you can't do that.

14:15 You start getting over these and you come up with a list of them over time.

14:19 And it's just, gosh, I think I could do something better, quite frankly.

14:44 And when you start a one-on-one conversation with one of their career coaches, you'll get resume reviews and personalized advice to help you get what you deserve.

15:04 So if filling out countless job applications isn't your thing, let top tech companies apply to you.

15:10 Join Indeed Prime for free at talkpython.fm/Indeed.

15:15 That's talkpython.fm/Indeed.

15:20 So you set out to do that, right?

15:22 Yeah, basically I set out to do that.

15:25 A lot of false starts, a lot of attempts on different backends.

15:30 And so I got a fair bit of time into figuring out exactly how I wanted to do it.

15:35 So yeah, Arcade is built off of OpenGL.

15:38 It also uses Piglet for doing the window management.

15:42 Piglet is also a pretty good game engine.

15:45 And it is not nearly as friendly as Arcade, but opens a lot more of the internals.

15:54 So when a programmer is more willing to dive into the internals, Piglet's not a bad option.

15:59 Is there like an escape hatch in your API to like drop down to those internals?

16:03 Or is it like take it or leave it?

16:05 I mean, you could just import the Piglet library and start doing work in the Piglet library.

16:09 I wouldn't really call it an escape hatch.

16:11 Yeah, just directly work it.

16:13 Yeah, just start working with...

16:15 Yeah, it's not really something separate.

16:17 Yeah, okay.

16:18 The Piglet has their own system for managing sprites, which we can talk about in a bit.

16:22 I really just use them for doing OpenGL calls and Windows event management.

16:28 Okay, so there's not like a deep integration, like multi-layer thing.

16:31 It's more just like, just take what they built and go with that.

16:34 Right.

16:34 For the few things you need.

16:36 Right.

16:36 And some of the, like Pygame Zero and some of the other, there have been a lot of things

16:40 that have been built on top of Pygame.

16:42 I kind of wanted to try to avoid some of that because you get too many layers of abstraction

16:48 and things just get kind of weird after a while.

16:51 Yeah, there's always that leaky abstraction or...

16:53 Exactly.

16:53 That thing that should be easy to do, but it's actually really impossible to do

16:56 because something in the middle.

16:58 Yeah.

16:59 Nice.

16:59 So it sounds like another one of your focuses on building Arcade was to focus on making it like Python 3 native.

17:08 Right.

17:09 Right.

17:09 The ability to do type hinting, just going ahead and using f-strings.

17:16 Quite frankly, I really like the type hinting in particular because when I get students that

17:22 work in PyCharm and they have those little linters that go with it, it helps a lot of students.

17:30 And it's not something actually I thought that would help students as much as it really has.

17:33 I've gotten a lot better code once they get those hinting features that are available.

17:38 Right.

17:38 We expected a number and you're passing a string.

17:40 That's probably not okay.

17:42 Something like this.

17:43 Yeah.

17:43 Right.

17:43 Exactly.

17:45 And it's just, I kind of started working with Python 3 to begin with just at the beginnings

17:50 of it.

17:51 So I just am more used to everything that's Python 3.

17:55 And thankfully that's not really such the issue that it used to be.

17:58 Yeah.

17:58 I saw some articles about Arcade and some commenters saying, oh, I can't believe you're using F

18:04 strings.

18:05 This means I have to have Python 3.

18:07 6 and I can't get that.

18:08 How am I going to get that?

18:09 You know, it's like, those are kind of going away.

18:10 I think.

18:11 It is a pain.

18:13 I'm not going to make a lot.

18:15 And well, I mean, until like a year ago, Ubuntu had 3.5 a year and a half.

18:20 Not super long.

18:21 Right.

18:21 Like that's.

18:22 Right.

18:22 Even though 3.6 had been out for quite a while.

18:24 It seems like Ubuntu seems to lag about, I don't know, a point version.

18:27 Right.

18:28 Like it's 3.6 now, but 3.7 is out.

18:31 Yeah.

18:31 I don't know their exact release schedule, but you know, that time is fixing this.

18:35 Right.

18:36 So I definitely think Python 3 is the right place to be for this and type hinting.

18:40 It's super interesting.

18:41 Do you do anything with it in terms of like changing behaviors or anything?

18:45 Like that?

18:45 Or is it just there to help students be more accurate?

18:48 Really just help students be more accurate.

18:50 One of the other things I've really liked is being in the classroom, customizing the exception

18:56 messages.

18:56 So as I get students that run into problems, having the exception and certain areas, I'll

19:04 actually do a little bit of checking to make sure that they're actually passing in the right

19:08 type of data.

19:09 It slows things down if I do that too much.

19:12 But where the most common mistakes are when you run a batch of 20 to 40 kids every single

19:17 semester through using this, you really get a good idea of how to make the code library

19:25 better.

19:26 Yeah.

19:26 Because you have a bunch of people that have no expectations of what to do correctly.

19:30 So how do you help them fall into the pit of success and like make the most, the right

19:35 thing, the most obvious thing and whatnot.

19:36 Right.

19:37 Right.

19:37 It's one of the things I really like about in creating a library to iteratively be able

19:42 to take people through the library and look over their shoulders while they're working

19:45 on it is really valuable and improving that library.

19:49 And the also having it out on the internet where people that you can't see give you feedback,

19:55 having both of those different types of feedback is really quite nice.

19:59 Yeah.

19:59 That's super interesting.

20:00 I mean, some companies, they have like usability labs for their developers and they bring people

20:05 in and then like watch through mirrors and other ways of what they're doing.

20:08 And in a sense, like that's, that's very, very rare for open source libraries, I would

20:13 suspect.

20:13 But in a sense, that's kind of what you're doing, right?

20:15 Just because you're teaching and walking around in the classroom, right?

20:18 Exactly.

20:19 And one of the big features of this particular library is a large set of examples.

20:24 And over the last 12, 13 years, I've been teaching with video games.

20:29 I got this library of different things that students have asked for.

20:33 And so I create all these different code samples and make sure.

20:36 And that's one of the things that helped also in creating the arcade libraries.

20:39 I had, I knew all these different types of things that people wanted to do and they wanted

20:43 to create 2D arcade games.

20:45 And I created the library.

20:47 I needed to make sure that I supported all of those different items.

20:51 And I had all that set of example code in Pygame.

20:54 And then I basically had to make sure that I could do all of those same features in the

20:58 arcade library.

20:59 That is really handy to have all those examples.

21:01 So I guess, you know, we probably haven't done a great job of just like defining exactly

21:07 what arcade is and its point, right?

21:09 So it's arcade is for building 2D platform-like or side-scroller-like games with Python, right?

21:16 Yeah, or top-down.

21:18 But basically any type of 2D graphics.

21:21 And that's what arcade is really made to do.

21:24 And it's made to do it so that people can get up and going simply and easily.

21:28 It's not supposed to be a huge overhead or mentally taxing library to use.

21:34 Yeah.

21:34 Could you create like a tower defense game?

21:36 Yes.

21:36 The best game that we've got actually that I am aware of that's been built in it is a

21:40 tower defense game, which is a pretty crazy game actually.

21:43 I've wasted way more hours of playing that than I would admit to my student that wrote it.

21:48 Is it online?

21:49 Is it something people can check out?

21:51 Yeah, actually, it's called Great Skeleton War.

21:53 And there's a link to the GitHub repository on the Arcade Academy website that hosts the

22:02 Arcade library.

22:02 Yeah, nice.

22:04 Yeah.

22:04 So no, it creates great top-down, side-scroller, animated.

22:10 It is really oriented towards doing that type of work.

22:14 And it works on cross-platform, obviously, with OpenGL and Python on Mac, OS, Windows, and Linux.

22:21 Is there any option for mobile or it's just a three at the moment?

22:23 No option for mobile.

22:25 Basically, those are the three main platforms that are in use.

22:28 Yeah.

22:28 Okay, cool.

22:29 I mean, that's a totally reasonable thing, given what you're building, but I just want to check.

22:33 So maybe give us a quick example of what the API feels like to write like a super simple

22:40 game.

22:41 You've got like a nice little example.

22:43 And you even talked about how it doesn't even have to have functions or classes or anything

22:48 like that.

22:49 Right.

22:49 If you wanted to do something really straightforward and just draw something to the screen,

22:54 it's pretty darn straightforward.

22:56 First off, you import the Arcade library, obviously.

22:59 And then in the Arcade library is an open window command.

23:03 You just give it the dimensions of the window and a screen title.

23:06 Then the next command you do is you set a background color.

23:10 It has a set of colors you can choose from or you can specify in a red, green, blue format.

23:18 And the next, basically as an outline, you've got a start render and a finish render command.

23:22 All your drawing commands have to happen between start render and finish render.

23:27 Does that map over to like GL swap buffer down below or something like that?

23:30 Yeah.

23:31 Start render basically clears the screen and then the finish render will actually swap the

23:35 buffer in front.

23:36 Okay, cool.

23:37 Then you've got commands such as draw a circle, draw a circle, fill, draw a circle outline,

23:42 draw in a rectangle, drawing an arc.

23:44 You can put bitmaps on the screen.

23:46 All of these commands are actually slow to run.

23:50 If you really wanted something high performance, you need to actually batch up these commands

23:55 and then run a draw command.

23:56 But to get started, you don't have to do that or really worry about that.

24:00 When you get to more advanced programs, you can fill in with the batch type of program.

24:06 Right, right, right.

24:07 Basically, yeah, you just import arcade, open a window, set a background, start render,

24:11 finish render, pop a whole bunch of straightforward drawing commands in the middle of that.

24:16 And that would be pretty darn close to a finished program, except the program would immediately

24:22 end right after you did that.

24:24 So the window would come up, flash on the screen and then go away.

24:27 So you do need to do an arcade.run, which will basically hold the window open on the screen

24:32 until you hit the close button.

24:33 Yeah, okay, cool.

24:34 And yeah, you can draw a happy face or some sort of simple type of item in like 20 lines,

24:42 50 lines if you want to add a bunch of comments in appropriate blank space.

24:45 Yeah, super nice.

24:46 That sounds very straightforward.

24:47 And like I had said, you could just put those commands straight into a .py file and then run

24:53 it, right?

24:53 You don't even need a function or a class or decorators or inheritance or any of that.

24:57 So it's pretty approachable for people to get started with.

25:01 Exactly.

25:01 I usually have them create drawings like this and then move on to functions so that they learn

25:08 to create functions that draw horses or pigs or whatever the heck that is they want to draw.

25:14 And then they can put that into a function.

25:16 And then that starts making more sense to them why they need functions.

25:20 And then eventually we can start getting into classes and how to handle events.

25:26 Yeah.

25:26 I mean, this just sounds like a really fun way to get into programming.

25:29 You know, when I was taught, I was like learning just basically data structures in Lisp.

25:34 Yeah.

25:35 And that was not as much fun.

25:38 I got to tell you, it wasn't as much fun.

25:39 Even if you're an experienced programmer, I prefer starting with really small, simple,

25:44 straightforward programs.

25:46 If I have to start with some new framework and it's going to be 50 files that are in

25:54 XML and some other type of format, it's just a headache to get started and really figure out

26:00 where to even begin.

26:01 But if I can get started in a 20 line program, I can start iterating off of that and learn

26:07 a framework a lot easier.

26:09 I'm starting to use this term that Python is a full spectrum language.

26:13 And what I mean by that is like, it's really appropriate for super beginner folks.

26:18 Cause like this example, you don't even need functions.

26:20 Like you don't even need to know what a function is.

26:22 You just need to like write these commands and you're good.

26:24 But it also has really rich concepts like classes and decorators and generators and whatnot.

26:31 And it kind of grows all the way from like simple programs to Instagram or whatever.

26:36 Right.

26:36 I feel like your API kind of mirrors that a little bit, right?

26:40 Like it has this super simple way where you can be productive with a very partial understanding

26:45 of what's going on.

26:46 But then you have richer types like windows classes and decorators and events that you can

26:51 hook into and stuff.

26:52 Exactly.

26:53 Really what I was trying very hard with this particular package to be able to do for somebody

26:59 to get up and going easily with it and not a lot of effort, but still have a lot of power

27:04 if they want to take the time to do it.

27:06 Yeah.

27:06 It sounds like it's pretty good for teaching programming to people who are learning programming,

27:11 but maybe even for like kids.

27:12 I mean, a lot of times people teach them kids.

27:14 I saw some nice articles on using Pygame Zero to teach kids programming and stuff like that.

27:19 What are your thoughts on that?

27:20 Yeah, I think they're all good options.

27:22 Quite frankly, I like actually seeing a little bit of competition out in the landscape.

27:27 So when I create items, I like to look at what other people are doing, Piglet, Pygame, Pygame Zero,

27:35 and particularly in the whole open source type of movement, figure out, oh, is there a better

27:42 way of doing this?

27:43 And if there's only one solution, I think things can get kind of stagnant.

27:49 So I think Pygame Zero and Pygame are still completely viable options.

27:53 I mean, obviously, I'm biased towards my library because like, who wouldn't be?

27:58 But I like seeing the competition out there.

28:02 And I do speed performance comparisons with my library and the other libraries and also how

28:08 clean the code looks.

28:09 And that's a nice way for me to make sure that this library is good, right?

28:14 Yeah.

28:14 Frame rates?

28:16 Like, what does it look like for a game on arcade?

28:19 Most of the games that people put together are usually 60 frames per second.

28:24 Basically, if you program it poorly, specifically, if you draw items individually, as opposed to

28:31 lists, that's where people usually end up getting into problems having the frame rates drop below

28:37 60.

28:38 Arcade uses OpenGL.

28:40 So basically, as long as you load your sprites, your shapes, the items that you want into a list,

28:46 I've had it be able to manage 400,000 sprites on the screen that aren't moving at the same time and

28:55 still keep 60 frames per second.

28:57 And I can get about 1,500 to 2,000 moving sprites on the screen at the same time.

29:05 Yeah, that's pretty awesome.

29:06 Yeah.

29:07 If you include collision, it takes a little bit more time.

29:10 So going really into the deep on which one's faster, which one's not, is really starting to

29:15 get into the weeds, which I would absolutely love to do, but might not be what everybody wants to do

29:20 right now.

29:21 Yeah, yeah, for sure.

29:22 But it's maybe the main takeaway is it's pretty quick, right?

29:26 You definitely get like smooth frame rates and smooth behaviors and whatnot out of it these days

29:31 using OpenGL.

29:32 Yeah, I've got some speed comparisons comparing arcade to Pi game.

29:38 And basically, when you keep adding sprites in the same list, particularly if they're not moving

29:44 with OpenGL and arcade, you can keep doing that.

29:48 And it's like an order one operation to draw it.

29:50 You load them to the graphics card.

29:52 Once they're on the graphics card, you just tell the graphics card to draw them and pow,

29:55 they're back on screen.

29:56 Yeah, that's super interesting.

29:57 And I think that's one of the aspects of Python performance.

30:01 that's really interesting to think about here, because you're not actually every time you

30:07 say, here's a sprite and here are the things I want you to draw it.

30:09 It's not like Python is doing all this computation to make it happen.

30:12 It's kind of just like we've already loaded that stuff into the GPU memory.

30:17 And we're just saying, hey, GPU, apply this transform to this thing over here or the set of

30:23 transforms to those things or the whole viewport or whatever, right?

30:26 Like it's sort of orchestrating what's happening with the scene, right?

30:30 Rather than it's actually like drawing every little bit.

30:32 Right.

30:33 The graphics operations themselves are actually really quite fast and they're pretty well offloaded

30:39 for Python.

30:39 So the Python does the high level work and then offloads it onto the graphics card.

30:44 And if you've done that right, then it doesn't matter quite so much what language you're working

30:48 with.

30:49 One of the items that I am working on right now is in actually moving the sprites and managing

30:58 a large number of sprites, having them change where they are or detecting collisions between

31:06 sprites.

31:07 That is where you can see a bit of a speed difference.

31:11 Pygame actually does pretty good with this because it is not pure Python.

31:15 Python, it compiles a fair bit down to the C level and the different objects, the sprites

31:21 that you've got on your screen are actually backed in the C program so they can do native

31:26 manipulation that way pretty quick.

31:27 And the arcade library doesn't do that, but I don't know if we'll end up doing that in the

31:35 future.

31:36 I've done a lot of experiments and there's a fair speed improvement if you offload some of

31:41 that stuff to the C level.

31:42 Yeah, I can imagine that there's like a handful of things that would really benefit from that.

31:47 Have you considered or experimented with Cython or something like that?

31:50 I've thought about it.

31:51 I've not had a chance to experiment with it.

31:53 Goes back to the whole limited amount of time in a day, unfortunately.

31:56 Yeah, well, it could be a cool project for one of your more advanced students to tell them

32:02 like, okay, in this course, you're going to optimize this.

32:05 I'd be really interested to know what it would do.

32:07 I've never tried running it under Cython.

32:09 Yeah, I mean, not the whole thing necessarily, but just take like, you know, do some profiling

32:12 and grab like the three slowest spots or whatever and just hit those functions with Cython, you

32:17 know, for example.

32:17 Right.

32:18 This portion of Talk Python to Me is brought to you by Rollbar.

32:23 Got a question for you.

32:25 Have you been outsourcing your bug discovery to your users?

32:27 Have you been making them send you bug reports?

32:30 You know, there's two problems with that.

32:32 You can't discover all the bugs this way.

32:34 And some users don't bother reporting bugs at all.

32:36 They just leave, sometimes forever.

32:38 The best software teams practice proactive error monitoring.

32:42 They detect all the errors in their production apps and services in real time and debug important

32:47 errors in minutes or hours, sometimes before users even notice.

32:50 Teams from companies like Twilio, Instacart, and CircleCI use Rollbar to do this.

32:55 With Rollbar, you get a real-time feed of all the errors so you know exactly what's broken

33:01 in production. And Rollbar automatically collects all the relevant data and metadata you need

33:06 to debug the errors so you don't have to sift through logs. If you aren't using Rollbar yet,

33:10 they have a special offer for you and it's really awesome. Sign up and install Rollbar at

33:15 talkpython.fm/Rollbar and Rollbar will send you a $100 gift card to use at the Open Collective

33:22 where you can donate to any of the 900 plus projects listed under the Open Source Collective

33:27 or to the Women Who Code organization. Get notified of errors in real time and make a difference in

33:32 open source. Visit talkpython.fm/Rollbar today.

33:38 Let's talk a little bit about the API just a little bit more before we move off of that.

33:42 So on one end of the spectrum, we have like open window, set background color, render, render,

33:47 render, done. Sort of not even a function. We talked about adding functions and classes,

33:53 but maybe a more real application might create a class that derives from the arcade.window.

33:58 And then it has all these events, right? Like an on draw, on key press, on mouse motion,

34:04 viewport, all those kinds of things. You want to take us through like how that might look?

34:07 Precisely. A little more advanced, not a lot more advanced, but a little more advanced

34:11 game will end up using classes. And one of the main ones is the window class, which works like a lot

34:18 of classic window classes in other APIs where you've got certain methods that you can override if you want

34:27 to respond to keystrokes or button presses or window resizing. Any of that type of work can be done

34:37 in your own custom window class.

34:40 Yeah. One thing I like about that is it lets you avoid like writing the event loop and dealing with

34:46 all of that funkiness that maybe some of the libraries have to deal with.

34:51 Yeah. That's one of the things that Pygame does that I really don't like is that you basically have

34:55 to create your own event loop, which is pretty, I don't know, 80s or 90s style anymore.

35:02 And a lot of the libraries that build on top of Pygame or Pygame based try to hide that or they create

35:10 their own event loop on top of it, which for obvious reasons, it's not the best way of doing it.

35:15 And there's a lot that happens in a good event loop for processing, for queuing up the events. And it's not really something that should probably be left to everyday users that don't need to dive into that.

35:33 Yeah.

35:34 So you still basically plug into the event loop, like the keyboard events and the draw events and whatnot.

35:39 Exactly.

35:39 Nice. So one of the things that I think is super tricky. So, you know, I used to work on 3D simulators at the OpenGL a little bit and C++ and whatnot.

35:48 And it was fun. I did that, I don't know, for a year or two, but not for a long time. But the actual job of creating the 3D thing and rendering it and doing all that is not super hard.

36:02 But what is, at least to me, was super hard is like, how do I get a realistic looking thing on the screen? And in this context, this probably comes down mostly to sprites. How do I get little graphics that then represent the characters and the elements, you know, an asteroid in an asteroid game, a little missile in like a missile command or, you know, whatever, right?

36:22 Having really good ones of those without a team of designers, like that's like a big difference between a good game and not so much a good game.

36:28 Yeah. It just kind of shows you the value of good graphic artists, quite frankly.

36:33 Yeah.

36:33 When I teach programming, though, a lot of students coming in, I'm not teaching graphic art. And I don't want them to spend a lot of time creating great graphic art either. I typically will give, point students towards artwork. A guy called Kenny, he's got a Kenny.nl website, K-E-N-N-E-Y.nl.

36:55 And he creates a lot of open art that's freely available for use in games. And while it doesn't have a particular style to it, it's a nice spot to start with. He's got thousands of different tiles and images that are 2D and a nice spot for students to start with for doing graphics.

37:19 And then, yeah, I kind of show them how to look up other graphics using like Google images or some other search engine and download and use.

37:30 One of the things I really liked about Arcade, Pi Game, it was a hassle because they would often download images and the images would have a transparent background.

37:39 But Pi Game, by default, didn't support a transparent background. So you had to figure out a color that that mapped to and then tell it that this color is transparent. And there were so many headaches around that.

37:50 Yeah.

37:51 The art was often different sized than they wanted. So maybe they wanted a 50 by 50 sprite, but the art that they downloaded was 200 by 200.

38:01 And not all of them really knew how to use graphics programs to resize the art very well. And Pi Game didn't do that resizing very easily. And that was such a hassle.

38:12 That's also built into Arcade to basically allow them to resize that on the fly. The transparency is built in.

38:21 And it's just the aspect of getting the art, downloading and using it is a little bit easier for students doing that.

38:29 Yeah, this is really cool. So like the Kenny and Elf stuff is really nice.

38:35 Like I'm checking out the Pixel Vehicle Pack. And if you wanted to create like a like a Frogger type game, it's even got little like characters with jumping different jump stage animations on them and whatnot.

38:47 Yeah, it's quite cool. So these come in as like a big block, like one giant pixel picture of all of them.

38:55 Is there a way to say like, I want the third fire truck in this big picture full of fire trucks? Or do you cut them out?

39:03 Typically, he also makes them available as individual images. And I found with people, it's been a lot easier for me to rather than having them deal with a sprite sheet and try to figure out the coordinates of the sprite sheet to pull individual sprites out of that.

39:17 To use the individual files.

39:47 Draw the sprites in one batch command. So you say draw a wall and pow, the walls are drawn. Basically, once they're on the graphics card, it's an order one operation.

39:55 And then you can see, does the player collide with any wall? Does a player collide with any lava? Does a player collide with an enemy? Those types of things. So the sprite list is pretty integral to the whole thing.

40:06 Yeah, it definitely seems like it's pretty powerful. Super cool. Let's see. So all the stuff we talked about is really good for putting pictures on a screen, right?

40:16 But there's the other part. I told you one of the things that I thought was hard about creating this type of stuff like simulators and games and whatnot is the pictures and the graphics and in 3D world, like the actual models, right? And understanding those.

40:32 But there's also more to it. There's physics, there's collisions, there's sounds, there's like editors and levels. Like, let's talk about some of those things. What comes in it? I know that there's some cool options for physics engines.

40:44 Yeah, basically, there's several levels. And as you progress, you can get more advanced. First off, there's a command just to see if one sprite collides with another sprite. That's the simplest. The second is I've got what's called a simple physics engine. And you can have one sprite. And it can have a velocity. And then you can have another list of sprites, which basically act as walls that you can't move through.

41:10 So it'll keep the player from moving through a wall, which is great for any sort of top down game where you've got a player or the enemies moving around as you don't want them moving through walls. There's a platformer one where it adds gravity to the mix. And it works reasonably well for side scrolling platformers. And it gives you the ability to jump.

41:33 The last PyCon, I had somebody add in the ability to support double jumps and triple jumps or however many you want to select.

41:40 Yeah.

41:41 And if you really want to go nuts, I've got example code. There's another library package called PyMonk, which adds full 2D physics to the whole thing.

41:52 I'm looking at it. It's pretty cool. Like the example has a little bike rolling into like a stack of bricks and the bricks all like, you know, obviously come apart and fall down like, well, like bricks would if you hit them.

42:03 Yeah, it's cool.

42:04 You can add springs and all sorts of things. And it is a really neat library to work with. It is not easy to get started with, particularly if you want to try to make a platformer out of 2D physics.

42:17 It's I spent a fair bit of time on that. I've got an example on the website, but it is not particularly easy.

42:23 Yeah. Yeah. But I guess that's like the pro version if you want to like really make a super legit realistic game.

42:29 Yes, precisely.

42:30 Yeah. So we talked about sprites and that sounds like that's basically built in. Arcade is 2D only, right? There's no 3D aspect.

42:37 Correct.

42:37 Any 3D you want to have, like you kind of have to simulate with like your sprites or scaling or something, right?

42:44 Yeah, you'd have to do like a 2.5 or isometric even is really kind of complex to do. And there's not really built. There's some built in support for drawing an isometric map, but figuring out where the walls are and movement.

42:58 Is a non-trivial problem that's not in the library right now.

43:02 Yeah, yeah, of course. So another type of game that seems like would be pretty appropriate. So you talked about the platformers. What about like side scrollers? Like I don't really care about it, but Flappy Bird or Angry Birds or something like that.

43:16 Yeah, I've had people do Angry Birds. I have people do Flappy Bird with my head. That was really weird when I got that program to grade.

43:26 I can imagine. Hold still, I got to take a picture of you. Why? Never mind.

43:29 They took it off the website. So yeah, I love my job in that basically for finals, I just sit here and go through and grade students video games. So it's pretty cool job to get. And yeah, sometimes you're kind of surprised with what they end up coming up with.

43:48 And Flappy Bird with my head was definitely one of them. But I've also had people do Minesweeper, Word Search Games, Sudoku.

43:56 Yeah, Minesweeper sounds fun. A Mastermind would be another simple and fun one.

44:00 Yeah, so they don't have to be necessarily what I consider sprite type games, but they could be more board games or puzzle games, that type of thing.

44:08 Yeah, sure. Okay, that sounds cool. Yeah, you probably don't need physics in Minesweeper, but still.

44:14 No, but it is an interesting aspect because it's a nice spot to show students recursion because a lot of students don't see where recursion is useful. And it is useful in the sweep feature of Minesweeper.

44:26 Right, of course. Yeah, it's like a tree sort of thing.

44:29 Yeah, you basically just recursively click around where they clicked and it works pretty well.

44:34 Okay, nice. So you run out of spots that are empty or whatever.

44:38 You can go.

44:38 Yeah, okay. So one thing that would be really nice, and I guess let's talk about the examples first and then I'll talk about this.

44:45 So something that surprised me a little bit, I saw some of the articles you had written, like I think the one about Asteroid Smasher, right?

44:54 Mm-hmm.

44:55 And on there, I saw that you can basically, once you pip install Arcade, it comes with a bunch of examples already.

45:02 And I can say like python-m arcade.examples.pick something like Asteroid Smasher.

45:08 And actually, if I go to the REPL and I import arcade.examples and say help arcade.examples, there's like 30 examples in there.

45:15 Actually, I think there's about 100 examples total on the example site on the documentation.

45:23 I need to sort of recount those.

45:25 But anyway, to me, the example, having examples to base learning off of was really important because a lot of the feedback I get from students that are out in the workforce are saying,

45:39 hey, I haven't had a chance to ever work with other and read other code.

45:45 That's a skill.

45:46 I've written my own code.

45:47 But when I get on the workforce, most of what my job is, is reading other people's code and making modifications to it.

45:53 Right.

45:53 And it's usually super complicated because it's been polished for three years.

45:57 Yeah, exactly.

45:58 And it's hard to read, right?

45:59 Yeah.

45:59 And this gives students a way of learning to read code.

46:05 Plus, I myself, quite frankly, just learn things better by seeing examples.

46:09 And there are certain people that learn better that way rather than having things presented to them in sort of a linear format.

46:17 And the examples, I've tried to come up with so many different examples so that all of the requests that I've gotten over time,

46:25 when people want to learn something, know how to do something, I create an example for it.

46:31 And a lot of my answers to emails anymore on like, how do you do this?

46:35 Are just, oh, look, here's an example on exactly how to do it.

46:38 Yeah.

46:39 Yeah.

46:40 That's a nice way to do it.

46:41 Yeah.

46:41 If there's not an example, then bang, now I got a new idea for an example.

46:45 Yeah.

46:45 So I'll just read through some of what you got when you do that help statement.

46:49 So you've got like Asteroid Smasher, which is basically asteroids.

46:52 It's pretty nice.

46:53 A limited version of that.

46:55 You've got drawing text.

46:56 You've got full screen example, which is pretty nice.

46:59 You've got some loops.

47:00 You've got like a particle stress.

47:02 Fireworks.

47:03 The fireworks one is kind of cute.

47:04 Bunch of stuff with Sprite.

47:06 Moving them around.

47:07 Sprite CSV map, which is cool.

47:10 And then rooms.

47:11 And yeah, there's a lot of stuff in there.

47:13 There's a Tetris.

47:14 Yeah.

47:14 The Tetris is actually one of the newer ones that I've got in there.

47:18 Also have some procedural generation showing how to generate mazes a couple different ways,

47:23 different rooms.

47:25 Some of the other items that I've really been working on is to also support basically using

47:32 a program called the Tiled Map Editor so that you can actually just design a level or a layout

47:39 in a different program visually and then load it up really easily in your own program.

47:43 Yeah, that's nice.

47:44 Is that that's working?

47:45 And is that like, is that all?

47:47 What is that other program people use?

47:48 The Tiled Map Editor.

47:50 It is a really nice program that is used actually by a lot of different languages, but it creates

47:58 a TMX file and tile sets so that you can take regularly sized tiles.

48:03 You can visually lay them out as a lot of different options that way.

48:06 You can even animate tiles.

48:08 And then I've got an older version of loading those tiles function that does that.

48:16 And we're actually creating a new, more powerful version of that.

48:21 You can basically animate the tiles.

48:24 It'll automatically do the animations.

48:26 You can draw hit boxes around tiles.

48:29 So not every tile you just assume is a rectangle that you hit, but you might have a ramp or like

48:36 a coin.

48:36 You're going to have a circle for a hit box.

48:40 And you can just draw that in the Tiled Map Editor.

48:43 And then you can import it with just a few commands in the arcade library.

48:49 That is cool.

48:50 Yeah, I found it at mapeditor.org.

48:52 And it's a cute C++ app on open source on GitHub.

48:56 And yeah, it looks really nice, actually.

48:59 Yeah, it's a nice alternative to if you want to do 2D games, you could pair that with a, you

49:09 know, with Python and arcade and run through quite a few different levels and code that way.

49:15 Yeah, that's interesting.

49:16 And there's an example of loading the output from this thing.

49:19 Which is that example?

49:20 Example of loading what?

49:22 Of loading the output from the Tiled Map Editor.

49:25 Oh, right.

49:25 So basically, I've got one example for that for loading for the Tiled Map Editor.

49:29 And then I also did a whole presentation on basically doing that.

49:35 Basically, if you go to arcade.academy at the front of that website, it's got a tutorial that

49:41 leads you from just the beginning.

49:43 It's a platformer tutorial.

49:45 It leads you just from the beginning of opening the window, adding sprites, and then eventually

49:49 using the map editor to lay out the sprites.

49:52 And in the next version of arcade, it'll actually have an updated version that'll support animation,

50:00 have a better support for hitboxes, and other, some of the more advanced features of the Tiled

50:05 Map Editor.

50:06 That's super cool.

50:07 Yeah, the one that I found was Sprite Tiled Maps.

50:10 Yes, that map, singular.

50:12 That's it.

50:13 That's really nice.

50:14 Because like I was saying, like, that's one of the parts of like, hey, I built this thing

50:18 that shows stuff on the screen, and it draws these sprites.

50:21 Wait, how do I create levels?

50:24 How do I create graphics?

50:24 Like, all that stuff is just, you know, it seems like it's not going to be a problem maybe

50:29 at first, but it really is.

50:30 Yeah.

50:30 And if you want to do the visual layout and not program exactly where every block goes,

50:35 having some sort of graphical editor, and the Tiled Map Editor is just beautiful for it.

50:39 It really is.

50:40 The guys put a ton of work into it.

50:42 And you do not have to do a whole lot of work to load that using the arcade library.

50:48 Yeah, that's really great.

50:49 Definitely think that's super valuable to have.

50:51 You know, one thing that I was thinking while you're talking, it probably doesn't exist.

50:56 It might be cool if it were to exist.

50:58 Maybe somebody out there could create it if they wanted.

51:00 So we talked about the sprites over on kinney.nl.

51:04 We talked about the Tiled Map Editor.

51:05 It would be fun if there was, like, some starter, sort of getting started, like, a little library.

51:13 So you can just pip install it, and you've got, you know, like, 500 sprites that you can work with

51:20 and, like, 10 levels that are already built that you can just, like, okay, I'm going to just start from this

51:25 and go, you know, like, import this level and run with it.

51:28 And you hear some sounds or, like, these little building blocks for people to, like, sort of quick start up with them.

51:35 Does anything like that exist?

51:36 Not that I am aware of, but that would actually be a really great idea.

51:40 Yeah.

51:41 So instead of having to, like, start from scratch, you know, you're kind of like, well, these are, like, the 500 sprites.

51:46 If you pip install this thing, you just have it, you know, and you could go from there.

51:50 That'd be cool.

51:51 Yeah, it would.

51:52 And then eventually, if you're into creating the art yourself, once you've got your placeholder art in there,

51:57 you can get the mechanics of the game going and then just start replacing the art, like, piece by piece.

52:03 Yeah, because it seems like the art is, like, the last thing that you want to put your energy into, you know?

52:07 Right, because until you get the basic mechanics down, you don't really know what art you need or if the art is going to match what you actually need for mechanics.

52:18 Exactly.

52:18 Or even if the game idea, the way you first thought of it makes any sense.

52:22 Like, if you could play around with, like, some little sample data and they go, oh, actually, really, that's close.

52:26 But this is really what I wanted.

52:27 Like, you don't want to spend a ton of time on art for that, right, to get it up and running.

52:31 Exactly.

52:31 Anyway, that would be cool.

52:33 Maybe somebody out there is inspired to create that.

52:37 That'd be great.

52:37 I'd love to see something like that.

52:39 Yeah, cool.

52:39 So I guess we can maybe round out our conversation here by, like, assuming we've built this beautiful game.

52:45 It's like a cool side-scroller, whatever, Angry Birds, who knows what it is.

52:51 We want to send it out to the world, put it in the Mac App Store, put it in the Windows Store, who knows?

52:56 Something like this.

52:57 One of the challenges of Python is shipping your program to other people who maybe don't have Python installed or the right dependencies or things like that, right?

53:07 Yeah, it is difficult, and I don't have a perfect answer for that, quite frankly.

53:14 The aspect of the sound libraries and the little libraries that go with the arcade library, it's difficult to package and get that packaging to work well.

53:27 Python itself doesn't have a whole lot of great options.

53:30 There's the whole PyB project.

53:33 There's PyInstaller.

53:34 You've got, like, PyOxidizer and some other packages.

53:37 I would love to see something good and straightforward for being able to package games that you've put together using Arcade.

53:45 I'm not there yet.

53:47 Or I can recommend a specific option.

53:50 That's been one of the spots that I'd love to see Python as a language have some improvements on.

53:55 I definitely see it as one of the shortcomings.

53:58 It's great to see the PyOxidizer is coming along, right?

54:01 This is the newest of the packaging tools.

54:04 And I think it does take other libraries along with it.

54:08 I'm not entirely sure.

54:09 It certainly takes, like, the other Python libraries.

54:10 But, like, FFmpeg, for example.

54:12 Does it take, you know, that, right?

54:14 That I'm not sure about.

54:15 But I think if you could package your Python code and its dependencies as a binary, you could use the other packaging mechanisms to solve the other dependencies, right?

54:26 Like, in Windows, you have MSI installers that take along the other dependencies and will put them in the same directory.

54:32 Or you could have, like, your .app file on Mac.

54:34 You know, you just put it into a disk image and, like, drag it over, right?

54:37 Like, that's basically a directory.

54:39 I suspect you could make it work like that.

54:41 I'd love to get to a spot where somebody who's learning to program or is more on the hobbyist side doesn't have to spend so much time trying to figure out all these different packagers.

54:52 And there can just be one simple option for them to create an installer and have that run on a particular platform.

55:00 Because it's pretty cool to learn how to program and then you get done with learning how to program in college or high school or whatnot.

55:08 And you want to take your game and show it off to your friends.

55:10 But then you can only run it on one computer.

55:15 Yeah, exactly.

55:16 It's super frustrating.

55:17 I mean, my dream of the future would be something like I go to the command line.

55:23 I type Python 3-m package or bundle or something in a directory.

55:31 And then I get three outputs.

55:33 Linux, Windows, Mac.

55:35 Yes.

55:36 And there's a .exe.

55:38 There's a .app.

55:39 And there's a Linux binary.

55:40 And that's it.

55:42 It just runs.

55:43 Yes.

55:43 Yes.

55:44 I would love to see something like that.

55:45 We're not in that world.

55:46 Maybe that's 2022.

55:48 I don't know when that world exists, but I would love for it to exist.

55:51 And then, you know, I think that would really make a big difference, especially on things like this.

55:56 Yeah.

55:56 For me on the Arcade Library, this is a big hang up.

55:59 The sound support is another one that I get a lot of headaches on and trying to make sure I do support.

56:07 Yeah.

56:07 We haven't talked about sound yet.

56:08 So can we have sound?

56:10 How does that work?

56:10 Yeah, you can have sound.

56:12 It's basically, it's one that I keep trying to change.

56:16 And I always end up finding somebody that has some different configuration that it doesn't work well with.

56:21 Right now, I'm using FFmpeg.

56:24 Pygame uses AVbin, which is like a really old binary library that hasn't been updated in, I don't know, since like 2008 or something.

56:34 I can't remember, but nobody supports it anymore.

56:36 And so I tried to work with FFmpeg.

56:39 But then with Windows, you need it installed somewhere.

56:42 So you have to have the binary installed and downloaded.

56:46 And Mac's a little bit different.

56:49 With Linux, it should already be installed.

56:51 So somehow you need to find it on Linux and then create a link to it.

56:56 But you can't really directly create a link because then you get permissioning errors.

57:00 You have to remember where the heck that is.

57:01 At any rate, sound is a headache.

57:04 And it's very, it's very kludgy right now.

57:08 And I'm constantly trying to fine tune or find little exceptions where it's breaking down.

57:13 But you can play MP3s and OGGs and WAV files.

57:18 I generally push people to do WAV files for shorter sound effects.

57:22 I would love better sound to port.

57:24 So you could easily create a backing track of music to your game.

57:28 And then when the song is done, you could get a callback and queue up the next song.

57:34 Stuff like that really should be a lot easier than it is.

57:37 But that's one of my top headaches, that and distribution.

57:41 Okay.

57:42 Well, people have ideas.

57:44 I guess they can send them along.

57:45 I don't, for sound, I have no ideas.

57:46 I don't know anything about sound other than I agree that it's kind of tricky.

57:50 Yeah, I've had, I've looked into so many different libraries with that where people have suggested, oh, well, you should do this.

57:56 And, you know, I take a look at it and there's always some rhyme or reason where it doesn't work particularly well.

58:00 But I would love a solution for that by any means.

58:03 If anybody knows one, let me know, please.

58:07 Well, it sounds like you have at least basic support for sound, which is pretty critical.

58:11 Yes.

58:11 It makes it a lot more immersive.

58:13 Yeah, absolutely.

58:14 Maybe even more so than graphics, right?

58:16 Like there was a really interesting game on the iPad that was like this retro 8-bit game.

58:21 But it had brilliant music that was so immersive.

58:25 And actually, it was quite, quite interesting.

58:27 I forgot what it's called, but it was, it was fun to play.

58:30 And it was because of the music.

58:31 Yeah, I agree.

58:32 And I told my students the same thing.

58:34 It's, you got to get some sort of sound effects on there.

58:36 Yeah, for sure.

58:37 If you're jumping or you hit an enemy or the game over, it's just a lot better if there's a sound effect with it.

58:43 Mind you, as soon as I tell students how to do sounds, there is no shortage of flatulence coming out of the speakers in the labs that day.

58:51 Oh boy.

58:53 Do you have a good place for sound effects?

58:55 Like the audio equivalent of Kenny.nl?

58:58 Kenny.nl actually has some sound effects.

59:00 So I often ship that.

59:02 Open Game Art is another website that's pretty good for finding both art and sound effects.

59:08 A lot of sound effect websites ask you to download bad software to play sounds, however.

59:17 So I really have to caution students.

59:20 If they're going out and trying to find sound effects, that's a great way to find malware.

59:24 Yeah.

59:25 Sound should never require an install.

59:27 Exactly.

59:28 And some sites that I used to like actually have sort of switched over to requiring some sort of install and therefore automatic.

59:38 Like steer clear of.

59:39 That is super shady.

59:40 That's crazy.

59:41 Yeah.

59:41 All right.

59:42 Well, I think we pretty much covered Arcade.

59:43 That sounds like a really nice project that you built and hopefully people get a chance to check it out.

59:48 All right.

59:49 Thank you very much for having me on.

59:50 Absolutely.

59:50 Before I let you out of here, though, there's two more questions to ask.

59:54 So if you're going to write some Python code, what editor do you use?

59:56 Oh, great question.

59:58 In order, I will typically do PyCharm first.

01:00:02 And I really like PyCharm.

01:00:04 Sublime would be number two for a quick editor to work with.

01:00:09 And then Vim if I'm on any sort of Linux type of environment.

01:00:15 Yeah.

01:00:16 All right.

01:00:16 Sounds like a good set to me.

01:00:18 And then notable PyPI package.

01:00:20 I'll go ahead and throw out there pip install arcade for you.

01:00:22 But like maybe something people don't necessarily know about, but you're like, well, this is really great.

01:00:27 People should know about X.

01:00:28 Oh, good question.

01:00:29 Other than standard packages, I do like Piglet as far as building stuff off of it for graphics.

01:00:38 If you want more of the underlying items, Modern GL, if you want to write your own OpenGL code,

01:00:44 Modern GL is a really pretty good package that's actively supported online as well.

01:00:50 Oh, that's interesting.

01:00:51 I've never used that.

01:00:52 So, yeah.

01:00:54 Yeah.

01:00:54 There's like a few different OpenGL packages.

01:00:58 Piglet's bindings I really like and Modern GL are my two favorites.

01:01:03 Okay.

01:01:04 Yeah.

01:01:04 Cool.

01:01:04 So, if you know the OpenGL API, like this is it, but in Python rather than C++.

01:01:10 Right.

01:01:11 Yeah.

01:01:11 Cool.

01:01:11 Okay.

01:01:11 Nice.

01:01:12 That's a good one.

01:01:12 Thanks.

01:01:13 Thanks.

01:01:13 See, this is the purpose of this little section because we all learn about these things that

01:01:17 we don't know.

01:01:18 All right.

01:01:19 So, final call to action.

01:01:20 People are excited with Arcade.

01:01:21 How do they get started?

01:01:22 How do they contribute?

01:01:23 Things like that.

01:01:24 There's a website, arcade.academy.

01:01:27 It's got links if you want to download, try it out.

01:01:30 If you want to contribute to it, which I would absolutely love, there's links on it to GitHub

01:01:37 and you can do pull requests.

01:01:39 There's a Discord available too.

01:01:41 If you want to shoot me an email, I can get you hooked up with the Discord for the development

01:01:46 on that.

01:01:46 If you're learning to program, there's also learn.arcade.academy that has a whole curriculum

01:01:52 that I use for first semester programming.

01:01:56 And yeah, that's basically how to get started.

01:02:00 The learn.academy.

01:02:00 That's great.

01:02:01 It's got some, basically walks you through all the different things that you do for the

01:02:05 course, right?

01:02:05 Yeah.

01:02:06 Learn.arcade.academy.

01:02:08 Yep.

01:02:09 I'll put it in the show notes.

01:02:10 People can click it.

01:02:11 There we go.

01:02:12 All right.

01:02:13 Well, thank you so much for being here.

01:02:14 It's great to chat with you.

01:02:15 Yes.

01:02:15 Thank you very much.

01:02:16 You bet.

01:02:17 Bye.

01:02:17 This has been another episode of Talk Python to Me.

01:02:20 Our guest on this episode was Paul Craven, and it's been brought to you by Indeed and Rollbar.

01:02:25 With Indeed Prime, one application puts you in front of hundreds of companies like PayPal

01:02:31 and VRBO in over 90 cities.

01:02:33 Get started at talkpython.fm/Indeed.

01:02:36 Rollbar takes the pain out of errors.

01:02:39 They give you the context and insight you need to quickly locate and fix errors that might have

01:02:44 gone unnoticed until users complain, of course.

01:02:47 Track a ridiculous number of errors for free as Talk Python to Me listeners at talkpython.fm

01:02:52 slash rollbar.

01:02:53 Want to level up your Python?

01:02:56 If you're just getting started, try my Python Jumpstart by Building 10 Apps course.

01:03:00 Or if you're looking for something more advanced, check out our new async course that digs into

01:03:06 all the different types of async programming you can do in Python.

01:03:09 And of course, if you're interested in more than one of these, be sure to check out our

01:03:13 Everything Bundle.

01:03:13 It's like a subscription that never expires.

01:03:15 Be sure to subscribe to the show.

01:03:17 Open your favorite podcatcher and search for Python.

01:03:20 We should be right at the top.

01:03:21 You can also find the iTunes feed at /itunes, the Google Play feed at /play,

01:03:26 and the direct RSS feed at /rss on talkpython.fm.

01:03:30 This is your host, Michael Kennedy.

01:03:32 Thanks so much for listening.

01:03:34 I really appreciate it.

01:03:35 Now get out there and write some Python code.

01:03:37 I'll see you next time.

01:03:57 Thank you.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon