This video discusses the three most common methods of constructing video games in Python's object oriented programming language! Tkinter is an easy to use GUI for simple computer applications but becomes less effective when more moving pieces and functionality get added. Pygame is great for basic 2D video games and can be used for everything from pong to run and gun games, space invaders and even turn based RPGs, but doesn't perform well in creating mobile applications.
Kivy is universally compatible and can be used to create apps that work for windows, mac, linux, android or ios app stores! It also has a fairly difficult learning curve due to its unique syntax and separation of functionality and design, but can also be used to create great mobile applications and games!
We have hundreds of hours of instructional content on the channel and create more every week so be sure to subscribe to stay up to speed! Thanks for checking out the video and good luck with your projects!
what's going on you guys welcome back to
the channel and today's video is going
to cover how to build a game in python
as well as the different modules you can
use including tkinter or kinter
pygame and kivy and we'll discuss the
pros and cons of each of them what type
of applications might make the most
sense for each when you would want to
use the different ones as well as the
approximate difficulty required to get
started with each type so
if you find this useful please check out
the rest of the channel for more great
content leave a like on the video and
subscribe to the channel and without any
further ado let's get going
[Music]
so the first thing i'm going to talk
about is just in general building games
in python uh python is not the
programming language that you would use
to build like a three-dimensional
multi-world console game you would use
an app a game engine like unity
something like that to do something on
that scale python's a better programming
language for
computer widget applications
two-dimensional
games that are kind of on a flat surface
it python is super useful if you want to
just build little quick widgets that
serve kind of one function it's object
oriented style makes that really easy
and again for any graphical user
interface where you're actually going to
have a playable game you're going to
need to use a module either tkinter
which comes in installed with python
today
or kivy or pygame which you import as a
module
so if you do want to build a game all in
python purely to
kind of flex your python abilities or
make kind of a fun little program
i i created a hangman game just to kind
of illustrate what that would look like
um if you want to learn how to build
this game the tutorial is on the channel
but you can kind of see here it's not a
ton of code and honestly a lot of the
rungs of code are me drawing a little
stick figure onto the console whether or
not the players died
so it's a really simple program even
though it took a little while to build
and i'll go ahead and play it here just
so you can see like if the secret word
was
apple and you guessed uh cue
we
record where the guess has been
we record correct guesses incorrect
guesses we'll draw the little dead body
onto the screen one at a time let's
guess a layer that's correct p we update
the letters
in the secret word
but you can see right here
even though you know it's a fun bit of
python programming
it really isn't much of a game you
wouldn't uh present this to someone and
say look i built a game you could say
look i'm proud of my python code and
that's great um but to
make any sort of game where you would
actually want to play it you have to
incorporate some
uh graphical user interface and the
easiest one the one that kind of comes
built in with python is called kinter or
t kenter
because it's spelled this way it's t k i
n t e r
it is super easy to get started with the
tutorial series on this youtube channel
um covers start to finish how to build
several different applications which
i'll just cover briefly here
to show you what we did
but we built a tic tac toe game
um nothing too uh crazy going on here
but uh you'll see when we run this you
can choose whether to play as x's or o's
um go ahead and hit start and then it
creates a game board and then you are
actually playing against a computer so
this is kind of i would say the first
like um
really enjoyable maybe playable um game
that we built
and uh it doesn't take very long it's
not super difficult and the formatting
makes a lot of sense just intuitively if
you're more of a programmer than a game
designer
this might be the easiest one for you
because it's really easy to just pick up
the syntax very quickly whereas pygame
and kivi which we'll talk about next
both have a fair bit of unique syntax in
their modules whereas uh kinter tkinter
it really only has like two or three
things that you wouldn't be used to
seeing normally and it's very good about
prompting you for what needs to go in
each location so
overall uh kinter is used much more for
things like this calculator that we also
created in a tutorial series
where like you can
perform a function so you're doing like
utilities uh you can sort of build your
obviously you don't need a calculator
your computer has one but this style of
widget where maybe you have one sort of
function where it's annoying and time
consuming every time you do it and so
you would write yourself a quick little
script and create a quick little
graphical user interface in kinter to
just perform that function for you
that's its real strength its strength is
not in game development
and so uh we'll get now into the two
uh python modules that their strength
really is game development and so we'll
start with pygame there are a bunch of
pie game tutorial series on this channel
all over youtube if you want to learn to
build all kinds of games
we've done space invaders on this
channel we've done pong we've done like
an idol clicker app style game
this
pong i'll just show you real quick we
made it with a color changing ball and
use wasd the score increments anytime
your
computer opponent
or you hit the ball and the speed
increases as you go up and up but you
can tell like this is actually a fun
video game like it's it's replayable
it's rapid
and again just looking at the script
here the whole thing start to finish
only takes like 130 lines of code
probably less if i cleaned it up a
little bit that's not really how i roll
um but the strength of pie game is their
module has tons of built-in things like
sprite uh collision detection and um
just sort of things that were obviously
created with the intention of making
games and not just a generic computer
application whereas uh kinter kind of
looks like a windows xp uh you know
windows 2000 like like um
widget format it it doesn't look real
modern it's not really tailored for the
game development side of things whereas
pi game you can tell from the name
pygame that's all it was made for so a
lot of things you would hope for like
enemies uh being deleted creating
classes of of different objects and
calling them sprites collision detection
masking things like that a lot of the
way it handles sound and controller uh
player movement is really intuitive um
at least i picked it up fairly rapidly
and i don't have a background in game
development so it made a lot of sense to
me i like pygame a lot the big
limitation of pygame is
much like kinter it doesn't just
transfer from platform to platform to
platform so you can maybe export your
program on windows and run it on mac and
vice versa
even then you might have a little bit of
formatting tweaks you have to make but
it's not super robust cross platform and
you wouldn't make mobile apps or mobile
games with it um so
that
is kind of the big drawback of pygame
it's a ton of fun it's pretty easy to
use and you can certainly share your
games and send it to friends
but if you're looking for app
development and building mobile games or
games that are just really robust
cross-platform then that brings us to
the last thing we're going to talk about
today which is called kivy
and i saved qivi for last because one
it's the most powerful and two in my
personal opinion it's the hardest one to
get started with it has the most unique
syntax it has a completely separate
design language where you would actually
create most of the visual elements of
your game in a separate kv file and then
you would need to incorporate that into
your pi game so you build the the
functionality and how each uh player
action is handled in
in the main python
and you use object oriented programming
but you have to become familiar with the
kivi syntax and even though you don't
have to separate into a similar file
which the separate file is definitely
the standard for larger
applications you would still need to
become familiar with the kivi syntax
even to code it directly into your
python file so in my opinion it is the
hardest one but enough about the
negatives the the great thing about it
is it's really robust at cross-platform
if you create a kivy program that's
properly formatted it can be used in mac
windows linux
ios or android app stores as well so if
people decide to make applications with
python
they almost always are using the kivi
graphical piece of that that's not
universal there are other ones there are
definitely less common ones but kivy you
can find a ton of stuff on stack
overflow you can find a ton of tutorials
on this channel you can find a ton of
tutorials on like freecodecamp.org and
other places
so
i think that if you have an interest in
developing mobile applications using
python you're best off putting the time
in to learn kivy but if you just want to
crank out a fun game quickly and flex
your python knowledge then
tkinter
pygame or kivy could all do the job for
you but just to give you a quick idea of
how
kind of how much more efficient um or or
a kivy game it really looks polished go
ahead and check this one out i followed
a youtube tutorial this was the first
tutorial i ever followed in first game i
made and right off the bat there was
color there was um you know infinite
land creation you could i have kind of a
stupid looking
icon there but
sound it very much looks like a full
functioning mobile app so
uh you know i think that ki is the way
you're going to want to go if your
interest is in mobile application but if
your interest is purely in like 2d game
creation for computers then
pick your favorite commit to it learn
learn it um you can do almost anything
you want in almost any of those
platforms so pick one of the three pick
um any of the others that you might read
about and you probably can teach
yourself but in my experience those are
the three you're going to see the most
tutorials for you'll get the most help
from you know the other programmers out
there on those three
and
also consider if you haven't started
learning a programming language yet
really read into python versus c or c
sharp or any of the visual based
languages
because if all you're interested in for
software is video game development then
you may actually want to steer away from
python its strength is not typically in
the video game side of things c or c
sharp
a lot of visual studio stuff that plays
nicely with like unity in the game
engines is actually the better way to go
for that so ask yourself those questions
hopefully you found this video useful if
you have any more questions or i didn't
answer something here today you are
wondering about
just let me know about in the comments
below i'll get back to you as soon as i
can and uh hopefully you are enjoying
kind of developing games and learning
software it's been a lot of fun for me
doing it over the last few years
and if you are interested in following
along just be sure to subscribe to the
channel it helps me out a ton as we are
fairly new and uh as always good luck
with your code and thanks for watching
thanks bye