Pygame Car Racing Tutorial #1 - Moving The Car
Vložit
- čas přidán 8. 07. 2024
- Welcome back to a new tutorial series! In this series, we'll go over making a car racing game in Python. We'll be using one of my favorite modules, Pygame.
💻 AlgoExpert is the coding interview prep platform that I used to ace my Microsoft and Shopify interviews. Check it out and get a discount on the platform using the code "techwithtim" algoexpert.io/techwithtim
📄 Resources 📄
Download Image Assets: dev-cms.us-east-1.linodeobjec...
Code In This Video: github.com/techwithtim/Pygame...
Learn Python OOP: • Python Object Oriented...
Fix Pip (Mac): • How to Install Pygame ...
Fix Pip (Windows): • How to Install Pygame ...
📚 Playlist: • Pygame Car Racing Tuto...
⭐️ Timestamps ⭐️
00:00 | Game Information and Demo
03:02 | Setup and Pygame Installation
06:00 | Loading Images/Assets
08:01 | Creating the Pygame Windows
10:19 | Displaying Images
15:45 | Resizing Images
21:20 | Rotating The Car
34:35 | Key Presses and Turning
36:28 | Acceleration and Velocity
40:21 | Moving The Car By An Angle
47:28 | Slowing Down The Car
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
💰 Courses & Merch 💰
💻 The Fundamentals of Programming w/ Python: tech-with-tim.teachable.com/p...
👕 Merchandise: teespring.com/stores/tech-wit...
🔗 Social Medias 🔗
📸 Instagram: / tech_with_tim
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-ruscica-82631b179
🌎 Website: techwithtim.net
📂 GitHub: github.com/techwithtim
🔊 Podcast: anchor.fm/tech-with-tim
🎬 My CZcams Gear 🎬
🎥 Main Camera (EOS Canon 90D): amzn.to/3cY23y9
🎥 Secondary Camera (Panasonic Lumix G7): amzn.to/3fl2iEV
📹 Main Lens (EFS 24mm f/2.8): amzn.to/2Yuol5r
🕹 Tripod: amzn.to/3hpSprv
🎤 Main Microphone (Rode NT1): amzn.to/2HrZxXc
🎤 Secondary Microphone (Synco Wireless Lapel System): amzn.to/3e07Swl
🎤 Third Microphone (Rode NTG4+): amzn.to/3oi0v8Z
☀️ Lights: amzn.to/2ApeiXr
⌨ Keyboard (Daskeyboard 4Q): amzn.to/2YpN5vm
🖱 Mouse (Logitech MX Master): amzn.to/2HsmRDN
📸 Webcam (Logitech 1080p Pro): amzn.to/2B2IXcQ
📢 Speaker (Beats Pill): amzn.to/2XYc5ef
🎧 Headphones (Bose Quiet Comfort 35): amzn.to/2MWbl3e
🌞 Lamp (BenQ E-reading Lamp): amzn.to/3e0UCr8
🌞 Secondary Lamp (BenQ Screenbar Plus): amzn.to/30Dtafi
💻 Monitor (BenQ EX2780Q): amzn.to/2HsmUPZ
💻 Monitor (LG Ultrawide 34WN750): amzn.to/3dSD7tS
🎙 Mic Boom Arm (Rode PSA 1): amzn.to/30EZw9m
🎚 Audio Interface (Focusrite Scarlet 4i4): amzn.to/2TjXsih
💸 Donations 💸
💵 One-Time Donations: www.paypal.com/donate?hosted_...
💰 Patreon: / techwithtim
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
⭐️ Tags ⭐️
- Tech With Tim
- Pygame
- Displaying Images
- Acceleration
- Velocity
- Algoexpert
⭐️ Hashtags ⭐️
#TechWithTim #PythonGame
If you’re having trouble downloading the assets please try getting them from GitHub! Both links are in the description. :)
hey, im trying to make it such that you can collide with the bot car but the bot cars direction doesnt change. can you make a video on that?
I still can't download it on mac. Can you help : )
My man Tim always keeps coming back to Pygame ❤️ It's so addictive
fr
This is your best Python series yet!!!
I've been waiting for a more advanced Pygame tutorial with OOP and all this angle stuff is great!
Finally, a pygame tutorial that teaches you how to realistically use it. I can't tell you how long I've been looking for one of these. So many of the pygame tutorials out there just show you what you CAN do but never expand on HOW to actually use it, especially not in a real world environment.
Tim is literally the best python youtuber out here saving us from bad professors.
I have learned so much with the previous courses done by Tim for pygame. Through his tutorial, I am now able to create my first game and I have been able to progress my programming skill so much by following his tutorials. Really a Big Thanks to Tim for taking the time to create another awesome tutorial on for this great module.
Wonderful tutorial Tim! This is a very inspiring tutorial! Keep them coming :D!
Loving this series Tim
Thank you for this tutorial. I was looking for movement in a direction and you are the only one who has helped me.
Im proud to be early in this new series
Great video, I'm looking forward to the next one
Love this. I can't believe I'm understanding what you're talking about and I'm not even following along with python. Crazy I've come this far! Also my wife's a math teacher and I told her to show the trig piece to see how math is used in real life.
Thank you Tim for making such great vid.
This is awesome. I think you have explained it quite right.
Best programming channel ever, u really helped me!
Very easy to listen to this guy, no nonsen, free fluent and good tempo.
Love from Nepal, keep inspiring us with these project ideas❤
Thanks, Tim, your tutorials are always inspiring, they make me push my limits. I am having some challenges using pygame's Joystick module and the hat-keys on the gamepad for rotating and moving a sprite, I would be glad if you could help me out with that. Thanks once more Tim.
Keep up the good work. I love your videos.
Love it Tim your the best coder on youtube thanks for doing it really appreciate it
Keep up the great work!
reliable tim. Been following u since 2018!
I have a game idea. Started with gamemaker a year and a half ago. But they kept changing/upgrading the engine which is good for the people who use it, but is hell for someone who doesnt know how to program. Then, my licence expired after a year, and everything stopped for me. Recently they changed the licencing terms, and got to think about continuing on my game. But, even tho i did learn some programing with GM, i felt something was wrong. So i started to learn python.
Now, i am still grasping the basics, but i have better understanding how code works. How things are structured. Im learning how to program, not how game engine works, and what are its features.... Even tho i finally understand why some things in GM are the way it is.
This tutorials are still over my grasp, but still i like to check them out, look at the concepts, how you structure things, how you use something.
One day i will make my masterpiece :D
damn it tim! your killing us! keep it coming!!!!!!
Love from Ethiopia, Thanks for the video Tim !
Me too.
Thank you very much for posting this!
Congrats on one mil subscribers
Great tutorial. Took a while to understand that rotated image center. Got it! Thanks
hey ET TEO i need your help in my car racing porject game please send me your emial id or something wos that i can contact you i really need an urgent hel of yours please provide me your contact please reply to the comment urgently need your help please help in image rotation please help me it would great ehlp from your side i m from INDIA please help me please
love ur channel!
Idk how to Thank you back? I guess Thank you is the only thing I can do. Thanks Tim
We really want like this type of awesome projects
So cool tutorial thanks a lot keep going
Respect boy. You‘re a boy with talent
Bro thanks for this lesson... trying to make mine now ❤️❤️❤️
I really like your python videos
theire the best
very nice and clear turorial!
hey J2frosty i need your help in my car racing porject game please send me your emial id or something wos that i can contact you i really need an urgent hel of yours please provide me your contact please reply to the comment urgently need your help
Just thought yesterday let's make a pygame project . I earlier make a pygame ball game but due to some reason I lost that..😓 .So I thought to recreate the game . But I forgot the pygame syntax. Now I got a tutorial to brush up my memory. Tim you are a mind reader.....
this little car project kicked my butt lol
I'll try to get along as Tim is good at instructing
Nice job!!
so hardworking boy😨❤️❤️❤️❤️
It's fun to watch when he talks about trigonometry "A NERDS CANDY" banner sneaks in to the frames. :-)
Thank You! Now I have to play Dirt rally 2 and Car Racing pygame 😉
Niiice ! We like more advanced stuff in Python
hey tim i need your help in my car racing project game please send me your emial id or something wos that i can contact you i really need an urgent hel of yours please provide me your contact please reply to the comment urgently need your help
Glad Tim's back with a pygame tutorial, but it is any one else having problems with the assets link?
Love from India ❤️, thank you for ameging video 😀.
Thanks for watching!
I FOUND IT INTERSTING, THANKS FOR YOUR UPLOAD AND LECTURING, GOD BLESS
I forgot to appreciate you for making the codes available. God bless you in His Will. Thank you
thanks tim 🤍🔥
New Tim album drop lets goooooo
"dont worry abt inheritance" continues to give a basic description of inheritance lol
Hey, Tim can you tell me what game engine did you use for your "12 hour coding Livestream" about a year ago
Damn that is some heavy maths right there, I should've focused more on my maths class damn.
my fan :)
Hey Tim Tim🔥🔥
This is nice series. I would like to do this but only using tkinter, time and math I guess.
Didn't realize I was going to get a good Kahn Academy math less in trig with my awesome PyGame tutorial! Thanks Tim! (what was up with the nerds photo-bombing your paint window though?)
thx tim
Hey can some one tell me that in my screen the window that we create is really big. How can I make it small? I have given its height and width equal to that of track.
In the starting of video, Tim : I will try my best to explain everything.
In the middle of video, Tim : I don't know I just copied the code from stackoverflow.
by the way great series as always Tim.
Goat
Waiting for more
thank you
How we can extract border of the track from image???
Hey Tim,
I am using a chromebook and when I try clicking on the same img link it isn't loading.
I tryed copy and pating in new browser but it's just plain white.
Is it because I am using Chrom OS?
how do i make it so the top of my window is orange like at 18:45
Thanks
Tim What is that thing came into the screen when you explaining angles on paint?
And also we are waiting for the next video...
This series is awesome and i am looking forward for you tutorial on chess in pygame i made a bit of it but got stuck.
Wow chess and pygame, amazing 🤩
Hey Tim, do you have the tutorial on your website?
Would that car movement work with camera movements in something like THREEjs?
I like how he explain the video
My man
anyoneknows why the class was created in the way it was. I mean why specific variables were defined as class attributes and specific variables were taken in innit. Is there any reason in particular for that, is there something we should keep in mind while defining class attributes and innit arguments ??
Hello Tim,
Are you planning on applying Reinforcement learning or Genetic Algorithm like Neat on this game later when you finish coding the game?
I would love that too
I still need more work with the trigonometry; do you have a trig tutorial?
can you make more of the opencv series?
where did you download the images from? the antivirus says they have something malicious
Congratulations on being early, claim your before 100k views 🍪 here
On the line of code that says:
blit_rotate_center(win, self.img, (self.x, self.y), self.angle)
There was an error that said:
blit_rotate_center() takes 3 positional arguments but 4 were given.
Can someone help me out?
Pygame is love pygame is life.
So i have a problem in this part 31:21 ,I always get the Unresolved attribute reference 'IMG' for class 'AbstractCar also for the START_POS. Also in the def draw(win, images), I got this Shadows name 'images' from outer scope . I tried using chatgpt to find whats wrong, it give me a code where i put super. in class PlayerCar, and after that, it doesnt show anything. Please help me, I'm stuck here and I still don't know what to change.
did you refer to his code in github??
Hi Tim, can't do pygame in vscode:
"pygame" is not accessedPylance
Import "pygame" could not be resolvedPylancereportMissingImports
Do you have any suggestions?
thanks
No way he is actually doing this!!!
Hey Tim what’s your color scheme it looks amazing!
i wanna download python and i noticed that your version is not the latest. which should i download and how?
Hi, you didn't mention which version of Python and Pygame you are using here?
how would you implement another car thats the exact same?
45:34 Can someone tell me why we have to use cosine for the vertical component?? Aren't we supposed to use sine as sinA = p/h
me too i was so confused when i saw it
actually now that i think about it, maybe it's because the car starts in an upright position on 0 degrees. let's say we want to move the car ONLY forward, on speed v. then y = v, but sin of 0 is undefined. if we calculate using sin (0) the equation would be wrong. instead we have to calculate using sin (90 + 0) * v so that y = v . so in all of our equations we have to add 90 to that angle. and with trig, we know that sin(90 + a) = cos a, and cos (90+a) = - sin a. hope that helps!
Tim’s cute
Keep it going
can you teach me how to code a game from start to finish, because I'm still a beginner and just learning code
Hi .. i am new to python .. can you help me by some solution .. from your code
i need position value of car how can i get this
hello from Brazil
why not use sprite classes?
Hi tim
I have an error that says: No file 'imgs/grass.jpg' found in working directory.
What can I do?
@Tech With Tim. please respond
Aren't the sin and cos flipped in the code?
Haha remeber where I learned this
do I have to learn trig for this????
When I tried accessing your website for the track border and track it just keeps crashing how do i fix this?? Or is you site down ??
Thanks Bro Love the vids
Can the game be converted to multiplayer?
it is showing error in line 15 but i have written the same code that you have written