WEBVTT

00:00:00.001 --> 00:00:01.840
Have you tried to teach programming to beginners?

00:00:01.840 --> 00:00:05.220
Python is becoming a top choice for the language,

00:00:05.220 --> 00:00:08.300
but you still have to teach them how to work with the language

00:00:08.300 --> 00:00:11.800
and understand core concepts like loops, variables, classes, and more.

00:00:11.800 --> 00:00:16.840
It turns out video game programming, when kept simple, can be great for this.

00:00:16.840 --> 00:00:18.940
Do you need to repeat items in a scene?

00:00:18.940 --> 00:00:21.460
Well, there's a natural situation to introduce loops.

00:00:21.460 --> 00:00:23.320
How about move an item around?

00:00:23.320 --> 00:00:25.780
Maybe make a function to redraw it at a location.

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

00:00:31.160 --> 00:00:33.440
just for this purpose called Arcade.

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

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

00:00:41.340 --> 00:00:47.640
This is Talk Python To Me, episode 223, recorded July 25th, 2019.

00:00:47.640 --> 00:01:04.080
Welcome to Talk Python To Me, a weekly podcast on Python,

00:01:04.080 --> 00:01:07.140
the language, the libraries, the ecosystem, and the personalities.

00:01:07.140 --> 00:01:09.080
This is your host, Michael Kennedy.

00:01:09.080 --> 00:01:11.220
Follow me on Twitter, where I'm @mkennedy.

00:01:11.220 --> 00:01:14.960
Keep up with the show and listen to past episodes at talkpython.fm.

00:01:14.960 --> 00:01:17.460
and follow the show on Twitter via at talkpython.

00:01:17.460 --> 00:01:20.760
This episode is sponsored by Indeed and Rollbar.

00:01:20.760 --> 00:01:23.120
Please check out what they're offering during their segments.

00:01:23.120 --> 00:01:24.520
It really helps support the show.

00:01:24.520 --> 00:01:26.600
Paul, welcome to Talk Python.

00:01:26.600 --> 00:01:27.720
Hey, great to be here.

00:01:27.720 --> 00:01:28.640
Thanks for having me, Michael.

00:01:28.640 --> 00:01:30.040
Yeah, it's great to talk to you again.

00:01:30.040 --> 00:01:37.220
We got a chance to meet each other at the creator's booth part of the PyCharm booth at PyCon.

00:01:37.220 --> 00:01:37.660
That was fun.

00:01:37.660 --> 00:01:39.460
Yeah, I enjoy PyCon a lot.

00:01:39.460 --> 00:01:40.220
Yeah, so did I.

00:01:40.220 --> 00:01:41.400
I call it my geek holiday.

00:01:41.900 --> 00:01:49.420
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.

00:01:49.420 --> 00:01:49.900
It was great.

00:01:49.900 --> 00:01:53.300
Thankfully, it's the only conference I go to, and I look forward to it every year.

00:01:53.300 --> 00:01:54.260
Yeah, yeah, absolutely.

00:01:54.260 --> 00:02:04.560
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,

00:02:04.560 --> 00:02:09.460
but also just making gaming and Python more fun, this thing called Python Arcade.

00:02:09.460 --> 00:02:11.040
So I'm really looking forward to talking to you about that.

00:02:11.040 --> 00:02:14.100
Yeah, it's a project I'm really passionate about.

00:02:14.100 --> 00:02:14.980
Yeah, I can tell.

00:02:14.980 --> 00:02:17.380
So before we get to that, though, let's start with your story.

00:02:17.380 --> 00:02:19.100
How did you get into programming and then Python?

00:02:19.100 --> 00:02:20.500
Video games, actually.

00:02:20.500 --> 00:02:24.320
Long ago, I worked with an Apple IIe.

00:02:24.500 --> 00:02:30.780
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.

00:02:30.780 --> 00:02:35.340
So he said if I wanted to play games, I'd have to program them myself.

00:02:36.300 --> 00:02:43.680
And there's a few books out there by David All, more basic computer games and basic computer games.

00:02:43.680 --> 00:02:48.240
And they basically just had computer games in basic that you could type in.

00:02:48.240 --> 00:02:51.480
And I got started programming doing that.

00:02:51.480 --> 00:02:55.860
And once you had the game in there, you could start modifying it and customizing it the way you wanted.

00:02:55.860 --> 00:02:59.820
I just absolutely love that as a way of learning to program.

00:02:59.820 --> 00:03:08.520
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.

00:03:08.520 --> 00:03:11.020
Because it's not just me teaching them programming.

00:03:11.020 --> 00:03:13.920
If they only take one semester, it's only a limited use.

00:03:13.920 --> 00:03:24.980
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.

00:03:24.980 --> 00:03:25.760
Yeah, absolutely.

00:03:25.940 --> 00:03:29.660
I definitely think that that's an interesting angle to help people get more engaged.

00:03:29.660 --> 00:03:32.880
So that's basic was the sort of entry point.

00:03:32.880 --> 00:03:34.560
But where do you learn about Python?

00:03:34.560 --> 00:03:36.420
I had a student actually present it.

00:03:36.420 --> 00:03:42.940
We were teaching programming in Java, which is a terrible language to teach programming in.

00:03:42.940 --> 00:03:45.600
It was the main way to do it for most schools for a long time.

00:03:45.600 --> 00:03:47.820
Oh, it was a step backwards from like Pascal.

00:03:47.820 --> 00:03:50.740
And that's how we were teaching it.

00:03:50.740 --> 00:03:52.320
And he gave a presentation on Python.

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

00:03:57.640 --> 00:04:00.180
But his presentation was actually really good.

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

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

00:04:13.100 --> 00:04:16.680
So we started now it's pretty common to start teaching in Python.

00:04:16.680 --> 00:04:20.540
But when we started teaching in Python, it was not the common first language by any means.

00:04:20.540 --> 00:04:21.160
Yeah, absolutely.

00:04:21.160 --> 00:04:22.040
It was all about Java.

00:04:22.040 --> 00:04:22.800
When was this?

00:04:22.800 --> 00:04:23.580
What time?

00:04:23.580 --> 00:04:24.020
What year?

00:04:24.020 --> 00:04:24.820
About?

00:04:24.820 --> 00:04:26.840
I would guess it'd be about 11, 12 years ago now.

00:04:26.840 --> 00:04:27.180
Yeah.

00:04:27.180 --> 00:04:27.460
Okay.

00:04:27.460 --> 00:04:28.220
Interesting.

00:04:28.340 --> 00:04:33.280
So Python was not nearly as popular and clearly the right choice as it is today, I guess.

00:04:33.280 --> 00:04:33.640
Yeah.

00:04:33.640 --> 00:04:34.560
No, not at all.

00:04:34.560 --> 00:04:40.960
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.

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

00:04:46.320 --> 00:04:48.240
So our first semester is Python.

00:04:48.240 --> 00:04:54.760
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.

00:04:54.760 --> 00:04:55.940
There you go.

00:04:55.940 --> 00:04:56.580
They're already committed.

00:04:57.060 --> 00:05:09.140
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.

00:05:09.140 --> 00:05:13.940
I think it's taught with an expectation of extreme delayed gratification.

00:05:13.940 --> 00:05:18.420
I've talked about this before, but basically like we're going to teach you loops.

00:05:18.420 --> 00:05:19.440
We're going to teach you variables.

00:05:19.440 --> 00:05:20.420
We're going to teach you memory.

00:05:20.420 --> 00:05:21.400
We're going to teach you the heap.

00:05:21.400 --> 00:05:22.380
We're going to teach you pointers.

00:05:22.380 --> 00:05:23.560
We're going to teach you all these things.

00:05:24.780 --> 00:05:29.120
So maybe at the end of the semester, you can do something sort of interesting, maybe.

00:05:29.120 --> 00:05:33.820
But you might have to wait a couple of courses after that before you actually build something that you care about.

00:05:33.820 --> 00:05:36.140
And that's just, it's crazy.

00:05:36.140 --> 00:05:37.620
It's not just delayed gratification.

00:05:37.620 --> 00:05:38.700
It's delayed explanation.

00:05:38.700 --> 00:05:41.460
Public, static, void, main, string, args.

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

00:05:46.400 --> 00:05:50.600
Just type this in and we'll explain maybe sometime later in the semester how it works.

00:05:50.600 --> 00:05:51.920
That's not how I want to do it.

00:05:51.920 --> 00:05:54.300
I want them to understand exactly what they're doing.

00:05:54.300 --> 00:05:55.060
Yeah, exactly.

00:05:55.060 --> 00:06:00.400
So I definitely like that you're starting with something that gets them to like these short little wins quicker.

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

00:06:04.980 --> 00:06:11.100
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.

00:06:11.100 --> 00:06:11.580
Right.

00:06:11.580 --> 00:06:12.560
That's exactly it.

00:06:12.560 --> 00:06:16.380
It does assume that they'll like arcade games.

00:06:16.500 --> 00:06:23.220
But a lot of my students aren't as interested in spreadsheets and are a lot more interested in arcade games.

00:06:23.220 --> 00:06:25.440
So I can hook a fair percentage of them.

00:06:25.440 --> 00:06:34.960
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?

00:06:34.960 --> 00:06:41.360
Like lists or data structures or loops or whatever, right?

00:06:41.360 --> 00:06:45.020
And it's one thing to just do that in like a terminal app or something like that.

00:06:45.480 --> 00:06:54.020
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.

00:06:54.020 --> 00:06:54.340
Right.

00:06:54.340 --> 00:07:00.400
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.

00:07:00.400 --> 00:07:01.620
They don't really care.

00:07:01.620 --> 00:07:12.460
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.

00:07:12.460 --> 00:07:12.960
Right, right.

00:07:12.960 --> 00:07:14.680
If the horn points down, that's not okay.

00:07:15.180 --> 00:07:16.220
That's not okay.

00:07:16.220 --> 00:07:20.800
For the occasional student, they do want to just sort of give up at that point.

00:07:20.800 --> 00:07:28.420
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.

00:07:28.420 --> 00:07:33.340
Maybe give us some examples of the types of things that you're teaching them there with games.

00:07:33.560 --> 00:07:37.460
Well, to start off with, one of the first things we do is just create an image.

00:07:37.460 --> 00:07:45.520
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.

00:07:45.520 --> 00:07:47.900
So you learn about how to call a function.

00:07:47.900 --> 00:07:51.740
And even just by calling a function, I don't have to have them create classes.

00:07:51.920 --> 00:07:53.720
I don't have to have them create functions.

00:07:53.720 --> 00:07:56.120
All they have to do are simple calls.

00:07:56.260 --> 00:08:01.060
And then they can actually build on that to create an image.

00:08:01.060 --> 00:08:03.480
And then that introduces them to the coordinate system.

00:08:03.480 --> 00:08:18.160
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.

00:08:18.160 --> 00:08:19.200
Let's introduce loops.

00:08:19.420 --> 00:08:19.820
Exactly.

00:08:19.820 --> 00:08:23.900
Yeah, because it's really painful to write 50 little fence objects and move them around.

00:08:23.900 --> 00:08:24.320
Exactly.

00:08:24.320 --> 00:08:26.860
And it's very iterative.

00:08:26.860 --> 00:08:32.300
And they can see the value in picking up that, hey, I need to learn about loops.

00:08:32.300 --> 00:08:37.500
Hey, oh, if I create a function, then I can create a function that'll draw a snowman.

00:08:37.500 --> 00:08:44.040
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.

00:08:44.040 --> 00:08:44.580
Yeah, sure.

00:08:44.580 --> 00:08:50.800
I do like that you can start in this really simple mode, kind of like the print of the world side of things.

00:08:50.800 --> 00:08:55.560
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.

00:08:55.560 --> 00:09:01.980
But maybe before we really dig into even to arcade, let's just kind of set the landscape for everybody.

00:09:01.980 --> 00:09:06.020
You know, not everybody is creating games or maybe more like me.

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

00:09:10.400 --> 00:09:10.720
Right.

00:09:10.720 --> 00:09:13.520
So what are some of the options for building games?

00:09:13.720 --> 00:09:15.920
You know, what's the spectrum of what we could do?

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

00:09:23.080 --> 00:09:28.060
It's a very slow way of doing graphics, but it's the original way a lot of people have done graphics.

00:09:28.060 --> 00:09:33.480
Then there are a lot of libraries out there or APIs for like OpenGL, which is really big.

00:09:33.480 --> 00:09:36.740
DirectX, which is OpenGL is cross-platform.

00:09:36.740 --> 00:09:39.240
DirectX is very much Windows.

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

00:09:46.680 --> 00:09:48.820
So they have all these different APIs.

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

00:09:56.000 --> 00:09:59.160
You got the Unreal, Unity, GoDot.

00:09:59.160 --> 00:10:08.740
There's several game engines that do that and take care of some of the underlying work for you in those OpenGL DirectX metal.

00:10:08.740 --> 00:10:08.960
Yeah.

00:10:08.960 --> 00:10:11.680
And a lot of times that means working like in C++, right?

00:10:11.680 --> 00:10:16.740
Like with Unreal or some of those other real game engines or Unity is C# or things like that, right?

00:10:16.740 --> 00:10:17.160
Right.

00:10:17.160 --> 00:10:18.840
Unity can do like C# or JavaScript.

00:10:18.840 --> 00:10:20.420
GoDot's fairly popular.

00:10:20.560 --> 00:10:24.840
It's a lot more of a friendly type of language, but it's not Python.

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

00:10:32.720 --> 00:10:45.600
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.

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

00:10:52.120 --> 00:11:00.080
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.

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

00:11:05.320 --> 00:11:06.680
Not necessarily friendly either.

00:11:06.680 --> 00:11:08.260
No, no, no, not so much.

00:11:08.260 --> 00:11:10.760
So in the Python world, I had heard of Pygame.

00:11:10.760 --> 00:11:12.380
That's been around for quite a while.

00:11:12.380 --> 00:11:17.640
I heard of Pygame Zero, which I didn't really know how that was different than Pygame until recently.

00:11:17.640 --> 00:11:18.960
What else is there?

00:11:18.960 --> 00:11:20.320
Obviously, there's Arcade as well.

00:11:20.320 --> 00:11:25.420
Yeah, Piglet, a few other ones, Coco's or 2D, I think.

00:11:25.420 --> 00:11:28.780
And Pygame by far is the most popular one.

00:11:28.780 --> 00:11:29.900
And I taught using it.

00:11:29.900 --> 00:11:34.500
In fact, even wrote a book on developing arcade games in Pygame.

00:11:34.500 --> 00:11:41.240
And I really like Pygame, but it has been around a very long time.

00:11:41.240 --> 00:11:46.740
So it kept a lot of backwards compatibility on Python.

00:11:46.740 --> 00:11:49.720
So it didn't use any of the new Python 3 features.

00:11:49.720 --> 00:11:55.200
And the maintenance on Pygame at the time had completely fallen off.

00:11:55.200 --> 00:12:02.120
So where I would try to make improvements and do pull requests, absolutely nobody was doing anything with that.

00:12:02.120 --> 00:12:08.460
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.

00:12:08.460 --> 00:12:11.880
You go so far as like actually creating a pull request and submitting it.

00:12:11.880 --> 00:12:16.040
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.

00:12:16.040 --> 00:12:20.400
But if it just goes unaddressed, like that is really not the best feeling.

00:12:20.400 --> 00:12:20.820
Yeah.

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

00:12:27.760 --> 00:12:32.140
And I actually just try to do my own development because you could always create your own branch.

00:12:32.140 --> 00:12:37.880
But Pygame was developed off of an old library called SDL, a C++ library.

00:12:37.880 --> 00:12:42.200
And that library itself was pretty old.

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

00:12:47.960 --> 00:12:55.720
The underpinnings on Pygame, just if you wanted to keep the backwards compatibility and update everything,

00:12:55.720 --> 00:13:03.040
it just didn't seem to me to be a really worthwhile effort, particularly when there weren't maintainers at the time.

00:13:03.040 --> 00:13:06.100
It's actually started to pick up on maintenance now, which is great.

00:13:06.520 --> 00:13:08.620
But I wanted something better.

00:13:08.620 --> 00:13:13.180
And I thought, gosh, since most of the people that I work with are starting from scratch,

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

00:13:23.180 --> 00:13:23.420
Yeah.

00:13:23.420 --> 00:13:29.780
And you get all the benefits of like high end modern graphics cards, graphics, GPU accelerated stuff and all that.

00:13:29.780 --> 00:13:30.000
Right.

00:13:30.120 --> 00:13:30.380
Yeah.

00:13:30.380 --> 00:13:32.480
And I taught a long time using Pygame.

00:13:32.480 --> 00:13:34.300
So I found a lot of things.

00:13:34.300 --> 00:13:36.240
And there's a lot of things about Pygame I really like.

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

00:13:43.900 --> 00:13:47.400
do the bugs that my students always complained about.

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

00:13:51.540 --> 00:13:56.660
And every hour you spend telling a student, oh, well, that coordinate system that you learned,

00:13:56.660 --> 00:14:01.540
well, it's different in computers because zero zero is in the upper left instead of the lower left.

00:14:01.540 --> 00:14:07.540
Or set mode is in order to open a window, you use a command called set mode.

00:14:07.540 --> 00:14:10.580
I know it's called set mode, but you really don't want me to get into that.

00:14:10.580 --> 00:14:14.600
And, oh, you want to make a football and rotating ellipse?

00:14:14.600 --> 00:14:15.980
Yeah, sorry, you can't do that.

00:14:15.980 --> 00:14:19.860
You start getting over these and you come up with a list of them over time.

00:14:19.860 --> 00:14:23.880
And it's just, gosh, I think I could do something better, quite frankly.

00:14:44.560 --> 00:15:04.260
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.

00:15:04.480 --> 00:15:10.800
So if filling out countless job applications isn't your thing, let top tech companies apply to you.

00:15:10.800 --> 00:15:15.260
Join Indeed Prime for free at talkpython.fm/Indeed.

00:15:15.260 --> 00:15:18.020
That's talkpython.fm/Indeed.

00:15:20.520 --> 00:15:22.060
So you set out to do that, right?

00:15:22.060 --> 00:15:25.240
Yeah, basically I set out to do that.

00:15:25.240 --> 00:15:30.040
A lot of false starts, a lot of attempts on different backends.

00:15:30.040 --> 00:15:35.660
And so I got a fair bit of time into figuring out exactly how I wanted to do it.

00:15:35.660 --> 00:15:38.260
So yeah, Arcade is built off of OpenGL.

00:15:38.260 --> 00:15:41.860
It also uses Piglet for doing the window management.

00:15:42.560 --> 00:15:45.420
Piglet is also a pretty good game engine.

00:15:45.420 --> 00:15:54.140
And it is not nearly as friendly as Arcade, but opens a lot more of the internals.

00:15:54.140 --> 00:15:59.760
So when a programmer is more willing to dive into the internals, Piglet's not a bad option.

00:15:59.760 --> 00:16:03.880
Is there like an escape hatch in your API to like drop down to those internals?

00:16:03.880 --> 00:16:05.780
Or is it like take it or leave it?

00:16:05.820 --> 00:16:09.920
I mean, you could just import the Piglet library and start doing work in the Piglet library.

00:16:09.920 --> 00:16:11.580
I wouldn't really call it an escape hatch.

00:16:11.580 --> 00:16:13.760
Yeah, just directly work it.

00:16:13.760 --> 00:16:15.320
Yeah, just start working with...

00:16:15.320 --> 00:16:17.840
Yeah, it's not really something separate.

00:16:17.840 --> 00:16:18.520
Yeah, okay.

00:16:18.520 --> 00:16:22.660
The Piglet has their own system for managing sprites, which we can talk about in a bit.

00:16:22.660 --> 00:16:28.580
I really just use them for doing OpenGL calls and Windows event management.

00:16:28.580 --> 00:16:31.860
Okay, so there's not like a deep integration, like multi-layer thing.

00:16:31.860 --> 00:16:34.200
It's more just like, just take what they built and go with that.

00:16:34.200 --> 00:16:34.560
Right.

00:16:34.700 --> 00:16:36.040
For the few things you need.

00:16:36.040 --> 00:16:36.380
Right.

00:16:36.380 --> 00:16:40.180
And some of the, like Pygame Zero and some of the other, there have been a lot of things

00:16:40.180 --> 00:16:42.160
that have been built on top of Pygame.

00:16:42.160 --> 00:16:48.080
I kind of wanted to try to avoid some of that because you get too many layers of abstraction

00:16:48.080 --> 00:16:51.020
and things just get kind of weird after a while.

00:16:51.020 --> 00:16:53.420
Yeah, there's always that leaky abstraction or...

00:16:53.420 --> 00:16:53.800
Exactly.

00:16:53.800 --> 00:16:56.820
That thing that should be easy to do, but it's actually really impossible to do

00:16:56.820 --> 00:16:58.580
because something in the middle.

00:16:58.580 --> 00:16:59.000
Yeah.

00:16:59.000 --> 00:16:59.480
Nice.

00:16:59.480 --> 00:17:03.580
So it sounds like another one of your focuses on building Arcade

00:17:03.580 --> 00:17:08.720
was to focus on making it like Python 3 native.

00:17:08.720 --> 00:17:09.360
Right.

00:17:09.360 --> 00:17:09.480
Right.

00:17:09.480 --> 00:17:16.020
The ability to do type hinting, just going ahead and using f-strings.

00:17:16.020 --> 00:17:22.140
Quite frankly, I really like the type hinting in particular because when I get students that

00:17:22.140 --> 00:17:29.720
work in PyCharm and they have those little linters that go with it, it helps a lot of students.

00:17:30.060 --> 00:17:33.280
And it's not something actually I thought that would help students as much as it really has.

00:17:33.280 --> 00:17:38.000
I've gotten a lot better code once they get those hinting features that are available.

00:17:38.000 --> 00:17:38.440
Right.

00:17:38.440 --> 00:17:40.960
We expected a number and you're passing a string.

00:17:40.960 --> 00:17:42.460
That's probably not okay.

00:17:42.460 --> 00:17:43.340
Something like this.

00:17:43.340 --> 00:17:43.540
Yeah.

00:17:43.540 --> 00:17:43.980
Right.

00:17:43.980 --> 00:17:44.560
Exactly.

00:17:45.240 --> 00:17:50.920
And it's just, I kind of started working with Python 3 to begin with just at the beginnings

00:17:50.920 --> 00:17:51.300
of it.

00:17:51.300 --> 00:17:55.620
So I just am more used to everything that's Python 3.

00:17:55.620 --> 00:17:58.620
And thankfully that's not really such the issue that it used to be.

00:17:58.620 --> 00:17:58.900
Yeah.

00:17:58.900 --> 00:18:04.980
I saw some articles about Arcade and some commenters saying, oh, I can't believe you're using F

00:18:04.980 --> 00:18:05.340
strings.

00:18:05.340 --> 00:18:07.100
This means I have to have Python 3.

00:18:07.100 --> 00:18:08.400
6 and I can't get that.

00:18:08.400 --> 00:18:09.220
How am I going to get that?

00:18:09.220 --> 00:18:10.940
You know, it's like, those are kind of going away.

00:18:10.940 --> 00:18:11.260
I think.

00:18:11.260 --> 00:18:13.200
It is a pain.

00:18:13.200 --> 00:18:15.400
I'm not going to make a lot.

00:18:15.400 --> 00:18:20.980
And well, I mean, until like a year ago, Ubuntu had 3.5 a year and a half.

00:18:20.980 --> 00:18:21.660
Not super long.

00:18:21.660 --> 00:18:21.820
Right.

00:18:21.820 --> 00:18:22.340
Like that's.

00:18:22.340 --> 00:18:22.600
Right.

00:18:22.600 --> 00:18:24.240
Even though 3.6 had been out for quite a while.

00:18:24.240 --> 00:18:27.900
It seems like Ubuntu seems to lag about, I don't know, a point version.

00:18:27.900 --> 00:18:28.320
Right.

00:18:28.320 --> 00:18:31.080
Like it's 3.6 now, but 3.7 is out.

00:18:31.080 --> 00:18:31.360
Yeah.

00:18:31.360 --> 00:18:35.940
I don't know their exact release schedule, but you know, that time is fixing this.

00:18:35.940 --> 00:18:36.200
Right.

00:18:36.200 --> 00:18:40.140
So I definitely think Python 3 is the right place to be for this and type hinting.

00:18:40.140 --> 00:18:41.160
It's super interesting.

00:18:41.160 --> 00:18:45.380
Do you do anything with it in terms of like changing behaviors or anything?

00:18:45.380 --> 00:18:45.840
Like that?

00:18:45.840 --> 00:18:48.720
Or is it just there to help students be more accurate?

00:18:48.720 --> 00:18:50.440
Really just help students be more accurate.

00:18:50.440 --> 00:18:56.040
One of the other things I've really liked is being in the classroom, customizing the exception

00:18:56.040 --> 00:18:56.540
messages.

00:18:56.540 --> 00:19:04.460
So as I get students that run into problems, having the exception and certain areas, I'll

00:19:04.460 --> 00:19:08.820
actually do a little bit of checking to make sure that they're actually passing in the right

00:19:08.820 --> 00:19:09.620
type of data.

00:19:09.620 --> 00:19:11.620
It slows things down if I do that too much.

00:19:12.040 --> 00:19:17.720
But where the most common mistakes are when you run a batch of 20 to 40 kids every single

00:19:17.720 --> 00:19:25.920
semester through using this, you really get a good idea of how to make the code library

00:19:25.920 --> 00:19:26.400
better.

00:19:26.400 --> 00:19:26.700
Yeah.

00:19:26.700 --> 00:19:30.560
Because you have a bunch of people that have no expectations of what to do correctly.

00:19:30.560 --> 00:19:35.080
So how do you help them fall into the pit of success and like make the most, the right

00:19:35.080 --> 00:19:36.680
thing, the most obvious thing and whatnot.

00:19:36.680 --> 00:19:37.020
Right.

00:19:37.020 --> 00:19:37.380
Right.

00:19:37.380 --> 00:19:42.060
It's one of the things I really like about in creating a library to iteratively be able

00:19:42.060 --> 00:19:45.520
to take people through the library and look over their shoulders while they're working

00:19:45.520 --> 00:19:49.060
on it is really valuable and improving that library.

00:19:49.060 --> 00:19:55.280
And the also having it out on the internet where people that you can't see give you feedback,

00:19:55.280 --> 00:19:59.460
having both of those different types of feedback is really quite nice.

00:19:59.460 --> 00:19:59.800
Yeah.

00:19:59.800 --> 00:20:00.580
That's super interesting.

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

00:20:05.220 --> 00:20:08.860
in and then like watch through mirrors and other ways of what they're doing.

00:20:08.860 --> 00:20:13.660
And in a sense, like that's, that's very, very rare for open source libraries, I would

00:20:13.660 --> 00:20:13.920
suspect.

00:20:13.920 --> 00:20:15.620
But in a sense, that's kind of what you're doing, right?

00:20:15.620 --> 00:20:18.620
Just because you're teaching and walking around in the classroom, right?

00:20:18.620 --> 00:20:19.080
Exactly.

00:20:19.080 --> 00:20:24.500
And one of the big features of this particular library is a large set of examples.

00:20:24.500 --> 00:20:29.840
And over the last 12, 13 years, I've been teaching with video games.

00:20:29.840 --> 00:20:33.840
I got this library of different things that students have asked for.

00:20:33.840 --> 00:20:36.640
And so I create all these different code samples and make sure.

00:20:36.640 --> 00:20:39.320
And that's one of the things that helped also in creating the arcade libraries.

00:20:39.320 --> 00:20:43.320
I had, I knew all these different types of things that people wanted to do and they wanted

00:20:43.320 --> 00:20:45.160
to create 2D arcade games.

00:20:45.160 --> 00:20:47.420
And I created the library.

00:20:47.420 --> 00:20:51.180
I needed to make sure that I supported all of those different items.

00:20:51.180 --> 00:20:54.400
And I had all that set of example code in Pygame.

00:20:54.400 --> 00:20:58.680
And then I basically had to make sure that I could do all of those same features in the

00:20:58.680 --> 00:20:59.460
arcade library.

00:20:59.460 --> 00:21:01.820
That is really handy to have all those examples.

00:21:01.820 --> 00:21:07.680
So I guess, you know, we probably haven't done a great job of just like defining exactly

00:21:07.680 --> 00:21:09.660
what arcade is and its point, right?

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

00:21:16.700 --> 00:21:18.040
Yeah, or top-down.

00:21:18.040 --> 00:21:20.700
But basically any type of 2D graphics.

00:21:21.360 --> 00:21:24.140
And that's what arcade is really made to do.

00:21:24.140 --> 00:21:28.440
And it's made to do it so that people can get up and going simply and easily.

00:21:28.440 --> 00:21:34.040
It's not supposed to be a huge overhead or mentally taxing library to use.

00:21:34.040 --> 00:21:34.280
Yeah.

00:21:34.280 --> 00:21:36.000
Could you create like a tower defense game?

00:21:36.000 --> 00:21:36.400
Yes.

00:21:36.400 --> 00:21:40.720
The best game that we've got actually that I am aware of that's been built in it is a

00:21:40.720 --> 00:21:43.800
tower defense game, which is a pretty crazy game actually.

00:21:43.800 --> 00:21:48.700
I've wasted way more hours of playing that than I would admit to my student that wrote it.

00:21:48.700 --> 00:21:49.580
Is it online?

00:21:49.580 --> 00:21:51.060
Is it something people can check out?

00:21:51.240 --> 00:21:53.320
Yeah, actually, it's called Great Skeleton War.

00:21:53.320 --> 00:22:02.060
And there's a link to the GitHub repository on the Arcade Academy website that hosts the

00:22:02.060 --> 00:22:02.720
Arcade library.

00:22:02.720 --> 00:22:04.580
Yeah, nice.

00:22:04.580 --> 00:22:04.860
Yeah.

00:22:04.860 --> 00:22:10.140
So no, it creates great top-down, side-scroller, animated.

00:22:10.140 --> 00:22:14.020
It is really oriented towards doing that type of work.

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

00:22:21.020 --> 00:22:23.860
Is there any option for mobile or it's just a three at the moment?

00:22:23.860 --> 00:22:24.920
No option for mobile.

00:22:25.180 --> 00:22:28.500
Basically, those are the three main platforms that are in use.

00:22:28.500 --> 00:22:28.760
Yeah.

00:22:28.760 --> 00:22:29.500
Okay, cool.

00:22:29.500 --> 00:22:33.900
I mean, that's a totally reasonable thing, given what you're building, but I just want to check.

00:22:33.900 --> 00:22:40.460
So maybe give us a quick example of what the API feels like to write like a super simple

00:22:40.460 --> 00:22:40.840
game.

00:22:41.140 --> 00:22:43.380
You've got like a nice little example.

00:22:43.380 --> 00:22:48.480
And you even talked about how it doesn't even have to have functions or classes or anything

00:22:48.480 --> 00:22:49.140
like that.

00:22:49.140 --> 00:22:49.560
Right.

00:22:49.820 --> 00:22:54.080
If you wanted to do something really straightforward and just draw something to the screen,

00:22:54.080 --> 00:22:56.460
it's pretty darn straightforward.

00:22:56.460 --> 00:22:59.620
First off, you import the Arcade library, obviously.

00:22:59.620 --> 00:23:03.760
And then in the Arcade library is an open window command.

00:23:03.760 --> 00:23:06.820
You just give it the dimensions of the window and a screen title.

00:23:06.820 --> 00:23:10.220
Then the next command you do is you set a background color.

00:23:10.220 --> 00:23:17.240
It has a set of colors you can choose from or you can specify in a red, green, blue format.

00:23:18.280 --> 00:23:22.920
And the next, basically as an outline, you've got a start render and a finish render command.

00:23:22.920 --> 00:23:27.540
All your drawing commands have to happen between start render and finish render.

00:23:27.540 --> 00:23:30.880
Does that map over to like GL swap buffer down below or something like that?

00:23:30.880 --> 00:23:31.160
Yeah.

00:23:31.160 --> 00:23:35.860
Start render basically clears the screen and then the finish render will actually swap the

00:23:35.860 --> 00:23:36.620
buffer in front.

00:23:36.620 --> 00:23:37.320
Okay, cool.

00:23:37.320 --> 00:23:42.200
Then you've got commands such as draw a circle, draw a circle, fill, draw a circle outline,

00:23:42.200 --> 00:23:44.360
draw in a rectangle, drawing an arc.

00:23:44.360 --> 00:23:46.160
You can put bitmaps on the screen.

00:23:46.760 --> 00:23:50.400
All of these commands are actually slow to run.

00:23:50.400 --> 00:23:55.320
If you really wanted something high performance, you need to actually batch up these commands

00:23:55.320 --> 00:23:56.880
and then run a draw command.

00:23:56.880 --> 00:24:00.600
But to get started, you don't have to do that or really worry about that.

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

00:24:06.820 --> 00:24:07.600
Right, right, right.

00:24:07.700 --> 00:24:11.960
Basically, yeah, you just import arcade, open a window, set a background, start render,

00:24:11.960 --> 00:24:16.980
finish render, pop a whole bunch of straightforward drawing commands in the middle of that.

00:24:16.980 --> 00:24:22.600
And that would be pretty darn close to a finished program, except the program would immediately

00:24:22.600 --> 00:24:24.740
end right after you did that.

00:24:24.840 --> 00:24:27.260
So the window would come up, flash on the screen and then go away.

00:24:27.260 --> 00:24:32.260
So you do need to do an arcade.run, which will basically hold the window open on the screen

00:24:32.260 --> 00:24:33.400
until you hit the close button.

00:24:33.400 --> 00:24:34.260
Yeah, okay, cool.

00:24:34.400 --> 00:24:42.400
And yeah, you can draw a happy face or some sort of simple type of item in like 20 lines,

00:24:42.400 --> 00:24:45.720
50 lines if you want to add a bunch of comments in appropriate blank space.

00:24:45.720 --> 00:24:46.460
Yeah, super nice.

00:24:46.460 --> 00:24:47.520
That sounds very straightforward.

00:24:47.520 --> 00:24:53.200
And like I had said, you could just put those commands straight into a .py file and then run

00:24:53.200 --> 00:24:53.560
it, right?

00:24:53.600 --> 00:24:57.920
You don't even need a function or a class or decorators or inheritance or any of that.

00:24:57.920 --> 00:25:01.180
So it's pretty approachable for people to get started with.

00:25:01.180 --> 00:25:01.680
Exactly.

00:25:01.680 --> 00:25:08.280
I usually have them create drawings like this and then move on to functions so that they learn

00:25:08.280 --> 00:25:14.640
to create functions that draw horses or pigs or whatever the heck that is they want to draw.

00:25:14.640 --> 00:25:16.420
And then they can put that into a function.

00:25:16.420 --> 00:25:20.560
And then that starts making more sense to them why they need functions.

00:25:20.560 --> 00:25:26.160
And then eventually we can start getting into classes and how to handle events.

00:25:26.160 --> 00:25:26.520
Yeah.

00:25:26.520 --> 00:25:29.380
I mean, this just sounds like a really fun way to get into programming.

00:25:29.380 --> 00:25:34.280
You know, when I was taught, I was like learning just basically data structures in Lisp.

00:25:34.280 --> 00:25:35.820
Yeah.

00:25:35.820 --> 00:25:38.140
And that was not as much fun.

00:25:38.140 --> 00:25:39.540
I got to tell you, it wasn't as much fun.

00:25:39.540 --> 00:25:44.740
Even if you're an experienced programmer, I prefer starting with really small, simple,

00:25:44.740 --> 00:25:46.000
straightforward programs.

00:25:46.000 --> 00:25:54.060
If I have to start with some new framework and it's going to be 50 files that are in

00:25:54.060 --> 00:26:00.060
XML and some other type of format, it's just a headache to get started and really figure out

00:26:00.060 --> 00:26:01.060
where to even begin.

00:26:01.060 --> 00:26:07.300
But if I can get started in a 20 line program, I can start iterating off of that and learn

00:26:07.300 --> 00:26:09.360
a framework a lot easier.

00:26:09.360 --> 00:26:13.180
I'm starting to use this term that Python is a full spectrum language.

00:26:13.180 --> 00:26:18.700
And what I mean by that is like, it's really appropriate for super beginner folks.

00:26:18.700 --> 00:26:20.960
Cause like this example, you don't even need functions.

00:26:20.960 --> 00:26:22.520
Like you don't even need to know what a function is.

00:26:22.520 --> 00:26:24.820
You just need to like write these commands and you're good.

00:26:24.820 --> 00:26:31.800
But it also has really rich concepts like classes and decorators and generators and whatnot.

00:26:31.800 --> 00:26:36.580
And it kind of grows all the way from like simple programs to Instagram or whatever.

00:26:36.580 --> 00:26:36.900
Right.

00:26:36.900 --> 00:26:40.800
I feel like your API kind of mirrors that a little bit, right?

00:26:40.800 --> 00:26:45.320
Like it has this super simple way where you can be productive with a very partial understanding

00:26:45.320 --> 00:26:46.220
of what's going on.

00:26:46.220 --> 00:26:51.540
But then you have richer types like windows classes and decorators and events that you can

00:26:51.540 --> 00:26:52.540
hook into and stuff.

00:26:52.540 --> 00:26:53.020
Exactly.

00:26:53.020 --> 00:26:59.340
Really what I was trying very hard with this particular package to be able to do for somebody

00:26:59.340 --> 00:27:04.640
to get up and going easily with it and not a lot of effort, but still have a lot of power

00:27:04.640 --> 00:27:06.560
if they want to take the time to do it.

00:27:06.560 --> 00:27:06.740
Yeah.

00:27:06.740 --> 00:27:11.120
It sounds like it's pretty good for teaching programming to people who are learning programming,

00:27:11.120 --> 00:27:12.560
but maybe even for like kids.

00:27:12.560 --> 00:27:14.660
I mean, a lot of times people teach them kids.

00:27:14.660 --> 00:27:19.260
I saw some nice articles on using Pygame Zero to teach kids programming and stuff like that.

00:27:19.260 --> 00:27:19.980
What are your thoughts on that?

00:27:20.080 --> 00:27:22.040
Yeah, I think they're all good options.

00:27:22.040 --> 00:27:27.460
Quite frankly, I like actually seeing a little bit of competition out in the landscape.

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

00:27:35.860 --> 00:27:42.700
and particularly in the whole open source type of movement, figure out, oh, is there a better

00:27:42.700 --> 00:27:43.920
way of doing this?

00:27:43.920 --> 00:27:49.020
And if there's only one solution, I think things can get kind of stagnant.

00:27:49.220 --> 00:27:53.540
So I think Pygame Zero and Pygame are still completely viable options.

00:27:53.540 --> 00:27:58.380
I mean, obviously, I'm biased towards my library because like, who wouldn't be?

00:27:58.380 --> 00:28:02.120
But I like seeing the competition out there.

00:28:02.120 --> 00:28:08.080
And I do speed performance comparisons with my library and the other libraries and also how

00:28:08.080 --> 00:28:09.360
clean the code looks.

00:28:09.820 --> 00:28:14.600
And that's a nice way for me to make sure that this library is good, right?

00:28:14.600 --> 00:28:14.980
Yeah.

00:28:14.980 --> 00:28:16.240
Frame rates?

00:28:16.240 --> 00:28:19.380
Like, what does it look like for a game on arcade?

00:28:19.600 --> 00:28:24.780
Most of the games that people put together are usually 60 frames per second.

00:28:24.860 --> 00:28:31.160
Basically, if you program it poorly, specifically, if you draw items individually, as opposed to

00:28:31.160 --> 00:28:37.680
lists, that's where people usually end up getting into problems having the frame rates drop below

00:28:37.680 --> 00:28:38.160
60.

00:28:38.160 --> 00:28:40.140
Arcade uses OpenGL.

00:28:40.460 --> 00:28:46.260
So basically, as long as you load your sprites, your shapes, the items that you want into a list,

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

00:28:55.600 --> 00:28:57.260
still keep 60 frames per second.

00:28:57.260 --> 00:29:05.780
And I can get about 1,500 to 2,000 moving sprites on the screen at the same time.

00:29:05.780 --> 00:29:06.640
Yeah, that's pretty awesome.

00:29:06.640 --> 00:29:07.120
Yeah.

00:29:07.120 --> 00:29:10.200
If you include collision, it takes a little bit more time.

00:29:10.200 --> 00:29:15.920
So going really into the deep on which one's faster, which one's not, is really starting to

00:29:15.920 --> 00:29:20.720
get into the weeds, which I would absolutely love to do, but might not be what everybody wants to do

00:29:20.720 --> 00:29:21.140
right now.

00:29:21.140 --> 00:29:22.120
Yeah, yeah, for sure.

00:29:22.120 --> 00:29:26.060
But it's maybe the main takeaway is it's pretty quick, right?

00:29:26.060 --> 00:29:31.600
You definitely get like smooth frame rates and smooth behaviors and whatnot out of it these days

00:29:31.600 --> 00:29:32.480
using OpenGL.

00:29:32.480 --> 00:29:38.260
Yeah, I've got some speed comparisons comparing arcade to Pi game.

00:29:38.740 --> 00:29:44.400
And basically, when you keep adding sprites in the same list, particularly if they're not moving

00:29:44.400 --> 00:29:48.080
with OpenGL and arcade, you can keep doing that.

00:29:48.080 --> 00:29:50.540
And it's like an order one operation to draw it.

00:29:50.540 --> 00:29:52.080
You load them to the graphics card.

00:29:52.080 --> 00:29:55.760
Once they're on the graphics card, you just tell the graphics card to draw them and pow,

00:29:55.760 --> 00:29:56.580
they're back on screen.

00:29:56.580 --> 00:29:57.760
Yeah, that's super interesting.

00:29:57.760 --> 00:30:01.380
And I think that's one of the aspects of Python performance.

00:30:01.760 --> 00:30:07.000
that's really interesting to think about here, because you're not actually every time you

00:30:07.000 --> 00:30:09.400
say, here's a sprite and here are the things I want you to draw it.

00:30:09.400 --> 00:30:12.800
It's not like Python is doing all this computation to make it happen.

00:30:12.800 --> 00:30:17.720
It's kind of just like we've already loaded that stuff into the GPU memory.

00:30:17.720 --> 00:30:23.020
And we're just saying, hey, GPU, apply this transform to this thing over here or the set of

00:30:23.020 --> 00:30:26.180
transforms to those things or the whole viewport or whatever, right?

00:30:26.260 --> 00:30:30.560
Like it's sort of orchestrating what's happening with the scene, right?

00:30:30.560 --> 00:30:32.800
Rather than it's actually like drawing every little bit.

00:30:32.800 --> 00:30:33.240
Right.

00:30:33.240 --> 00:30:39.280
The graphics operations themselves are actually really quite fast and they're pretty well offloaded

00:30:39.280 --> 00:30:39.820
for Python.

00:30:39.820 --> 00:30:44.100
So the Python does the high level work and then offloads it onto the graphics card.

00:30:44.100 --> 00:30:48.640
And if you've done that right, then it doesn't matter quite so much what language you're working

00:30:48.640 --> 00:30:48.980
with.

00:30:49.220 --> 00:30:58.520
One of the items that I am working on right now is in actually moving the sprites and managing

00:30:58.520 --> 00:31:06.620
a large number of sprites, having them change where they are or detecting collisions between

00:31:06.620 --> 00:31:07.240
sprites.

00:31:07.240 --> 00:31:11.540
That is where you can see a bit of a speed difference.

00:31:11.540 --> 00:31:15.860
Pygame actually does pretty good with this because it is not pure Python.

00:31:15.860 --> 00:31:21.160
Python, it compiles a fair bit down to the C level and the different objects, the sprites

00:31:21.160 --> 00:31:26.260
that you've got on your screen are actually backed in the C program so they can do native

00:31:26.260 --> 00:31:27.920
manipulation that way pretty quick.

00:31:27.920 --> 00:31:35.940
And the arcade library doesn't do that, but I don't know if we'll end up doing that in the

00:31:35.940 --> 00:31:36.140
future.

00:31:36.140 --> 00:31:41.160
I've done a lot of experiments and there's a fair speed improvement if you offload some of

00:31:41.160 --> 00:31:42.540
that stuff to the C level.

00:31:42.540 --> 00:31:47.000
Yeah, I can imagine that there's like a handful of things that would really benefit from that.

00:31:47.000 --> 00:31:50.920
Have you considered or experimented with Cython or something like that?

00:31:50.920 --> 00:31:51.720
I've thought about it.

00:31:51.720 --> 00:31:53.700
I've not had a chance to experiment with it.

00:31:53.700 --> 00:31:56.920
Goes back to the whole limited amount of time in a day, unfortunately.

00:31:56.920 --> 00:32:02.540
Yeah, well, it could be a cool project for one of your more advanced students to tell them

00:32:02.540 --> 00:32:05.440
like, okay, in this course, you're going to optimize this.

00:32:05.440 --> 00:32:07.400
I'd be really interested to know what it would do.

00:32:07.400 --> 00:32:09.120
I've never tried running it under Cython.

00:32:09.320 --> 00:32:12.980
Yeah, I mean, not the whole thing necessarily, but just take like, you know, do some profiling

00:32:12.980 --> 00:32:17.280
and grab like the three slowest spots or whatever and just hit those functions with Cython, you

00:32:17.280 --> 00:32:17.880
know, for example.

00:32:17.880 --> 00:32:18.380
Right.

00:32:18.380 --> 00:32:23.760
This portion of Talk Python To Me is brought to you by Rollbar.

00:32:23.760 --> 00:32:25.160
Got a question for you.

00:32:25.160 --> 00:32:27.880
Have you been outsourcing your bug discovery to your users?

00:32:27.880 --> 00:32:30.520
Have you been making them send you bug reports?

00:32:30.520 --> 00:32:32.240
You know, there's two problems with that.

00:32:32.240 --> 00:32:34.220
You can't discover all the bugs this way.

00:32:34.220 --> 00:32:36.760
And some users don't bother reporting bugs at all.

00:32:36.760 --> 00:32:38.660
They just leave, sometimes forever.

00:32:38.660 --> 00:32:42.460
The best software teams practice proactive error monitoring.

00:32:42.460 --> 00:32:47.420
They detect all the errors in their production apps and services in real time and debug important

00:32:47.420 --> 00:32:50.860
errors in minutes or hours, sometimes before users even notice.

00:32:50.860 --> 00:32:55.940
Teams from companies like Twilio, Instacart, and CircleCI use Rollbar to do this.

00:32:55.940 --> 00:33:01.480
With Rollbar, you get a real-time feed of all the errors so you know exactly what's broken

00:33:01.480 --> 00:33:06.720
in production. And Rollbar automatically collects all the relevant data and metadata you need

00:33:06.720 --> 00:33:10.640
to debug the errors so you don't have to sift through logs. If you aren't using Rollbar yet,

00:33:10.640 --> 00:33:15.560
they have a special offer for you and it's really awesome. Sign up and install Rollbar at

00:33:15.560 --> 00:33:22.240
 talkpython.fm/Rollbar and Rollbar will send you a $100 gift card to use at the Open Collective

00:33:22.240 --> 00:33:27.500
where you can donate to any of the 900 plus projects listed under the Open Source Collective

00:33:27.500 --> 00:33:32.840
or to the Women Who Code organization. Get notified of errors in real time and make a difference in

00:33:32.840 --> 00:33:36.260
open source. Visit talkpython.fm/Rollbar today.

00:33:38.180 --> 00:33:42.240
Let's talk a little bit about the API just a little bit more before we move off of that.

00:33:42.240 --> 00:33:47.620
So on one end of the spectrum, we have like open window, set background color, render, render,

00:33:47.620 --> 00:33:53.100
render, done. Sort of not even a function. We talked about adding functions and classes,

00:33:53.100 --> 00:33:58.840
but maybe a more real application might create a class that derives from the arcade.window.

00:33:58.840 --> 00:34:04.020
And then it has all these events, right? Like an on draw, on key press, on mouse motion,

00:34:04.020 --> 00:34:07.680
viewport, all those kinds of things. You want to take us through like how that might look?

00:34:07.800 --> 00:34:11.540
Precisely. A little more advanced, not a lot more advanced, but a little more advanced

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

00:34:18.960 --> 00:34:27.200
of classic window classes in other APIs where you've got certain methods that you can override if you want

00:34:27.200 --> 00:34:37.420
to respond to keystrokes or button presses or window resizing. Any of that type of work can be done

00:34:37.420 --> 00:34:40.660
in your own custom window class.

00:34:40.660 --> 00:34:46.480
Yeah. One thing I like about that is it lets you avoid like writing the event loop and dealing with

00:34:46.480 --> 00:34:51.240
all of that funkiness that maybe some of the libraries have to deal with.

00:34:51.240 --> 00:34:55.520
Yeah. That's one of the things that Pygame does that I really don't like is that you basically have

00:34:55.520 --> 00:35:01.760
to create your own event loop, which is pretty, I don't know, 80s or 90s style anymore.

00:35:02.580 --> 00:35:10.680
And a lot of the libraries that build on top of Pygame or Pygame based try to hide that or they create

00:35:10.680 --> 00:35:15.640
their own event loop on top of it, which for obvious reasons, it's not the best way of doing it.

00:35:15.820 --> 00:35:32.400
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.

00:35:33.060 --> 00:35:34.060
Yeah.

00:35:34.060 --> 00:35:39.080
So you still basically plug into the event loop, like the keyboard events and the draw events and whatnot.

00:35:39.080 --> 00:35:39.660
Exactly.

00:35:39.660 --> 00:35:48.060
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.

00:35:48.300 --> 00:36:02.260
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.

00:36:02.260 --> 00:36:22.000
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?

00:36:22.000 --> 00:36:28.360
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.

00:36:28.360 --> 00:36:33.040
Yeah. It just kind of shows you the value of good graphic artists, quite frankly.

00:36:33.040 --> 00:36:33.520
Yeah.

00:36:33.520 --> 00:36:54.420
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.

00:36:55.020 --> 00:37:18.840
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.

00:37:19.060 --> 00:37:30.560
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.

00:37:30.560 --> 00:37:39.100
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.

00:37:39.100 --> 00:37:50.840
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.

00:37:50.840 --> 00:37:51.100
Yeah.

00:37:51.100 --> 00:38:01.280
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.

00:38:01.440 --> 00:38:12.820
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.

00:38:12.820 --> 00:38:20.780
That's also built into Arcade to basically allow them to resize that on the fly. The transparency is built in.

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

00:38:29.980 --> 00:38:35.220
Yeah, this is really cool. So like the Kenny and Elf stuff is really nice.

00:38:35.220 --> 00:38:47.660
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.

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

00:38:55.800 --> 00:39:03.080
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?

00:39:03.080 --> 00:39:17.500
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.

00:39:17.500 --> 00:39:47.480
To use the individual files.

00:39:47.480 --> 00:39:55.160
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.

00:39:55.160 --> 00:40:06.760
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.

00:40:06.960 --> 00:40:16.920
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?

00:40:16.920 --> 00:40:32.500
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.

00:40:32.880 --> 00:40:44.860
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.

00:40:44.860 --> 00:41:10.420
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.

00:41:10.640 --> 00:41:33.760
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.

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

00:41:40.900 --> 00:41:41.600
Yeah.

00:41:41.600 --> 00:41:52.220
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.

00:41:52.220 --> 00:42:03.840
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.

00:42:03.840 --> 00:42:04.500
Yeah, it's cool.

00:42:04.500 --> 00:42:17.400
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.

00:42:17.400 --> 00:42:23.040
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.

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

00:42:29.120 --> 00:42:30.040
Yes, precisely.

00:42:30.040 --> 00:42:37.320
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.

00:42:37.320 --> 00:42:37.840
Correct.

00:42:37.840 --> 00:42:44.060
Any 3D you want to have, like you kind of have to simulate with like your sprites or scaling or something, right?

00:42:44.060 --> 00:42:58.920
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.

00:42:58.920 --> 00:43:02.740
Is a non-trivial problem that's not in the library right now.

00:43:02.740 --> 00:43:16.320
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.

00:43:16.320 --> 00:43:24.020
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.

00:43:26.220 --> 00:43:29.440
I can imagine. Hold still, I got to take a picture of you. Why? Never mind.

00:43:29.440 --> 00:43:47.800
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.

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

00:43:56.440 --> 00:44:00.300
Yeah, Minesweeper sounds fun. A Mastermind would be another simple and fun one.

00:44:00.300 --> 00:44:08.720
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.

00:44:08.840 --> 00:44:14.500
Yeah, sure. Okay, that sounds cool. Yeah, you probably don't need physics in Minesweeper, but still.

00:44:14.500 --> 00:44:26.860
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.

00:44:26.860 --> 00:44:29.160
Right, of course. Yeah, it's like a tree sort of thing.

00:44:29.160 --> 00:44:34.800
Yeah, you basically just recursively click around where they clicked and it works pretty well.

00:44:34.800 --> 00:44:38.120
Okay, nice. So you run out of spots that are empty or whatever.

00:44:38.420 --> 00:44:38.660
You can go.

00:44:38.660 --> 00:44:45.180
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.

00:44:45.180 --> 00:44:54.760
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?

00:44:54.760 --> 00:44:55.100
Mm-hmm.

00:44:55.100 --> 00:45:01.440
And on there, I saw that you can basically, once you pip install Arcade, it comes with a bunch of examples already.

00:45:02.420 --> 00:45:08.280
And I can say like python-m arcade.examples.pick something like Asteroid Smasher.

00:45:08.280 --> 00:45:15.780
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.

00:45:15.900 --> 00:45:23.180
Actually, I think there's about 100 examples total on the example site on the documentation.

00:45:23.920 --> 00:45:25.780
I need to sort of recount those.

00:45:25.780 --> 00:45:38.740
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,

00:45:39.160 --> 00:45:45.160
hey, I haven't had a chance to ever work with other and read other code.

00:45:45.160 --> 00:45:46.300
That's a skill.

00:45:46.300 --> 00:45:47.400
I've written my own code.

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

00:45:53.140 --> 00:45:53.460
Right.

00:45:53.460 --> 00:45:57.040
And it's usually super complicated because it's been polished for three years.

00:45:57.040 --> 00:45:58.380
Yeah, exactly.

00:45:58.380 --> 00:45:59.480
And it's hard to read, right?

00:45:59.480 --> 00:45:59.740
Yeah.

00:45:59.860 --> 00:46:05.060
And this gives students a way of learning to read code.

00:46:05.060 --> 00:46:09.940
Plus, I myself, quite frankly, just learn things better by seeing examples.

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

00:46:17.000 --> 00:46:25.200
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,

00:46:25.720 --> 00:46:31.080
when people want to learn something, know how to do something, I create an example for it.

00:46:31.080 --> 00:46:35.980
And a lot of my answers to emails anymore on like, how do you do this?

00:46:35.980 --> 00:46:38.700
Are just, oh, look, here's an example on exactly how to do it.

00:46:38.700 --> 00:46:39.760
Yeah.

00:46:39.760 --> 00:46:40.080
Yeah.

00:46:40.080 --> 00:46:41.260
That's a nice way to do it.

00:46:41.260 --> 00:46:41.720
Yeah.

00:46:41.720 --> 00:46:45.520
If there's not an example, then bang, now I got a new idea for an example.

00:46:45.520 --> 00:46:45.840
Yeah.

00:46:45.840 --> 00:46:49.240
So I'll just read through some of what you got when you do that help statement.

00:46:49.240 --> 00:46:52.260
So you've got like Asteroid Smasher, which is basically asteroids.

00:46:52.260 --> 00:46:53.160
It's pretty nice.

00:46:53.160 --> 00:46:54.800
A limited version of that.

00:46:55.380 --> 00:46:56.580
You've got drawing text.

00:46:56.580 --> 00:46:59.540
You've got full screen example, which is pretty nice.

00:46:59.540 --> 00:47:00.720
You've got some loops.

00:47:00.720 --> 00:47:02.720
You've got like a particle stress.

00:47:02.720 --> 00:47:03.340
Fireworks.

00:47:03.340 --> 00:47:04.880
The fireworks one is kind of cute.

00:47:04.880 --> 00:47:06.360
Bunch of stuff with Sprite.

00:47:06.360 --> 00:47:07.840
Moving them around.

00:47:07.840 --> 00:47:10.720
Sprite CSV map, which is cool.

00:47:10.720 --> 00:47:11.580
And then rooms.

00:47:11.580 --> 00:47:13.320
And yeah, there's a lot of stuff in there.

00:47:13.320 --> 00:47:14.000
There's a Tetris.

00:47:14.000 --> 00:47:14.280
Yeah.

00:47:14.280 --> 00:47:18.520
The Tetris is actually one of the newer ones that I've got in there.

00:47:18.520 --> 00:47:23.980
Also have some procedural generation showing how to generate mazes a couple different ways,

00:47:23.980 --> 00:47:25.200
different rooms.

00:47:25.200 --> 00:47:32.280
Some of the other items that I've really been working on is to also support basically using

00:47:32.280 --> 00:47:39.440
a program called the Tiled Map Editor so that you can actually just design a level or a layout

00:47:39.440 --> 00:47:43.720
in a different program visually and then load it up really easily in your own program.

00:47:43.920 --> 00:47:44.580
Yeah, that's nice.

00:47:44.580 --> 00:47:45.580
Is that that's working?

00:47:45.580 --> 00:47:47.160
And is that like, is that all?

00:47:47.160 --> 00:47:48.860
What is that other program people use?

00:47:48.860 --> 00:47:50.060
The Tiled Map Editor.

00:47:50.600 --> 00:47:58.040
It is a really nice program that is used actually by a lot of different languages, but it creates

00:47:58.040 --> 00:48:03.140
a TMX file and tile sets so that you can take regularly sized tiles.

00:48:03.140 --> 00:48:06.540
You can visually lay them out as a lot of different options that way.

00:48:06.540 --> 00:48:08.380
You can even animate tiles.

00:48:08.380 --> 00:48:16.480
And then I've got an older version of loading those tiles function that does that.

00:48:16.480 --> 00:48:21.500
And we're actually creating a new, more powerful version of that.

00:48:21.500 --> 00:48:24.440
You can basically animate the tiles.

00:48:24.440 --> 00:48:26.020
It'll automatically do the animations.

00:48:26.020 --> 00:48:29.280
You can draw hit boxes around tiles.

00:48:29.280 --> 00:48:36.020
So not every tile you just assume is a rectangle that you hit, but you might have a ramp or like

00:48:36.020 --> 00:48:36.580
a coin.

00:48:36.580 --> 00:48:39.780
You're going to have a circle for a hit box.

00:48:40.320 --> 00:48:43.680
And you can just draw that in the Tiled Map Editor.

00:48:43.680 --> 00:48:49.880
And then you can import it with just a few commands in the arcade library.

00:48:49.880 --> 00:48:50.580
That is cool.

00:48:50.580 --> 00:48:52.520
Yeah, I found it at mapeditor.org.

00:48:52.520 --> 00:48:56.840
And it's a cute C++ app on open source on GitHub.

00:48:56.840 --> 00:48:59.280
And yeah, it looks really nice, actually.

00:48:59.580 --> 00:49:09.040
Yeah, it's a nice alternative to if you want to do 2D games, you could pair that with a, you

00:49:09.040 --> 00:49:15.500
know, with Python and arcade and run through quite a few different levels and code that way.

00:49:15.500 --> 00:49:16.400
Yeah, that's interesting.

00:49:16.400 --> 00:49:19.700
And there's an example of loading the output from this thing.

00:49:19.700 --> 00:49:20.840
Which is that example?

00:49:20.840 --> 00:49:22.000
Example of loading what?

00:49:22.000 --> 00:49:24.720
Of loading the output from the Tiled Map Editor.

00:49:25.060 --> 00:49:25.640
Oh, right.

00:49:25.640 --> 00:49:29.900
So basically, I've got one example for that for loading for the Tiled Map Editor.

00:49:29.900 --> 00:49:35.280
And then I also did a whole presentation on basically doing that.

00:49:35.280 --> 00:49:41.200
Basically, if you go to arcade.academy at the front of that website, it's got a tutorial that

00:49:41.200 --> 00:49:43.300
leads you from just the beginning.

00:49:43.300 --> 00:49:45.220
It's a platformer tutorial.

00:49:45.220 --> 00:49:49.000
It leads you just from the beginning of opening the window, adding sprites, and then eventually

00:49:49.000 --> 00:49:51.840
using the map editor to lay out the sprites.

00:49:52.800 --> 00:50:00.500
And in the next version of arcade, it'll actually have an updated version that'll support animation,

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

00:50:05.800 --> 00:50:06.340
Map Editor.

00:50:06.340 --> 00:50:07.120
That's super cool.

00:50:07.120 --> 00:50:10.800
Yeah, the one that I found was Sprite Tiled Maps.

00:50:10.800 --> 00:50:12.920
Yes, that map, singular.

00:50:12.920 --> 00:50:13.440
That's it.

00:50:13.440 --> 00:50:14.460
That's really nice.

00:50:14.460 --> 00:50:18.540
Because like I was saying, like, that's one of the parts of like, hey, I built this thing

00:50:18.540 --> 00:50:21.400
that shows stuff on the screen, and it draws these sprites.

00:50:21.740 --> 00:50:24.040
Wait, how do I create levels?

00:50:24.040 --> 00:50:24.880
How do I create graphics?

00:50:24.880 --> 00:50:29.080
Like, all that stuff is just, you know, it seems like it's not going to be a problem maybe

00:50:29.080 --> 00:50:30.440
at first, but it really is.

00:50:30.440 --> 00:50:30.800
Yeah.

00:50:30.800 --> 00:50:35.980
And if you want to do the visual layout and not program exactly where every block goes,

00:50:35.980 --> 00:50:39.940
having some sort of graphical editor, and the Tiled Map Editor is just beautiful for it.

00:50:39.940 --> 00:50:40.380
It really is.

00:50:40.380 --> 00:50:42.180
The guys put a ton of work into it.

00:50:42.560 --> 00:50:48.140
And you do not have to do a whole lot of work to load that using the arcade library.

00:50:48.140 --> 00:50:49.300
Yeah, that's really great.

00:50:49.300 --> 00:50:51.560
Definitely think that's super valuable to have.

00:50:51.560 --> 00:50:56.660
You know, one thing that I was thinking while you're talking, it probably doesn't exist.

00:50:56.660 --> 00:50:58.280
It might be cool if it were to exist.

00:50:58.280 --> 00:51:00.360
Maybe somebody out there could create it if they wanted.

00:51:00.900 --> 00:51:04.340
So we talked about the sprites over on kinney.nl.

00:51:04.340 --> 00:51:05.820
We talked about the Tiled Map Editor.

00:51:05.820 --> 00:51:13.400
It would be fun if there was, like, some starter, sort of getting started, like, a little library.

00:51:13.560 --> 00:51:20.040
So you can just pip install it, and you've got, you know, like, 500 sprites that you can work with

00:51:20.040 --> 00:51:25.040
and, like, 10 levels that are already built that you can just, like, okay, I'm going to just start from this

00:51:25.040 --> 00:51:28.700
and go, you know, like, import this level and run with it.

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

00:51:35.740 --> 00:51:36.980
Does anything like that exist?

00:51:36.980 --> 00:51:40.900
Not that I am aware of, but that would actually be a really great idea.

00:51:40.900 --> 00:51:41.640
Yeah.

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

00:51:46.920 --> 00:51:50.700
If you pip install this thing, you just have it, you know, and you could go from there.

00:51:50.700 --> 00:51:51.220
That'd be cool.

00:51:51.220 --> 00:51:52.100
Yeah, it would.

00:51:52.100 --> 00:51:57.920
And then eventually, if you're into creating the art yourself, once you've got your placeholder art in there,

00:51:57.920 --> 00:52:03.380
you can get the mechanics of the game going and then just start replacing the art, like, piece by piece.

00:52:03.380 --> 00:52:07.820
Yeah, because it seems like the art is, like, the last thing that you want to put your energy into, you know?

00:52:07.820 --> 00:52:18.460
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.

00:52:18.460 --> 00:52:18.960
Exactly.

00:52:18.960 --> 00:52:22.280
Or even if the game idea, the way you first thought of it makes any sense.

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

00:52:26.860 --> 00:52:27.960
But this is really what I wanted.

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

00:52:31.540 --> 00:52:31.940
Exactly.

00:52:31.940 --> 00:52:33.500
Anyway, that would be cool.

00:52:33.500 --> 00:52:37.420
Maybe somebody out there is inspired to create that.

00:52:37.420 --> 00:52:37.860
That'd be great.

00:52:37.860 --> 00:52:39.160
I'd love to see something like that.

00:52:39.160 --> 00:52:39.580
Yeah, cool.

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

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

00:52:51.240 --> 00:52:56.880
We want to send it out to the world, put it in the Mac App Store, put it in the Windows Store, who knows?

00:52:56.880 --> 00:52:57.700
Something like this.

00:52:57.700 --> 00:53:07.720
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?

00:53:07.880 --> 00:53:14.000
Yeah, it is difficult, and I don't have a perfect answer for that, quite frankly.

00:53:14.000 --> 00:53:27.280
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.

00:53:27.280 --> 00:53:30.680
Python itself doesn't have a whole lot of great options.

00:53:30.680 --> 00:53:33.180
There's the whole PyB project.

00:53:33.180 --> 00:53:34.500
There's PyInstaller.

00:53:34.500 --> 00:53:37.280
You've got, like, PyOxidizer and some other packages.

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

00:53:45.080 --> 00:53:47.280
I'm not there yet.

00:53:47.280 --> 00:53:50.760
Or I can recommend a specific option.

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

00:53:55.880 --> 00:53:58.240
I definitely see it as one of the shortcomings.

00:53:58.240 --> 00:54:01.180
It's great to see the PyOxidizer is coming along, right?

00:54:01.180 --> 00:54:04.920
This is the newest of the packaging tools.

00:54:04.920 --> 00:54:08.180
And I think it does take other libraries along with it.

00:54:08.180 --> 00:54:09.240
I'm not entirely sure.

00:54:09.240 --> 00:54:10.920
It certainly takes, like, the other Python libraries.

00:54:10.920 --> 00:54:12.620
But, like, FFmpeg, for example.

00:54:12.620 --> 00:54:14.720
Does it take, you know, that, right?

00:54:14.720 --> 00:54:15.660
That I'm not sure about.

00:54:15.660 --> 00:54:26.220
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?

00:54:26.220 --> 00:54:32.240
Like, in Windows, you have MSI installers that take along the other dependencies and will put them in the same directory.

00:54:32.240 --> 00:54:34.600
Or you could have, like, your .app file on Mac.

00:54:34.600 --> 00:54:37.940
You know, you just put it into a disk image and, like, drag it over, right?

00:54:37.940 --> 00:54:39.280
Like, that's basically a directory.

00:54:39.280 --> 00:54:41.000
I suspect you could make it work like that.

00:54:41.000 --> 00:54:52.200
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.

00:54:52.700 --> 00:55:00.940
And there can just be one simple option for them to create an installer and have that run on a particular platform.

00:55:00.940 --> 00:55:08.220
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.

00:55:08.220 --> 00:55:10.840
And you want to take your game and show it off to your friends.

00:55:10.840 --> 00:55:15.120
But then you can only run it on one computer.

00:55:15.120 --> 00:55:16.540
Yeah, exactly.

00:55:16.540 --> 00:55:17.620
It's super frustrating.

00:55:17.620 --> 00:55:23.700
I mean, my dream of the future would be something like I go to the command line.

00:55:23.700 --> 00:55:31.600
I type Python 3-m package or bundle or something in a directory.

00:55:31.600 --> 00:55:33.320
And then I get three outputs.

00:55:33.320 --> 00:55:35.460
Linux, Windows, Mac.

00:55:35.460 --> 00:55:36.380
Yes.

00:55:36.380 --> 00:55:38.080
And there's a .exe.

00:55:38.080 --> 00:55:39.100
There's a .app.

00:55:39.100 --> 00:55:40.580
And there's a Linux binary.

00:55:40.580 --> 00:55:42.240
And that's it.

00:55:42.240 --> 00:55:43.280
It just runs.

00:55:43.280 --> 00:55:43.540
Yes.

00:55:43.540 --> 00:55:44.300
Yes.

00:55:44.300 --> 00:55:45.240
I would love to see something like that.

00:55:45.240 --> 00:55:46.080
We're not in that world.

00:55:46.840 --> 00:55:48.040
Maybe that's 2022.

00:55:48.040 --> 00:55:51.340
I don't know when that world exists, but I would love for it to exist.

00:55:51.340 --> 00:55:56.020
And then, you know, I think that would really make a big difference, especially on things like this.

00:55:56.020 --> 00:55:56.360
Yeah.

00:55:56.360 --> 00:55:59.660
For me on the Arcade Library, this is a big hang up.

00:55:59.660 --> 00:56:07.680
The sound support is another one that I get a lot of headaches on and trying to make sure I do support.

00:56:07.680 --> 00:56:07.920
Yeah.

00:56:07.920 --> 00:56:08.860
We haven't talked about sound yet.

00:56:08.860 --> 00:56:10.000
So can we have sound?

00:56:10.000 --> 00:56:10.600
How does that work?

00:56:10.600 --> 00:56:12.120
Yeah, you can have sound.

00:56:12.120 --> 00:56:16.960
It's basically, it's one that I keep trying to change.

00:56:16.960 --> 00:56:21.880
And I always end up finding somebody that has some different configuration that it doesn't work well with.

00:56:21.880 --> 00:56:24.400
Right now, I'm using FFmpeg.

00:56:24.400 --> 00:56:34.440
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.

00:56:34.540 --> 00:56:36.900
I can't remember, but nobody supports it anymore.

00:56:36.900 --> 00:56:39.820
And so I tried to work with FFmpeg.

00:56:39.820 --> 00:56:42.700
But then with Windows, you need it installed somewhere.

00:56:42.700 --> 00:56:46.700
So you have to have the binary installed and downloaded.

00:56:46.700 --> 00:56:49.340
And Mac's a little bit different.

00:56:49.340 --> 00:56:51.480
With Linux, it should already be installed.

00:56:51.480 --> 00:56:56.000
So somehow you need to find it on Linux and then create a link to it.

00:56:56.000 --> 00:57:00.040
But you can't really directly create a link because then you get permissioning errors.

00:57:00.040 --> 00:57:01.960
You have to remember where the heck that is.

00:57:01.960 --> 00:57:04.120
At any rate, sound is a headache.

00:57:04.420 --> 00:57:08.420
And it's very, it's very kludgy right now.

00:57:08.420 --> 00:57:13.420
And I'm constantly trying to fine tune or find little exceptions where it's breaking down.

00:57:13.420 --> 00:57:18.360
But you can play MP3s and OGGs and WAV files.

00:57:18.360 --> 00:57:22.580
I generally push people to do WAV files for shorter sound effects.

00:57:22.580 --> 00:57:24.840
I would love better sound to port.

00:57:24.840 --> 00:57:28.940
So you could easily create a backing track of music to your game.

00:57:28.940 --> 00:57:34.080
And then when the song is done, you could get a callback and queue up the next song.

00:57:34.300 --> 00:57:37.960
Stuff like that really should be a lot easier than it is.

00:57:37.960 --> 00:57:41.640
But that's one of my top headaches, that and distribution.

00:57:41.640 --> 00:57:42.020
Okay.

00:57:42.020 --> 00:57:44.140
Well, people have ideas.

00:57:44.140 --> 00:57:45.060
I guess they can send them along.

00:57:45.060 --> 00:57:46.740
I don't, for sound, I have no ideas.

00:57:46.740 --> 00:57:50.720
I don't know anything about sound other than I agree that it's kind of tricky.

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

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

00:58:00.300 --> 00:58:03.640
But I would love a solution for that by any means.

00:58:03.640 --> 00:58:05.680
If anybody knows one, let me know, please.

00:58:07.020 --> 00:58:11.500
Well, it sounds like you have at least basic support for sound, which is pretty critical.

00:58:11.500 --> 00:58:11.980
Yes.

00:58:11.980 --> 00:58:13.260
It makes it a lot more immersive.

00:58:13.260 --> 00:58:14.200
Yeah, absolutely.

00:58:14.200 --> 00:58:16.320
Maybe even more so than graphics, right?

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

00:58:21.520 --> 00:58:25.140
But it had brilliant music that was so immersive.

00:58:25.140 --> 00:58:27.740
And actually, it was quite, quite interesting.

00:58:27.740 --> 00:58:30.320
I forgot what it's called, but it was, it was fun to play.

00:58:30.320 --> 00:58:31.380
And it was because of the music.

00:58:31.380 --> 00:58:32.240
Yeah, I agree.

00:58:32.240 --> 00:58:34.000
And I told my students the same thing.

00:58:34.000 --> 00:58:36.720
It's, you got to get some sort of sound effects on there.

00:58:36.720 --> 00:58:37.700
Yeah, for sure.

00:58:37.700 --> 00:58:42.900
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.

00:58:43.000 --> 00:58:51.720
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.

00:58:51.720 --> 00:58:53.220
Oh boy.

00:58:53.220 --> 00:58:55.960
Do you have a good place for sound effects?

00:58:55.960 --> 00:58:58.380
Like the audio equivalent of Kenny.nl?

00:58:58.380 --> 00:59:00.760
Kenny.nl actually has some sound effects.

00:59:00.760 --> 00:59:02.400
So I often ship that.

00:59:02.400 --> 00:59:08.300
Open Game Art is another website that's pretty good for finding both art and sound effects.

00:59:08.900 --> 00:59:17.880
A lot of sound effect websites ask you to download bad software to play sounds, however.

00:59:17.880 --> 00:59:20.140
So I really have to caution students.

00:59:20.140 --> 00:59:24.640
If they're going out and trying to find sound effects, that's a great way to find malware.

00:59:24.640 --> 00:59:25.180
Yeah.

00:59:25.180 --> 00:59:27.460
Sound should never require an install.

00:59:27.460 --> 00:59:28.820
Exactly.

00:59:28.820 --> 00:59:38.460
And some sites that I used to like actually have sort of switched over to requiring some sort of install and therefore automatic.

00:59:38.460 --> 00:59:39.680
Like steer clear of.

00:59:39.680 --> 00:59:40.760
That is super shady.

00:59:40.760 --> 00:59:41.360
That's crazy.

00:59:41.360 --> 00:59:41.800
Yeah.

00:59:41.800 --> 00:59:42.140
All right.

00:59:42.140 --> 00:59:43.960
Well, I think we pretty much covered Arcade.

00:59:43.960 --> 00:59:48.660
That sounds like a really nice project that you built and hopefully people get a chance to check it out.

00:59:48.660 --> 00:59:49.000
All right.

00:59:49.000 --> 00:59:50.440
Thank you very much for having me on.

00:59:50.440 --> 00:59:50.920
Absolutely.

00:59:50.920 --> 00:59:54.160
Before I let you out of here, though, there's two more questions to ask.

00:59:54.160 --> 00:59:56.920
So if you're going to write some Python code, what editor do you use?

00:59:56.920 --> 00:59:58.160
Oh, great question.

00:59:58.160 --> 01:00:01.500
In order, I will typically do PyCharm first.

01:00:02.300 --> 01:00:04.300
And I really like PyCharm.

01:00:04.300 --> 01:00:09.620
Sublime would be number two for a quick editor to work with.

01:00:09.620 --> 01:00:15.760
And then Vim if I'm on any sort of Linux type of environment.

01:00:15.760 --> 01:00:16.020
Yeah.

01:00:16.020 --> 01:00:16.960
All right.

01:00:16.960 --> 01:00:18.060
Sounds like a good set to me.

01:00:18.060 --> 01:00:20.220
And then notable PyPI package.

01:00:20.220 --> 01:00:22.980
I'll go ahead and throw out there pip install arcade for you.

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

01:00:27.140 --> 01:00:28.400
People should know about X.

01:00:28.580 --> 01:00:29.600
Oh, good question.

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

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

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

01:00:50.760 --> 01:00:51.680
Oh, that's interesting.

01:00:51.680 --> 01:00:52.860
I've never used that.

01:00:52.860 --> 01:00:54.160
So, yeah.

01:00:54.380 --> 01:00:54.720
Yeah.

01:00:54.720 --> 01:00:58.200
There's like a few different OpenGL packages.

01:00:58.200 --> 01:01:03.300
Piglet's bindings I really like and Modern GL are my two favorites.

01:01:03.300 --> 01:01:04.360
Okay.

01:01:04.360 --> 01:01:04.580
Yeah.

01:01:04.580 --> 01:01:04.720
Cool.

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

01:01:10.440 --> 01:01:11.020
Right.

01:01:11.020 --> 01:01:11.380
Yeah.

01:01:11.380 --> 01:01:11.560
Cool.

01:01:11.560 --> 01:01:11.920
Okay.

01:01:11.920 --> 01:01:12.400
Nice.

01:01:12.400 --> 01:01:12.840
That's a good one.

01:01:12.840 --> 01:01:13.160
Thanks.

01:01:13.160 --> 01:01:13.220
Thanks.

01:01:13.220 --> 01:01:17.720
See, this is the purpose of this little section because we all learn about these things that

01:01:17.720 --> 01:01:18.480
we don't know.

01:01:18.480 --> 01:01:19.440
All right.

01:01:19.520 --> 01:01:20.560
So, final call to action.

01:01:20.560 --> 01:01:21.680
People are excited with Arcade.

01:01:21.680 --> 01:01:22.460
How do they get started?

01:01:22.460 --> 01:01:23.840
How do they contribute?

01:01:23.840 --> 01:01:24.860
Things like that.

01:01:24.860 --> 01:01:27.200
There's a website, arcade.academy.

01:01:27.200 --> 01:01:30.860
It's got links if you want to download, try it out.

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

01:01:37.760 --> 01:01:39.720
and you can do pull requests.

01:01:39.720 --> 01:01:41.560
There's a Discord available too.

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

01:01:46.020 --> 01:01:46.940
on that.

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

01:01:52.800 --> 01:01:56.280
that I use for first semester programming.

01:01:56.280 --> 01:02:00.000
And yeah, that's basically how to get started.

01:02:00.000 --> 01:02:00.960
The learn.academy.

01:02:00.960 --> 01:02:01.400
That's great.

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

01:02:05.360 --> 01:02:05.760
course, right?

01:02:05.760 --> 01:02:06.060
Yeah.

01:02:06.060 --> 01:02:08.840
Learn.arcade.academy.

01:02:08.840 --> 01:02:09.360
Yep.

01:02:09.360 --> 01:02:10.220
I'll put it in the show notes.

01:02:10.220 --> 01:02:11.180
People can click it.

01:02:11.180 --> 01:02:12.160
There we go.

01:02:12.160 --> 01:02:13.380
All right.

01:02:13.380 --> 01:02:14.880
Well, thank you so much for being here.

01:02:14.880 --> 01:02:15.600
It's great to chat with you.

01:02:15.600 --> 01:02:15.920
Yes.

01:02:15.920 --> 01:02:16.820
Thank you very much.

01:02:16.820 --> 01:02:17.140
You bet.

01:02:17.140 --> 01:02:17.360
Bye.

01:02:17.360 --> 01:02:20.720
This has been another episode of Talk Python To Me.

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

01:02:25.820 --> 01:02:31.280
With Indeed Prime, one application puts you in front of hundreds of companies like PayPal

01:02:31.280 --> 01:02:33.520
and VRBO in over 90 cities.

01:02:33.520 --> 01:02:36.960
Get started at talkpython.fm/Indeed.

01:02:36.960 --> 01:02:39.820
Rollbar takes the pain out of errors.

01:02:39.820 --> 01:02:44.420
They give you the context and insight you need to quickly locate and fix errors that might have

01:02:44.420 --> 01:02:47.140
gone unnoticed until users complain, of course.

01:02:47.140 --> 01:02:52.580
Track a ridiculous number of errors for free as Talk Python To Me listeners at talkpython.fm

01:02:52.580 --> 01:02:53.560
slash rollbar.

01:02:53.560 --> 01:02:56.140
Want to level up your Python?

01:02:56.140 --> 01:03:00.920
If you're just getting started, try my Python Jumpstart by Building 10 Apps course.

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

01:03:06.020 --> 01:03:09.100
all the different types of async programming you can do in Python.

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

01:03:13.040 --> 01:03:13.760
Everything Bundle.

01:03:13.760 --> 01:03:15.640
It's like a subscription that never expires.

01:03:15.640 --> 01:03:17.940
Be sure to subscribe to the show.

01:03:17.940 --> 01:03:20.340
Open your favorite podcatcher and search for Python.

01:03:20.340 --> 01:03:21.560
We should be right at the top.

01:03:21.560 --> 01:03:26.400
You can also find the iTunes feed at /itunes, the Google Play feed at /play,

01:03:26.400 --> 01:03:30.540
and the direct RSS feed at /rss on talkpython.fm.

01:03:30.540 --> 01:03:32.660
This is your host, Michael Kennedy.

01:03:32.660 --> 01:03:34.160
Thanks so much for listening.

01:03:34.160 --> 01:03:35.200
I really appreciate it.

01:03:35.200 --> 01:03:37.000
Now get out there and write some Python code.

01:03:37.000 --> 01:03:57.000
I'll see you next time.

01:03:57.000 --> 01:04:26.980
Thank you.

