Тёмный

How to Make a Game in Python 

Подписаться
Просмотров 385 тыс.
% 8 711

In today's video I will be giving you guys an introduction to Python Game Development using the Pygame module, which is a simple 2D graphics library in Python. This tutorial will be simple, fun, yet allow you to create an extensible game!
💻 Master Blockchain and Web 3.0 development today by using BlockchainExpert: algoexpert.io/blockchain - use code "tim" for a discount!
💻 ProgrammingExpert is the best platform to learn how to code and become a software engineer as fast as possible! programmingexpert.io/tim - use code "tim" for a discount!
💻 Finished Code: github.com/techwithtim/Python-Game-Dev-Intro
💻 Fix Pip (Windows): ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-AdUZArA-kZw.html
💻 Fix Pip (Mac): ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-E-WhAS6qzsU.html
💻 Python Platformer Tutorial: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-B6DrRN5z_uU.html
⭐️ Timestamps ⭐️
00:00 | Project Overview
00:46 | Project Demo
01:52 | Setup/Installation
02:45 | Creating The Window
07:31 | Adding a Background Image
12:35 | Moving a Character
20:38 | Adding Player Boundaries
22:45 | Keeping Track Of Time
24:15 | Rendering Text
27:08 | Adding Projectiles
33:55 | Moving Projectiles & Collision
37:35 | Drawing Projectiles
38:45 | Handling Losing The Game
42:18 | Conclusion
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
👕 Merchandise: teespring.com/stores/tech-with-tim-merch-shop
📸 Instagram: tech_with_tim
📱 Twitter: TechWithTimm
⭐ Discord: discord.gg/twt
📝 LinkedIn: www.linkedin.com/in/tim-ruscica-82631b179/
🌎 Website: techwithtim.net
📂 GitHub: github.com/techwithtim
🔊 Podcast: anchor.fm/tech-with-tim
🎬 My RU-vid Gear: www.techwithtim.net/gear/
💵 One-Time Donations: www.paypal.com/donate?hosted_button_id=CU9FV329ADNT8
💰 Patreon: www.patreon.com/techwithtim
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
⭐️ Tags ⭐️
- Tech With Tim
- Python Game Development
- Python Full Tutorial
⭐️ Hashtags ⭐️
#techwithtim #Gamedevelopment #pythonfulltutorial

Опубликовано:

 

8 мар 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 367   
@fidelrivera2887
@fidelrivera2887 Год назад
Pygame has been a lot of fun to learn... I'm still in the learning phase but the gears are already turning when thinking of new ideas to try and implement. Thank you for the great help... it only gets clear with practice and good guidance like you provide here 👍
@BumbleBeeast_
@BumbleBeeast_ 10 месяцев назад
This was honestly such a fun tutorial! I now have a functional game that I can show off and mess with to try to work on my code abilities! Thank you! I was also able to add a lot of your descriptions as to why you put certain things where you did that way I can reference back to it if needed! Great tutorial!
@gigameister321
@gigameister321 5 месяцев назад
Hey Tim! I just wanted to say how much I appreciate these videos! I am using them to learn python and it's going well for me. I'm about halfway done with this one rn, I look forward to following many more of you're tutorials! Thanks again.
@summaalchemica364
@summaalchemica364 Год назад
This is the first tutorial I got all the way through for Python. Very well made, thank you.
@codsweat5152
@codsweat5152 Год назад
i am new to python and pygame but i can say it has been the best 43 min of my time with coding.. and i never thought i will go through the day without using print() message = "good bye!!" print(message)
@ok.9516
@ok.9516 3 месяца назад
or you can just print("goodbye!") or am i missing something?
@BloonsSanitry
@BloonsSanitry 3 месяца назад
@@ok.9516 u can but it looks more professional to write a variable for some reason
@MewMasterDaMewnza
@MewMasterDaMewnza 2 месяца назад
@@ok.9516, yes but it looks more advanced, that's why.
@MikkahLive
@MikkahLive 26 дней назад
@@ok.9516 Yes you can do that, but they're making a joke.
@anactualalpaca7016
@anactualalpaca7016 Год назад
Tim, not many people out there teach code in such a comprehensive and easy to digest manner like you do. Most tutorials are really hard to follow and the person teaching is either super unorganized, or just really bad at teaching in general for many reasons. But you get it dude, and people like me (people who wanna learn,) appreciate it a ton
@Nitreous
@Nitreous Год назад
After watching just 2 of you videos, the "Learn Python with this one project" you made 5 months ago, and this one I decided to write the code to print a full times table to the console (will do it to a game window next) and I spaced all the numbers correctly in the console so they appear in nice columns... single digits and double digits made the spacing all wrong. Nothing fancy but its little bits like this that build familiarity with the syntax. My goal with pygame is to build a spirograph style project as I remember spending all my lunch breaks on the schools BBC micro in the science labs when I was 15 playing with the code to generate the images the time and effort you put into these tutorials is greatly appreciated and I will be going through all your videos to aid my learning journey.
@shawn445
@shawn445 Год назад
TIm, thank you so much for all of your great videos. They've been great for me to follow along and learn python. I wish you have an extended part of this video or a connected video that went into putting a graphic sprite as you mentioned so you could have more than just a red block. I went nerdy and made my background a space and TARDIS image and themed the messages and name from Doctor Who, but I am not nearly advanced enough to know how to change it to a sprite.
@thoserandomshredders
@thoserandomshredders Год назад
As a beginner python coder: your tutorials help me so much. Keep making them!
@caw25sha
@caw25sha Год назад
For anyone who's recently upgraded to Python 3.11, you'll need to add --pre to your pip command until they update PyGame.
@fidelrivera2887
@fidelrivera2887 Год назад
That explains a lot... been having issues especially while debugging
@jacob-4595
@jacob-4595 Год назад
add how/where? beginning? end?
@jacob-4595
@jacob-4595 Год назад
@Joshua Rose very helpful to a beginner thank you
@jacob-4595
@jacob-4595 Год назад
@Joshua Rose and where can one find this documentation?
@annoyingzebra7460
@annoyingzebra7460 Год назад
do you say --prepip install pygame? doesn't work for me i'm confused
@rileylecaptain113
@rileylecaptain113 5 месяцев назад
This tutorial was amazing and even turned it into a game about traversing a asteroid belt, I managed to replace the squares with images and now all I need to do is figure out on making a menu, and import audios along with a small tutorial box at the start
@bee16384
@bee16384 11 месяцев назад
Tim, thank you very much for this great tutorial. I got so addicted over the weekend that I changed the game to run in full screen, added sounds and music, lives, etc. As you said, it is great starting point and as well a real good example to give pupils an intro into programming on a fun way.
@minecraft69122
@minecraft69122 11 месяцев назад
3:58
@asifmehrabi5154
@asifmehrabi5154 6 месяцев назад
THIS WAS THE BEST TUTORIAL EVER I HAVE GONE THROUGH OVER 50 VIDEOS AND I ALWAYS GIVE UP BECAUSE THEY ARE TOO HARD BUT THIS WAS A VERY SIMPLE YET FUN PROJECT! TY SO MUCH KEEP IT GOING!
@marc8451
@marc8451 3 месяца назад
Are you taking ap csp
@asifmehrabi5154
@asifmehrabi5154 3 месяца назад
what is that????@@marc8451
@seanyB0123
@seanyB0123 5 месяцев назад
Really grateful for this video. I had a bit of a rocky start and I had to rewind about 50 times because I was making errors but you explained everything clearly and concisely. I've got a long way to go but you have helped me take my first few steps on realizing some daft and hopefully fun ideas Thanks again :)
@Anonymous-dk7ek
@Anonymous-dk7ek Год назад
You're GOATED bro.I respect your dedication after all these years from when you were very young...Keep it up
@lifeofintention4711
@lifeofintention4711 5 месяцев назад
Thank you very much for helping me/us learn to code in this practical and explanatory way. You are clear and direct with your explanations and provide a good basis to move on from.
@TevlanTea
@TevlanTea 8 месяцев назад
I finished the game, and I wasn't able to do the text, as I was using too old a version of python but I got it working and it's great! thanks!
@Drifters_Productions
@Drifters_Productions 6 месяцев назад
Wanted to make a comment to house the code. Fantastic tutorial. I recommend watching other videos on python to simply get an understanding of loops and variables. Then coming back. Makes the whole thing a lot more understandable !!
@gurkiratkaur3884
@gurkiratkaur3884 Год назад
Thanks for this awesome tutorial Tim, I needed this :)
@mrsajjad30
@mrsajjad30 6 месяцев назад
Thank you so much for this introduction to game programming in Python. Nice tutorial with all the necessary knowledge. I very much appreciate your effort. THANK YOU.🙂
@daviesfamily9608
@daviesfamily9608 4 месяца назад
Incredible tutorial Tim!! The only thing that would have been more helpful for me to understand would probably be adding doc strings for functions and a few in line comments.
@robmertens5214
@robmertens5214 13 дней назад
Well, this is the first pygame tutorial that actually made sense to me, thanks!!
@QuocDatPhung
@QuocDatPhung Год назад
Wow this is what I've been searching for!
@Boogie-wi7hd
@Boogie-wi7hd 5 месяцев назад
Thanks man. Learned a lot from this tutorial, keep it up!
@softwhere07
@softwhere07 5 месяцев назад
this was a good project. thank you for sharing this. I have been a lot of the day going through this and even tinkering with the moving the character. I even added the up and down feature to play around with it just to see how that would work. But changed it back to just left and right. so much you can do with just what you showed here. thanks. and thanks again. only one problem I have with this is that my "stars" seem to be rotated the wrong way. lol. makes it a bit harder I guess. But awesome.
@bretthart1499
@bretthart1499 7 месяцев назад
thanks for going step by step. I'm very new to this!
@user-lg9im2xy5e
@user-lg9im2xy5e 8 месяцев назад
Thanks tim made the game watched till the end always love your videos
@YouTubeName-hw1uk
@YouTubeName-hw1uk 3 месяца назад
Yoo thank you so much I've been wanting to learn pygame for so long!
@Ector_902
@Ector_902 7 месяцев назад
Watched one video and already Subscribing. You make python language a lot easier than what im learning it in a duolingo type way.
@mjrober33
@mjrober33 Год назад
I enjoy coding along with different projects, learn something new each time. Thank You
@TechWithTim
@TechWithTim Год назад
Glad you enjoy it!
@anshulshah986
@anshulshah986 8 месяцев назад
Extreamly good explanation with good examples. Keep it up!
@Jan_Seidel
@Jan_Seidel 4 месяца назад
I love this tutorial! A real kickstart into Python if you already have some programming knowledge :)
@user-tg1mq6op1e
@user-tg1mq6op1e 3 месяца назад
Thank you very much for this video I really needed it! And you have great content! Subbed you 😀
@sirinarendra6573
@sirinarendra6573 11 месяцев назад
Thank you so much!!! Loved it!
@Nitreous
@Nitreous Год назад
Sat here watching this and this type of game was one of the first games I ever made when I got my 16k ram pack for my ZX-81
@amirilifee
@amirilifee Год назад
You motivated me to make my own channel and teach programming. And so I did !! ))
@hamzazad5258
@hamzazad5258 Месяц назад
great tutorial. Thank you!
@user-mi2bb8bm6s
@user-mi2bb8bm6s Год назад
I've been learning a lot from your videos. Many thanks from South Korea! Could you make a video about python subprocess library ??
@CheeseSticks65757
@CheeseSticks65757 10 месяцев назад
yo I'm not going to lie, I'm a new programmer and this vid don't go into to while loops that much, But it made me understand while loops more then a video on them. Great job!
@idkanything7
@idkanything7 7 месяцев назад
my first time using python! thank you!
@amirilifee
@amirilifee Год назад
well done bro!!!!! always doing funny projects. Keep moving forward !
@ArunManivannan
@ArunManivannan Год назад
Brilliant yet simple tutorial ! Thanks, Tim !
@user-xw5lh6rv7e
@user-xw5lh6rv7e 10 месяцев назад
Thanks for the video. I always loved your videos keep it up. made the whole project and learnt a lot about pygame. never seen any tutorial like this on pygame
@Pultset
@Pultset 2 месяца назад
Really nice tutorial! If you guys finished this tutorial, try to figure out how to make game restart automatically after you got hit by "star" and then try to add score system. You learn best when you have to figure out thing on your own :)
@noebaulopez1295
@noebaulopez1295 4 месяца назад
tnx man very nice and clear video
@LeoiX112
@LeoiX112 Год назад
Thanks brother for the tutorial
@ootbinc
@ootbinc Год назад
So cool! Thanks.
@karthikkarthikshetty2247
@karthikkarthikshetty2247 7 дней назад
It was a very good session learned a lot 🎉
@Samuel11959
@Samuel11959 5 месяцев назад
thanks man taught me alot
@kyawmying224
@kyawmying224 6 месяцев назад
Thank you so much tim
@cptnbara
@cptnbara 6 месяцев назад
I got so many things wrong while doing this > < but I pushed through and hunted down my errors Great tutorial! very good for getting to grips with the simple elements needed for game making.
@madfut24nor
@madfut24nor 3 месяца назад
i cant run the game it says pygame.rect.Rect' object has no attribute 'append' can someone pls help me?
@nchucks72robert99
@nchucks72robert99 4 месяца назад
This is nice, normally i thought python would be hard compared to CSS but with this lesson, i realized that it is actually simpler than i expected. From me to you, "Dude, I love your tutorials"!!!!!!
@TechWithTim
@TechWithTim 4 месяца назад
Wow thanks for the comment!
@catthatisarat
@catthatisarat 7 месяцев назад
Thanks my guy!
@stephendouglas684
@stephendouglas684 Год назад
TWT majoring on the majors! Pygaming like a BOSS!
@dimkau09
@dimkau09 Год назад
You`re so good, the goat.
@kawsr2669
@kawsr2669 2 месяца назад
Coding with Tim. Sounds like excellent game title.😊
@NOTHING-ct4uz
@NOTHING-ct4uz 10 месяцев назад
Thank youuuuu so muchhhh broooo ❤❤❤
@cashdisanti
@cashdisanti Год назад
Thanks Man!
@qosound
@qosound 10 месяцев назад
I did it. Yay!
@xyzxyz6095
@xyzxyz6095 3 месяца назад
TiM !!! Thank you. Salutations from France.
@RolateFN
@RolateFN 6 месяцев назад
the stars wont delete after they collide with the player. I think i made a mistake or something but other than that your explination and everything was on point and perfect
@JVee.
@JVee. 7 месяцев назад
really good intro
@Prof.Fishman
@Prof.Fishman 6 месяцев назад
If your on a more current version of pygame or python, you may have to change the keys script. Try doing ‘if keys()[pygame.K_LEFT]:’ instead of ‘if keys[pygame.K_LEFT]:’
@thetransformation9932
@thetransformation9932 9 месяцев назад
Hi getting erro with for event in pygame.event.get(): Screen popping up but disappearing. Doesn't stay there like you said. Any idea how to fix?
@ronaldothor9118
@ronaldothor9118 11 месяцев назад
I think the if hit statement should come after draw function because we want our players to see the collision or else there will be a gap between the player and the star when the game ends
@BestyyYT
@BestyyYT 10 месяцев назад
For some reason the stars only fall when I am moving and specifically moving right do you know how to fix it?
@user-tn9os8qf2y
@user-tn9os8qf2y 10 месяцев назад
Could you explain why you have to do the star_count += clock.tick(60)? Couldnt you just do star_count += 5 or something since it's already in the main loop?
@godfirstamaka4185
@godfirstamaka4185 4 месяца назад
That point u said if u reached this point u have tried boosted my morale to finish it 🏋️
@habibullahshaik6986
@habibullahshaik6986 6 месяцев назад
broski going godspeed
@YayonTay
@YayonTay 10 месяцев назад
very nice some pot holes but I enjoyed it
@gieranplays
@gieranplays 3 месяца назад
I have no clue what you just taught me, but that's not the point. I loved your video, and it has inspired me just that much more to get into game development. Hopefully one day, I'll be able to do this without a video 😅
@user-sf6nj9sp4m
@user-sf6nj9sp4m 6 месяцев назад
cool video)
@Andrew-Tsegaye
@Andrew-Tsegaye Год назад
Tim, our master, Is this significantly beginner-friendly? To ensure everyone can follow through on the projects and videos you post daily, please give us some insight into the necessary prerequisites. We love you keep up the good work.
@JoyBoyLaughs
@JoyBoyLaughs Год назад
This isn't beginner friendly. You should already know about variables, functions, loops and be able to write some small logic in order to visual how everything is working in ur mind, otherwise you will probably feel lost. This is probably low intermediate to medium intermediate level
@Andrew-Tsegaye
@Andrew-Tsegaye Год назад
@@JoyBoyLaughs I mean can you walk though the project without any pygame knowledge. Now I think you got the point.
@moraja3aty
@moraja3aty Год назад
nice bro good work ;)
@icephonex
@icephonex Год назад
can you make gamedev tutorials with languages which are commonly used in the gamedev industry? like without a game engine but with opengl or sdl for example? there are other tutorials out there but I've been watching you since 2016 and you're way of teaching is much better than anyone else
@TechWithTim
@TechWithTim Год назад
I'll consider it for sure!
@westside7001
@westside7001 Год назад
That's why it's The GOAT!! THE GOAT!!!!!!!!
@paulthomas1052
@paulthomas1052 Год назад
Great little demo - thanks
@user-vy1nu3ix8w
@user-vy1nu3ix8w 7 месяцев назад
Hi Tim I m trying to program tetris . I don't know much about programming. What would you recommend to watch first before starting . Thanks
@GDominusOnYt
@GDominusOnYt Год назад
awesome
@dreadmemoirs
@dreadmemoirs Месяц назад
Hey! Thanks for the tutorial, I finished it and completed it. However, I went through the code and can't find the issue, (my stars only come down when moving to the right), any idea what I could have done wrong? Thanks!
@patdabot1
@patdabot1 9 месяцев назад
How could I add a 'Try Again' button at the end when you touch the projectile? Thank you
@hzrf4039
@hzrf4039 Год назад
after drawing the projectiles, when i try to launch in, after 2 seconds it crashes and says "AttributeError: 'list' object has no attribute 'y'" what can i do to fix it?
@crazyjedcowpokemon
@crazyjedcowpokemon 2 месяца назад
This video was so entertaining and fun to watch, great job, Toolman Tim!
@victorunited2168
@victorunited2168 Год назад
Worked well loving ur tutorials. Having a problem, I want the game to continue and not exit after losing
@riquelsonalcochete6070
@riquelsonalcochete6070 Год назад
You can use functions, and if you want a menu and more thing, you should create a main function first and in that function you initialize pygame, and to change between menu, game,etc, you need to create more functions inside the main each one with it's individual while True loop
@riquelsonalcochete6070
@riquelsonalcochete6070 Год назад
And of course the variables, for pygame related variables you can create them in the main func, and call it from any place, but for normal variables you need to create them in the function where it will be used.
@user-tn9os8qf2y
@user-tn9os8qf2y 10 месяцев назад
why at the end can I not change the lost_text, when I do the old text is still displayed below it even after the update.
@d_fendr6222
@d_fendr6222 11 месяцев назад
Hey folks I'm at the point where I have to draw the rectangle, but it just won't show up. I followed the code as shown in the video but it still doesn't appear. Is there a way to fix this?
@brandonw3180
@brandonw3180 7 месяцев назад
I was copying your tutorial character by character, then the timer wasn't displaying. rewatched a few times before asking ChatGPT. it said: "try moving the pygame.display.update() line outside the draw function and place it after the draw call in the game loop. This ensures that the display is updated each frame." this ended up working surprisingly. Any idea why?
@unknownman5296
@unknownman5296 Год назад
hey tim can you make a tutorial on godot? it's like unity but for python, you can make 3d games with it
@thetriumphpublication
@thetriumphpublication Год назад
Great. I recently started watching your videos. You are really great. Can you guide me to some job.
@markgreen2170
@markgreen2170 Год назад
Nice ...I did watch the whole video ...at 1.25x but, I did something similar on the commodore 64 a few years back. relearning python now ...correction, learning python, it has come a long, long way since I was a programmer,
@bruhaduadu3318
@bruhaduadu3318 10 месяцев назад
good video !
@SHEIKHHARIS8695
@SHEIKHHARIS8695 3 месяца назад
I am begginer and after watching this video i have come to know that how the python intresting is
@mrquack1720
@mrquack1720 Год назад
Nice
@Anonymous25424
@Anonymous25424 Год назад
everything was working correctly but i add the stars object it keeps on freezing and crashing what might be the problem
@gabe_motherboard3355
@gabe_motherboard3355 Год назад
Idk if I will figure this out right after commenting but every time I try to run the script now I get the unexpected indent error for line 24, the while run command, how do I fix this?
@ahammadalipk
@ahammadalipk Год назад
Why you have used 2 IFs instead of if else inside loop?
@user-rf8rw7rp1n
@user-rf8rw7rp1n Месяц назад
Tim I cant run the code because even though I made the 'stars' variable it says it isnt defined by pylance
@nathanthomas9268
@nathanthomas9268 Год назад
what coding software do you recommend for Mac? (I'm new to this)
@gustavofring6176
@gustavofring6176 5 месяцев назад
why does mine say when i try to run it with the stars “Random.randint() takes 3 positional arguments but 4 were given?”
@maxyruelasangel2853
@maxyruelasangel2853 10 месяцев назад
tysm of that now i made all of the zelda games
@BlazingFire-kh9lz
@BlazingFire-kh9lz Месяц назад
Every time I run the program, it says eg "Test1" is not defined ( the error is from the line : Test1()) . How do I fix this?