Тёмный
No video :(

Pygame Tutorial #3 - Character Animation & Sprites 

Tech With Tim
Подписаться 1,6 млн
Просмотров 402 тыс.
50% 1

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

 

24 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 919   
@TechWithTim
@TechWithTim 5 лет назад
Interested in what its like to be a computer science student? Check out my Podcast: anchor.fm/tech-with-tim Follow me on Twitter: twitter.com/TechWithTimm Join my Discord to Ask Questions and get help with pygame! discord.gg/pr2k55t SOURCE CODE: techwithtim.net/tutorials/game-development-with-python/pygame-tutorial/pygame-animation/
@asjadsidd
@asjadsidd 5 лет назад
Hey Tim, I really like your videos, and the podcasts as well. Please do more podcasts. It's been 4 months since your last one. Talk about more topics, and please give some tips on how us guys with knowledge of python, pygame, openCV, OOP, etc can make money online. And please do more podcasts and videos. Thanks, and keep up the great work !
@s.platini9390
@s.platini9390 4 года назад
Awesome tutorial. Thanks!
@IdunRedstone
@IdunRedstone 4 года назад
EDIT: Answer was pygame.transform.scale() for those interested. Assuming adressed in later videos or can find out elsewhere but can sprites be made to scale with the window size or do you have to use other techniques for that?
@kaldiaz9337
@kaldiaz9337 4 года назад
plz help my code is saying can't load R1.png
@IdunRedstone
@IdunRedstone 4 года назад
@@kaldiaz9337 Did you put R1.png in the folder your python file is saved in? Because it has to be there. You can also put the full file path like "C:\Users\You\Pics\R1.png" [example] but you shouldn't do that on code you're giving to others as it wouldn't work for them unless they had the exact same folders.
@ibrahimabdalla1642
@ibrahimabdalla1642 4 года назад
YOU... ARE... AWESOME!!! THESE ARE BY FAR THE MOST USEFUL PYTHON TUTORIALS I HAVE EVER SEEN.
@alternyte925
@alternyte925 4 года назад
true fact there
@Gridzontop
@Gridzontop 2 года назад
excatly
@fyxfrominferno9194
@fyxfrominferno9194 5 лет назад
I've been entertaining myself for the last 5 minutes over the fact that the player character has no jumping animation so he just rockets up into the atmosphere
@newbielegend1353
@newbielegend1353 3 года назад
m e too
@Gridzontop
@Gridzontop 2 года назад
hehehhehe i can imagine that
@robinjack
@robinjack 5 лет назад
Just found this series of tutorials and way theyre better than the "bigger" channels out there. Keep it up!
@windhaming2573
@windhaming2573 5 лет назад
i agree this is the best tutorial for pygame i've seen
@percypappiono8464
@percypappiono8464 5 лет назад
@Azlaan Moinyup
@hank7898
@hank7898 5 лет назад
I know I'm nit picking (i totally agree with your point), but are way and they're switched around?
@vandegraaff5114
@vandegraaff5114 4 года назад
I agree.
@andrewn211
@andrewn211 4 года назад
I like how his voice is strong and that his mic isnt low because i find a lot of tutorials who have people who do that... But yeah this tutorial IS GOOOD
@jerrygoss6395
@jerrygoss6395 5 лет назад
I kept overlooking your videos because "more views is better" but holy crap dude, my classmates recommended you and now I can see the light
@TechWithTim
@TechWithTim 5 лет назад
Well thank you and Welcome!
@benjamintchang3923
@benjamintchang3923 3 года назад
N now it's got 250k views, Tim is winning
@theblinkingbrownie4654
@theblinkingbrownie4654 5 лет назад
For people who have custom sprites I suggest this at the beginning of the file: from pygame import image as img Then instead of walk_right = [pygame.image.load("Custom sprite.png")] It's walk_right = [img.load("Custom sprite.png")]
@chronicsnail6675
@chronicsnail6675 4 года назад
y
@RohanKumar-zd3pc
@RohanKumar-zd3pc 3 года назад
that doesn't make a difference
@theblinkingbrownie4654
@theblinkingbrownie4654 3 года назад
@@RohanKumar-zd3pc Helps code look a lot cleaner instead of repeating the same thing over and over.
@RohanKumar-zd3pc
@RohanKumar-zd3pc 3 года назад
@@theblinkingbrownie4654 Agreed
@andeemengaming5000
@andeemengaming5000 3 года назад
USE CAMEL CASE LOL
@anantkhanna4954
@anantkhanna4954 4 года назад
0:50 for a second i thought that my headphones sparked
@ey7830
@ey7830 4 года назад
yeah same here, I teared them down of my head ':DD
@ey7830
@ey7830 4 года назад
@Goodbye F
@kidskpadonou894
@kidskpadonou894 4 года назад
so I'm not the only one...
@danify2921
@danify2921 4 года назад
your not
@Ashersminicartoons
@Ashersminicartoons 4 года назад
sammmeeee. I thought my headphones sparked and broke so I switched to my speacker
@gokulrajkumarassamy1658
@gokulrajkumarassamy1658 4 года назад
Great Video Tim! For anyone who is lazy like me! Instead of loading the images the way Tim did it, here is an alternative walkRight = [pygame.image.load(f'R{n}.png' for n in range(1, 10)) and for left just change the variable name and the 'R' to a 'L'
@ahmetcoskun6632
@ahmetcoskun6632 2 года назад
hi i wanted to try this out but it kept quitting when I tried to move
@chedlyshabou4476
@chedlyshabou4476 2 года назад
@@ahmetcoskun6632 you forgot the , (x, y) after walkcount // 3
@lucascook7981
@lucascook7981 9 месяцев назад
This video series of tutorials is amazing, not to mention the free set of .png video game character graphics neatly loaded into one place with copy paste script to organize them all!! The troubles of trying to download free .png files off sketchy websites are no more! I am a first year CS major and learning python through your channel has made the process so much more fun. Seeing the animated character running instead of a basic moving shape was such a good feeling!
@premprasad3511
@premprasad3511 2 года назад
Finest tutorials on python and pygame. Your explanatory power is divine !!
@bandanaboii3136
@bandanaboii3136 3 года назад
This tutorial saved me a lot of time and research, thanks Tim
@louzynerd129
@louzynerd129 4 года назад
this is just fantastic, i was almost gonna give up python because i thought i can't even make simple animations on it but wow this can go far. amazing video
@christinepuccio3830
@christinepuccio3830 3 года назад
Thank you! This is much clearer than a lot of the books and tutorials out there. :)
@johnathanpieters2479
@johnathanpieters2479 2 года назад
hey guys. if you are having trouble downloading the images from the link given in the description I suggest downloading the images from the inspector(right-click the download button and select inspect).
@notreo
@notreo 2 года назад
oh my god thank you so much youre a life saver
@holahopper
@holahopper Год назад
I wish I had read your comment before I downloaded the images one by one on github...
@mitchelljones2452
@mitchelljones2452 Год назад
@@holahopper I said fuck it and started making my own 😂
@holahopper
@holahopper Год назад
@@mitchelljones2452 🤣🤣🤣
@kafuitv
@kafuitv Год назад
saviour
@jannik244
@jannik244 2 года назад
(11:43) just a little thing. I wanted it a bit smoother, so you guys in the comments can try it. Replace the clock.tick(27) with the double amount. --> clock.tick(54) and decrease the velocity, for example by 2. --> vel = 3.
@chriscisco9880
@chriscisco9880 Месяц назад
These tutorials have been really good so far! The only problem I ran into was that I couldn’t load the images but it was just because the path to my python file was in my virtual environment folder for some reason
@seeforkat
@seeforkat 5 лет назад
i love how youtube gives me a lot of helpful videos like you keep up tim >;)
@TechWithTim
@TechWithTim 5 лет назад
Thanks!
@isaac8228
@isaac8228 5 лет назад
import os os.chdir("C:\\Users\\Toshiba\\Documents\\Programming\\Resources\\Game\\SPRITE1") Note: For those whose having trouble with loading images. Replace the (" "), with the location of your images. Make sure it has double slash.
@darkseid2584
@darkseid2584 4 года назад
Thanks
@esdrastshiala_kabangu4944
@esdrastshiala_kabangu4944 3 года назад
Thanks
@suyashvashishtha4904
@suyashvashishtha4904 5 лет назад
if anyone is getting issue like "cant load the images" just do one thing --- close you notepad.make a new folder . paste your python program there and also paste the sprites/images directly there (not in a folder) and then run the program. thanks .....
@Cerbero3333333
@Cerbero3333333 5 лет назад
I'm on vs code, I have done what you said, but I still get the error. what can I do?
@taliesonsolmon7662
@taliesonsolmon7662 5 лет назад
@@Cerbero3333333 I'm also having this issue. not sure what to do :(
@Cerbero3333333
@Cerbero3333333 5 лет назад
@@taliesonsolmon7662 i managed to solve the problem by telling the program to Import (file directory) at the beginning of the script i believe
@justing5228
@justing5228 4 года назад
May giglio I don’t understand what you mean
@Cerbero3333333
@Cerbero3333333 4 года назад
@@justing5228 type: import os os.chdir(r'C:\ directory of folder')
@aluskus
@aluskus 4 года назад
Elegant solution for modifying walkCount: Instead of having an if statement to set walkCount = 0 you can do this in each if left: and if right: statements like: if left: win.blit(walkLeft[walkCount], (x, y)) walkCount = (walkCount + 1) % 9 elif right: win.blit(walkRight[walkCount], (x, y)) walkCount = (walkCount + 1) % 9 Because there are 9 elements in the array, using the modulo operator % (remainder of division) will make sure that walkCount always is in the range [0-8] which correctly accesses the sprites in the walking animation array. Preferably you'd define a small function to increase walkCount to avoid repeated code.
@claytonsmith1367
@claytonsmith1367 5 лет назад
This video saved my life! I was going crazy trying to figure this out on my own
@TechWithTim
@TechWithTim 5 лет назад
Glad it helped!
@lavinabhambra7611
@lavinabhambra7611 6 лет назад
Great video as always! Can't wait to do the rest
@metgaming9545
@metgaming9545 4 года назад
I had a problem for Deprecation Warnings. Right now I’m on Python 3.8.2 so that’s probably why I got these. If you are getting Deprecation warnings, use this code. import warnings warnings.filterwarnings(“ignore”, category=DeprecationWarning) Just in case anyone else gets the same problem (:
@user-nj3lg7wi5r
@user-nj3lg7wi5r 3 года назад
Not bad, keep going. I will be rewatching those pygame tutorial videos because they're helpful. Thank you.
@matheus5806
@matheus5806 5 лет назад
I want to add that starting in Python 3.4, we can use the Pathlib module to set up the filepaths we wish to use. I don't know if it's better or worse than os.path, but it's a possibility I wanted to share. So if your sprites are located, for example, in "C:\Users\User\Desktop\Game\Assets\Hero", and your script is in "C:\Users\User\Desktop\Game", all we need to do is: from Pathlib import Path #We define GAME_FOLDER so we can navigate through its files and folders whenever GAME_FOLDER = Path.cwd() #Now, when loading the sprites, instead of os.path.join(), simply navigate to the desired folder. #Because pygame.image.load() seems to accept strings and bytes, the filepath needs to be converted #to a string pygame.image.load(str(GAME_FOLDER/"assets"/"hero"/"R1.png"))
@favourite_indian
@favourite_indian Год назад
do we need to do that for every one of the sprites or just one time?
@JadeyCatgirl99
@JadeyCatgirl99 4 года назад
I had a problem getting the image files to load, but figured it out. I use the PyCharm interface to write the code, and had the shortcut file saved in the same location as the image. What I really needed to do was save the scratch file in that folder. After I moved the scratch file, and told PyCharm what to run it loaded fine.
@aaronrahaman7760
@aaronrahaman7760 4 года назад
I used to always use Pycharm but school uses IDLE so whenever I learned something new it was weird to switch in between the two IDEs lol
@kaizyx6710
@kaizyx6710 4 года назад
What
@kaizyx6710
@kaizyx6710 4 года назад
I didn’t get last part
@anayamalean5437
@anayamalean5437 4 года назад
If you can't open R1.png, take all the sprites and put it into another new folder. Then on your Python interpreter (for me it's Pycharm) type; Import os os.chdir(r' Copy and paste the link to the folder into here') So the paste would look like C:\etc\etc Then run it and hopefully it works. It did for me
@blissfulbog907
@blissfulbog907 3 года назад
Thanks! I've been trying to figure out what the problem was for about an hour or so and didn't even think to check the comments, then found this in under 30 seconds which solved the issue
@anayamalean5437
@anayamalean5437 3 года назад
@@blissfulbog907 No problem!
@micahconnor8954
@micahconnor8954 3 года назад
tysm! ive been tryna figure this out for a while, and your advice worked perfectly!
@angelgonzalez-sv7vc
@angelgonzalez-sv7vc Год назад
man i was ready to give up lol thanks for the tip, i couldn't figure out what was wrong i know everything looked right
@leolegos8358
@leolegos8358 Год назад
I actually used the Command Prompt to move the images into a place where Python would recognize their existence
@annieshi883
@annieshi883 4 года назад
I love these tutorials even though they are old they are extremely helpful. i hope soon I can start freelancing :)))
@jantonisito
@jantonisito 7 месяцев назад
Excellent tutorial. Great way to make learning basic Python FUN!
@jimlee8016
@jimlee8016 5 лет назад
Finally load images !!!! Such a relief
@dhruvjain9029
@dhruvjain9029 4 года назад
My program is running and showing no error but images ain't loading
@lb_abz8234
@lb_abz8234 3 года назад
@@dhruvjain9029 same
@techmech7196
@techmech7196 3 года назад
Where did u save the images buddy
@shozy1
@shozy1 5 лет назад
If you play it at 1,5x, Tim speaks normally
@yy-wt7qt
@yy-wt7qt 4 года назад
Already been said, but I have learned more about pygame from these pygame tutorials than any other videos I've watched so far. Thanks a ton!
@hangawpc123
@hangawpc123 3 года назад
Same :)
@StarryEyedDemonGirl
@StarryEyedDemonGirl 5 месяцев назад
Had to replace some code to make the sprite actually animate, but over all this tutorial STILL holds up in 2024.
@sourabh6894
@sourabh6894 5 лет назад
how to open image.png as there is an error -> Couldn't open R1.png
@sourabh6894
@sourabh6894 5 лет назад
Got the answer that first copy that game file where your Python file is present and then just ('game/R1.png')
@rafaelperezmederos6958
@rafaelperezmederos6958 4 года назад
Don’t understand make this more clearer please
@jibster148
@jibster148 4 года назад
@@rafaelperezmederos6958 you need to have both the images and the game stored in the same location bud
@Home4HowTos
@Home4HowTos 4 года назад
I had the same issue. to resolve "Couldn't open R1.png" you have to enter the file location. This is from my mac walkRight = [pygame.image.load('/Users/BFaruch/Downloads/Game/R1.png')]
@fuzzypicklesgaming439
@fuzzypicklesgaming439 4 года назад
You have to put all the image files in the SAME file as your code file. You can't have the images in another folder inside of the folder that your code is in.
@williambendwell1549
@williambendwell1549 3 года назад
When I try to include the sprites my program gives me a FileNotFoundError: No such file or directory. They are in the same file, so Idk what to do
@siddhartheaswar959
@siddhartheaswar959 3 года назад
try using the path to the picture because like he said sometimes that has to be done in case of errors
@theallduck
@theallduck 3 года назад
yeah same that happened to me too
@savagekawaii6521
@savagekawaii6521 2 года назад
What i do is copy the whole project and make it another. You just gotta copy and paste ot into mew project. It should work then
@unrealpuggy
@unrealpuggy Год назад
Make sure you’re running the same file folder or else the computer won’t read it.
@thaimeuu
@thaimeuu 7 месяцев назад
couldn't believe I can do this, thanks Tim
@kushalshrivastav5469
@kushalshrivastav5469 2 года назад
THIS WAS THE EASIEST TUTORIAL FOR ME ON ANIMATION WITH PYGAME ON RU-vid! THANKS!
@NathanielPennington
@NathanielPennington 5 лет назад
CHARACTER NOT ANIMATING LEFT? 9:15 - 9:17 watch carefully, this is where i messed up, working now :D
@proninja434
@proninja434 4 года назад
mines not animating right
@ugwuey1080
@ugwuey1080 4 года назад
@@proninja434 mine no animating when still jajaj. checking for the mistake for 10 minutes
@havhavproductions8725
@havhavproductions8725 4 года назад
It has to be an elif not an if
@quator7346
@quator7346 5 лет назад
If you run into an invalid character in identifier after copy/pasting the top comment, remove and replace the last “)” in the copy!
@Runslik3Wind
@Runslik3Wind 5 лет назад
Perfect thanks
@lucaslu135
@lucaslu135 5 лет назад
thx man
@technewbea8118
@technewbea8118 5 лет назад
just for anyone having trouble with the images if you are storing the image in the same folder as the python program I created a variable for directory path using folder = os.path.dirname(__file__) and then pygame.image.load(os.path.join(folder,'bg.png')) also dont forget to import the os module I was having trouble with this as well so hope this helps
@xiokraze
@xiokraze 5 лет назад
Which compiler/IDE are you using? This is really easy to add to VS2017!
@nitowl8515
@nitowl8515 3 года назад
Dude thanks so much for this, it finally works!!!! I am using VSCode
@philipp9633
@philipp9633 6 месяцев назад
@@nitowl8515what are you supposed to write as the dirname? The name of the folder my sprites and game are in, or users/[username]
@banipreetkaur1286
@banipreetkaur1286 4 года назад
For all those with the error-Couldn't open R1.png, here's something to help you out First copy full path(i.e. URL of the image) Then..check the URL, generally it has single slashes(eg. pc\downloads) so..just double slash the complete URL (eg. pc\\downloads)....double slash COMPLETE URL(wherever slashes appear)
@pablocorrales4416
@pablocorrales4416 2 года назад
Excellent tutorial! Just 1 question: did you download a spritesheet and cut it? If so, how can I do that? I always manage to do it wrong 🙃
@dailyfunnierfacts
@dailyfunnierfacts 2 года назад
No, you have to cut it . OK
@Didrik147
@Didrik147 4 года назад
Thank you for a wonderful tutorial! I learned a lot by watching this tutorial series. I wondered if it would be OK if I used the sprites for my own project? If that is the case, who should I give the credit it to?
@johnathanpieters2479
@johnathanpieters2479 2 года назад
I googled and found this
@tomthejus5587
@tomthejus5587 4 года назад
If you want your character to spin Press "a" and "d" at the same time Try pressing the space bar also
@maxilea4118
@maxilea4118 4 года назад
it's my second year of python and i'm trying to create a 2d top down racing game but i haven't been able to import the images of the cars for over 2 weeks now with no success. Thanks to your video my game now works perfectly. Thank you so much
@irfanwani4322
@irfanwani4322 4 года назад
walkcount + 1 > 9 walkcount // 1 gives a move clear image and i dont think we need to load a single image 3 times PLEASE REPLY...
@hls6627
@hls6627 4 года назад
The man made this video 2 years ago. I don’t think he’s checking all the comments on his videos 24/7
@Jacob11227
@Jacob11227 4 года назад
when ever I try to move too far left or right it come up with Traceback (most recent call last): File "C:\Users\user\OneDrive\python\firstGame.py", line 85, in redrawGameWindow() File "C:\Users\user\OneDrive\python\firstGame.py", line 38, in redrawGameWindow win.blit (walkright[walkcount//3], (x,y)) IndexError: list index out of range
@adriaan3428
@adriaan3428 3 года назад
You probably forgot to reset the walkcount after 27 : if walkcount + 1 >= 27 : walkcount = 0
@LOSFOUFOUP
@LOSFOUFOUP 3 года назад
@@adriaan3428 Well I didn't and still I get the same error.
@adriaan3428
@adriaan3428 3 года назад
@@LOSFOUFOUP Well that's weird, I can't help you in that case.
@LOSFOUFOUP
@LOSFOUFOUP 3 года назад
@@adriaan3428 Welp, all I had to do was replace 'walkCount += 1' by 'walkCount = (walkCount + 1) % 4' (because 4 sprites for each direction) and no more of this error.
@jwcolby54
@jwcolby54 5 лет назад
You might want to create a character class where you store all the attributes and actions of the character. Then have the program just call methods of the character to cause it to move. The character "knows" how big it is, how to check the screen boundaries based on its size, how to jump etc.
@jesusdacoast872
@jesusdacoast872 4 года назад
Thanks dude for your efforts, it's an amazing tutorial to get started with Python and pygame lib. Thanks again dude 😎
@ranjithj.c.8711
@ranjithj.c.8711 4 года назад
I have an error that says: pygame.error: Couldn't open R1.png I know that I am probably 2 years late but please reply
@valeriovergni3339
@valeriovergni3339 4 года назад
@sdm Mahale asked the same eleven month ago and I guess he solved it
@Amoul24
@Amoul24 4 года назад
That is because your game is not in the same file as your pictures if you add it there it will work. Or if you don't want you can add the place you put it before each file name for e.g. [pygame.image.load('/Users/Ranijith/Downloads/Game/R1.png')]
@5staryzzz
@5staryzzz 4 года назад
Same!
@5staryzzz
@5staryzzz 4 года назад
@@Amoul24 I'll try that
@theadatap6818
@theadatap6818 4 года назад
same XD
@baato870
@baato870 4 года назад
Traceback (most recent call last): File "C:\Users\user\Downloads\driwe.py", line 11, in car = pygame.image.load('Driwe/Driwe_car.png') pygame.error: Couldn't open Driwe/Driwe_car.png well how the hell could it open it?
@irfanwani4322
@irfanwani4322 4 года назад
copy that image and paste it in the main project....and then try again
@irfanwani4322
@irfanwani4322 4 года назад
@Tyr Tirov U're welcome....
@marcusaurelius45
@marcusaurelius45 4 года назад
@@irfanwani4322 What do you mean by copy and pasting it into the main project could you be a bit clearer please?
@irfanwani4322
@irfanwani4322 4 года назад
@@marcusaurelius45 copy the image or music whatever you want to add to your project.then go to LOCAL DISC C >> USERS >> THEN SELECT THE ACC.YOU ARE USING i.e, YOUR COMPUTER NAME >> python projects >> select the name of your project and open that >> copy the file there which you want to add to your project... Hope you got the answer..
@mkm6007
@mkm6007 3 года назад
😩😩😩 please can you make me understand i am still waiting i dont understand i copied and pasted it on folder where my project is but not working 😩😩😩😩 please
@samwaterworth2859
@samwaterworth2859 4 года назад
It's probably something obvious I am doing wrong but when I set the clock tick when I run it I get a black screen. How do I fix this?
@bibblyjibbly653
@bibblyjibbly653 4 года назад
Sam Waterworth is it because you might not have put the statement correct Like clock = pygame.time.Clock() with brackets and a capital c
@samwaterworth2859
@samwaterworth2859 4 года назад
@@bibblyjibbly653 thanks so much
@cookiecuty1234
@cookiecuty1234 4 года назад
Thank you!! It was very easy to follow and to change some things here and there since you explained their purpose so well!
@tomazornik2002
@tomazornik2002 5 лет назад
Wow, thank you for this!
@TheMathguy345
@TheMathguy345 5 лет назад
U are gr8 . U helped a lot
@anindyaroythetechmaster
@anindyaroythetechmaster 4 года назад
why are you using IDLE when you already have PyCharm?
@ninjoushinja9478
@ninjoushinja9478 2 месяца назад
The guy in the vid has PyCharm?
@4B3K_
@4B3K_ 3 года назад
This guy is a LEGEND!!!!!!! I found a way to use sprites in a different way, yet still retain the idle sprite using this method! Thanks so much!!
@hedgehogkoebel5919
@hedgehogkoebel5919 6 лет назад
char = pygame.image.load('standing.png') when I run the program it says: "invalid character in identifier" I copied it after yours and my script and images are in the same folder. Any ideas?
@skyharrington-baker3653
@skyharrington-baker3653 6 лет назад
same its making me sad
@joey3491
@joey3491 6 лет назад
I just retyped the char line, and it worked. I can't tell what the error was but it came from copying and pasting the line from the top comment
@xiokraze
@xiokraze 5 лет назад
When copy/pasting over, it also copies in the newline character. Just delete a few off the end of the line until you remove the ) and retype it. Should fix the problem.
@MahdeenSky
@MahdeenSky 4 года назад
cant u just use a for loop and format strings to loop through 1 to 9 to load all the images? by appending them to a list? instead of hardcoding all of them? Like this: walkRight = [] walkLeft = [] for i in range(1, 10): walkRight.append(pygame.image.load(f'R{i}.png')) walkLeft.append(pygame.image.load(f'L{i}.png'))
@TheRettrixx
@TheRettrixx 4 года назад
Thats actually what i thought.
@MahdeenSky
@MahdeenSky 4 года назад
@@TheRettrixx i actually went to his discord to ask that, but then we came to a close, with the idea, he wanted to keep things simple lol.
@WolverineAndSloth
@WolverineAndSloth 5 лет назад
This is such a great tutorial series. Thank you so much for providing this fantastic content! You're literally making dreams come true, man
@TechWithTim
@TechWithTim 5 лет назад
Thank you! And I’m glad I could help.
@codewithshajahan9997
@codewithshajahan9997 3 года назад
This series is Awesome. Best pygame tutorial series out there!
@leo848
@leo848 4 года назад
I have pygame.error: Couldn't open R1.png even it's in the same directory. 😭
@christianfranssens8358
@christianfranssens8358 4 года назад
Me too.
@leo848
@leo848 4 года назад
Christian franssens I could temporarily fix it by adding game/, but it's not working anymore.
@christianfranssens8358
@christianfranssens8358 4 года назад
I already fixed it by putting everything in one folder and restarting the whole program
@thunder5gaming73
@thunder5gaming73 4 года назад
@@christianfranssens8358 Rip
@Amoul24
@Amoul24 4 года назад
I have the same problem so annoying especially because it was working a few days ago
@metrobomb8658
@metrobomb8658 5 лет назад
Code: if walkCount + 1 >= 27: ^ SyntaxError: invalid syntax
@lunareclipse07
@lunareclipse07 5 лет назад
Your error must be somewhere else
@anantkhanna4954
@anantkhanna4954 4 года назад
can you show me your entire code?
@sanjaynagarimadugu6108
@sanjaynagarimadugu6108 4 года назад
These videos are amazing. I came here from your free tensorflow tutorials and damn its so good
@avvn9331
@avvn9331 5 лет назад
Very useful tutorial and Thanks lot for explaining this is such simple and easy manner to understand. I can't thank you enough for this tutorial. I tried in another a set of images, and its works just fine.
@TechWithTim
@TechWithTim 5 лет назад
You’re more than welcome, thanks for the comment!
@rehelm3114
@rehelm3114 5 лет назад
0:57 my ears started bleeding
@nash1629
@nash1629 6 лет назад
pygame.error: Couldn't open R1.png
@edenp5274
@edenp5274 6 лет назад
Same
@edenp5274
@edenp5274 6 лет назад
What do we do????
@tsungyuh6650
@tsungyuh6650 6 лет назад
You guys should put the pics into the folder which had place your tutorial.py~ "same folder!"
@ozalym
@ozalym 6 лет назад
If the images are on the same folder as the ".py" file it can be a copy-paste error, have to write it manualy (even if there is no difference between both)
@ShahbazAhmad-ff4cs
@ShahbazAhmad-ff4cs 6 лет назад
Same here
@fernandocorenstein6531
@fernandocorenstein6531 4 года назад
Fantastic videos, very nice to watch and plenty to learn. Thank you for the great content.
@carcedopro7285
@carcedopro7285 2 года назад
its more way better to add .convert() at the end of line when you loading images its give you almost 10x more fps
@Browne24
@Browne24 6 лет назад
does anybody keep getting "invalid character in identifier" error?
@in-sean-mnia2118
@in-sean-mnia2118 6 лет назад
I do yes. However, I cant even fix it because it doesn't tell me where the error is, just that there is one. is this the same for you?
@in-sean-mnia2118
@in-sean-mnia2118 6 лет назад
Oh hey, I actually found out what was wrong in my line of code. So i had copied the lists from the top comment so that i didnt have to type it all and somehow the last ) in the background variable is wrong? so all i did was backspace and re-typed ) hope that helps you as well
@Browne24
@Browne24 6 лет назад
yeah that worked thank you!
@stuey2313
@stuey2313 6 лет назад
what was the problem with the background variable
@HeskeyBoy21
@HeskeyBoy21 5 лет назад
Thank you @In_Sean-mnia replace the bracket at the end of char fixed the issue!!
@UNIPIXEL
@UNIPIXEL 6 лет назад
Did any one go the hard way by typing the "copy pasted" part? Just me? Ok
@h1ts1l24
@h1ts1l24 6 лет назад
your not alone Brothers in loss
@michaelgoedeker9697
@michaelgoedeker9697 4 года назад
You're the man! I was reading through so much documentation, and you helped me bypass reading more.
@matheuscastelhano3442
@matheuscastelhano3442 4 года назад
hey! how do you handle the part he used the global variable function? bc this is no longer available in the news python versions
@kilianmelcher3811
@kilianmelcher3811 4 года назад
OMG THAT LINK TO YOUR SITE IT'S JUST PERFECT, THAT'S REALLY THE BEST PYGAME TUTORIAL EVER HAHA. Sorry I was really excited
@pininduliyanage8643
@pininduliyanage8643 23 дня назад
Wow these lessons are so good!!!
@zeeyadanwar8884
@zeeyadanwar8884 5 лет назад
Thanks for the Link your coding has helped me complete my summer goal on how to code on a program. Your tutorials are excellent, thank you so much. I can't wait to show my program and recommend your channel to my family.
@TechWithTim
@TechWithTim 5 лет назад
Glad you are liking the content!
@Cochise85
@Cochise85 5 лет назад
I wasn't really interested in programming games, just looking for a way to become a better programmer, but low and behold - I've just become a games designer.This gives me some great ideas on developing my own games. Top lesson, thanx.
@TechWithTim
@TechWithTim 5 лет назад
No problem!
@dom_the_whale5140
@dom_the_whale5140 4 года назад
thank you for helping me learn to code. if it was not for you, then i would have probably failed my school grades
@VascoCC95
@VascoCC95 5 лет назад
you can actually load the images in a fairly simple way by creating a for loop (image name is a string)
@xiokraze
@xiokraze 5 лет назад
I put my images in a media folder: walkRight = [ pygame.image.load('Media/R%s.png' % frame) for frame in range(1,10)]
@nou9225
@nou9225 4 года назад
For the animation lists, all you have to do is use list comprehesion and you can save a lot of time.
@scoopydevy
@scoopydevy 3 года назад
guys if your imgs are in another directory this is the code --> pygame.image.load(os.path.join("folder name (directory)","name of file.png" )) (need to import os module)
@powerhawk8207
@powerhawk8207 7 месяцев назад
Great Tutorial! I found that running clock.tick(30) instead of clock.tick(27) makes the game run a little bit smoother withoout any errors
@slange420
@slange420 4 года назад
4:18 You can just use a for loop
@TheWinnieston
@TheWinnieston 3 года назад
yooo, just what I was looking for! Keep it up!
@kaushalsengupta2069
@kaushalsengupta2069 3 года назад
best line- I hope that make sense
@sheersendughosh
@sheersendughosh 5 лет назад
Really loved your videos Tim but didn't understand the jumping part. Rest r awesome!!!!!
@sheersendughosh
@sheersendughosh 5 лет назад
can u please tell from where to find these types of animations more??.
@johannmenezes1521
@johannmenezes1521 3 года назад
why do i get a black screen??
@gerhardkling
@gerhardkling 4 года назад
Great tutorial! Using a modulo operator would be useful as you do not have to set walk_count = 0 after reaching 27.
@dwaghe2444
@dwaghe2444 3 года назад
this is nice very simple and easy good job man!
@afrosamuraj99
@afrosamuraj99 5 лет назад
If you want import your character and dont want to type all time pygame.image.load, just set for example ld = pygame.image.load and do Walkright = [ld('R1.png')],its simpler.
@VikramSingh-hu2hs
@VikramSingh-hu2hs 4 года назад
I'm having error that the image not found even after I put them in a separate directory with the exact name... R1.png like that. Someone help
@VikramSingh-hu2hs
@VikramSingh-hu2hs 4 года назад
Finally... I'm done.. thanks for the turorial
@realnice3672
@realnice3672 3 года назад
could you say to solution i cant figure out.
@estinmyrhaug6896
@estinmyrhaug6896 4 года назад
Using pycharm I put the images in a folder called game and used for loops to load the images # Load player images player_walk_left = [] player_walk_right = [] # Left for img in range(1, 10): print(img) player_walk_left.append(pygame.image.load(os.path.join('Venv/Game', f'L{img}.png'))) # Right for img in range(1, 10): player_walk_right.append(pygame.image.load(os.path.join('Venv/Game', f'R{img}.png')))
@johanalexanderrosariolopez911
@johanalexanderrosariolopez911 4 года назад
Also you can use walkRight =[pygame.image.load('R'+str(i)+'.png') for i in range(1,10) ] walkLeft =[pygame.image.load('L'+str(i)+'.png') for i in range(1,10) ]
@kingjames4827
@kingjames4827 5 лет назад
Please help I copied and pasted Jack Carter's link and it didnt work for some reason it says can't open R1 but then i opened R1 to see if it were corrupted and it wasn't
@pavelbrazda3626
@pavelbrazda3626 5 лет назад
I have the same problem :(, do you know the reason why it's hapening now?
@thestationerydraw2733
@thestationerydraw2733 5 лет назад
I amusing this right now in a classroom! Keep it up
@TechWithTim
@TechWithTim 5 лет назад
What grade level ?
@thestationerydraw2733
@thestationerydraw2733 5 лет назад
@@TechWithTim Well im in ireland so we dont use "Grades" but I am 14 if that helps
@uumatter_0106
@uumatter_0106 5 лет назад
Really good Video I learned a lot!
@jndd7373
@jndd7373 3 года назад
This is awesome! Thank you so much, Tim :D
@lunareclipse07
@lunareclipse07 3 года назад
Instead of writing all of the sprite names out, you can simply do: from glob import glob walkLeft = sorted([pygame.image.load(file) for file in glob("L?.png")] ) walkRight = sorted([pygame.image.load(file) for file in glob("R?.png")]) in python 3 I guess
@pushpahebbar6540
@pushpahebbar6540 4 года назад
You are great we want more videos
@MACHINEBUILDER
@MACHINEBUILDER 5 лет назад
Hey tim! In my IST class (in year 9) my classmates are doing this tutorial! I find that kinda funny lol
@722degrees2
@722degrees2 5 лет назад
what does IST class mean ?
@MACHINEBUILDER
@MACHINEBUILDER 5 лет назад
@@722degrees2 information sciences and technology.. it's basically a computing class
@djhracak
@djhracak Год назад
Hi, this really looks as a great tutorial. Could I just ask a few noob questions? 1. Why do you use 9 images for animations, instead of e.g. 4? Does it make a difference if I use 4 or 5 animations images (in other cases)? 2. Why do you divide the walk_count by 3, instead by some other number (e.g. 4)? Does it really need to be 27 // 3 or could it perhaps be 16 // 4 if there are 4 images in animation? 3. Why do you use numbers inside pygame.display.set_mode, instead of defined variables? For example: pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)? 4. For x and y character starting positions, why do you use fixed numbers, and not SCREEN_WIDTH - CHAR_WIDTH and SCREEN_HEIGHT - CHAR_HEIGHT respectively? 5. Within the jump_count, why do you use numbers (-10) instead of just a negative jump_count variable? Is it better to use the code for jumping as shown in the video or within your website tutorial? Thank you in advance.
Далее
Pygame Tutorial #4 - Optimization & OOP
10:29
Просмотров 194 тыс.
I made Games with Python for 10 Years...
28:52
Просмотров 316 тыс.
Multiple Scenes in Pygame Tutorial (Gamestates)
15:46
Pygame Animation with Sprite Sheets
11:38
Просмотров 75 тыс.
Top 18 Most Useful Python Modules
10:50
Просмотров 928 тыс.
Easy Way to Make Jumping in PyGame! (7 Mins)
7:24
Просмотров 31 тыс.
Pygame Tutorial #1 - Basic Movement and Key Presses
12:32