#100DaysOfCode in Python Transcripts
Chapter: Days 97-99: Building JSON APIs
Lecture: Introducing our online game server
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Welcome to Day 97.
0:02
Michael again here with you and we're going to bring
0:05
a bunch of things together that we've previously done
0:08
and what I think is actually a really cool way
0:11
of pushing and combining what you know.
0:14
So we're going to build an online game.
0:17
And it's going to be a multiplayer game,
0:19
not multi-interactive real time game,
0:22
but multiple players from multiple places
0:23
log in and play this game online
0:26
and you get things like high scores,
0:27
who's won the most games, active players, things like that.
0:31
And what's really cool is you basically
0:33
already know like 80% of what you need to do this.
0:37
The final bit we're going to put together here
0:39
with a little bit of APIs and Flask.
0:43
Online games are fun, right?
0:45
Here's a cool one, Eve Online.
0:47
This is actually powered by Python on the backend
0:50
in some really, really important ways
0:52
and it's this MMO, massively multiplayer online game.
0:57
And I actually interviewed the guys from Eve
0:59
over on Talk Python in Episode 52
1:01
if you want to learn about that.
1:02
That's all pretty interesting.
1:04
So we're going to build an online game.
1:06
Now, it's not as amazing as this, right?
1:08
This is incredibly cool, taking hundreds of people
1:10
working on it for a really long time.
1:12
But let's see what we have and how we can piece it together.
1:15
So over here, on Days 13, 14, and 15,
1:19
we talked about text games.
1:21
And the thing we actually built
1:22
was a Dungeons & Dragons wizard game.
1:24
Remember that?
1:25
It was a long time ago, I know,
1:27
but that was one of the first things we built.
1:28
It was really fun, we learned about classes and so on.
1:31
We also discussed this 15-way Rock Paper Scissors.
1:36
And we've come back to this 15-way Rock Paper Scissors
1:39
several times so we're going to do that again today
1:42
for the thing we're going to build together.
1:44
You don't necessarily have to build that one.
1:46
Actually you probably won't build that one yourself
1:48
but that's the one we're going to build together.
1:50
What else do we have?
1:51
Well, we saw that we can consume structured APIs
1:55
with Uplink, recall this?
1:56
We actually went to our movie search service
1:59
and created this Uplink client
2:00
to communicate with that and we're going to again
2:02
use Uplink to build the client side,
2:06
the playing the game side, the user side of this app.
2:09
Not the service side but consuming the service side
2:11
stuff that we build.
2:12
So Uplink's coming back, that'll be fun.
2:14
On Day 76, Julian told us all about Flask
2:17
and how simple and easy it is to get started.
2:19
We're going to take our Flask knowledge
2:22
and use Flask as the web framework for hosting
2:25
our application that is our game server.
2:28
It has the various operations that we need to use
2:31
in order to make our client applications run.
2:35
Finally and really, really importantly, we have databases.
2:40
In order to scale out our server,
2:43
make it survive reboots and all sorts of stuff,
2:45
we need to save our data and have data integrity
2:49
across the various requests and executions
2:53
of our web server.
2:54
So we're going to use SQLAlchemy.
2:56
In fact we're going to use already the exact same model
2:58
that we already added here.
3:00
So over in our demo recall we built
3:02
our persistent Rock Paper Scissors.
3:04
So we're going to take our persistent Rock Paper Scissors
3:07
and convert it to a server side version
3:10
and use the database to keep that information
3:13
going back and forth and then we're going to write
3:14
a little client to use it, that way everybody
3:17
plays on the same server, we have all the shared data
3:19
about who's played what, what were the history high scores,
3:23
things like that.
3:24
I hope you see that we have all the pieces
3:26
with the exception of building just the API methods
3:30
which turn out to be pretty simple in Flask
3:31
if you're not trying to do too much.
3:33
It's going to be an ambitious 3 days
3:36
but we can do it and it's going to be super rewarding.
3:39
So let's get started.