aha! you're using the floor division arithmetic operator, eh?? 😉 It's definitely an extra elegant alternative to my int() conversion, thank you so much for sharing the tip!! 😁😁😁
You can’t use width/2 because you need integer number and since width/2 returns floating point number you need to convert it to integer. Two ways to convert it is use int(width/2) or width//2
@@realmadwolf the operator "a/b" != "a//b" != "a%b" -- the subtleties of syntax of different "languages". In some syntax you have to use "ab" or "a NOT b".
You rock! I'm teaching python to my 9 y.o. I taught him Scratch when he was 7 y.o., and now it's time for him to learn a real programming language. But all the talk of strings and arrays are not at all interesting to a child. We tried a snake program, but it lacked line numbers and contained several errors. Then I found your channel and you're awakening the 9 y.o. within me, making coding fun again! 👍🙂👍
Great tutorial. You’re covering what I’m doing with my school aged son, but you’re way quicker and more accurate. He’ld love it if he got to your level one day. You’re a great role model.
You really do a way better job teaching coding than other channels. Other tutorials are the same old scripts over and over never really explaining the syntax, just saying "type this" .. keep up the awesome work!
Very nice tutorial! I love how thought through the process seems while still keeping it light and fun. I also like the fact that you actually create a working game before the sponsor ad is run as it keeps the flow and add bonus instead of making the video into a two part one like most of the creators seem to do. The only thing i would add in a beginners guide is a ToDo list commented into the code for easy progression and structured work flow.
Thanks for this tutorial Maria! I'm going to make some minor changes (add a motorcycle and sand instead of a second car and grass) and add it to an upcoming video I have for a podcast episode on the book 'Zen and the Art of Motorcycle Maintenance'. I will link back to this video for my viewers that are interested in creating games with Pygame. Nice t-shirt too by the way!
Me too! It's actually available since Oct 2020 but not too many people heard about it! 🙃 I think the biggest holdback is that Anaconda still didn't update its package to the current version so you can only install Pygame 2 with "pip install pygame". I believe that's a big part of the problem! With "conda install -c cogsci pygame" folks receive a message in the terminal that "Pygame only works with Python 2.7 - 3.5" but they don't realize it refers to Pygame 1 so it's a total Anaconda mess up! 🤪 And thank you so much for the lovely comment!! I'm really happy you like my tutorials! 😀😀😀
Thanks so much for this!!! Have been talking through the design phase of a game my 6 year daughter wants to create called Shark Catcher... My office wall is covered in design notes and sketches she has been creating and it is time we started dev. I code Python everyday but never Pygame so this tutorial / live coding example is a great framework for us to bootstrap from. Especially happy that my daughter has such a well versed female tutor / role model who is able to communicate quite difficult principles in such a understandable way! Will be sure to share our fork with you for you to review and play. Personally I have been coding for over 20 years now but still learn at least one thing new in every one of your videos (sometime many and totally new new design patterns) Please keep up the excellent work, it is very much appreciated!!! Rob
That's awesome, Rob!! I can't wait to see Shark Catcher in action! 🤩🤩🤩 Creating software and learning coding at 6 is VERY impressive!! Sounds like you have a young Elona Musk at home! 😉 I hope to have an entire "Python for kids" series by the time she's old enough to independently study. I've been planning it for a while but still stuck on picking the best coding interface to use (I hope I won't need to build one 😅) Super happy to hear you enjoy my tutorials! I have some really nice projects in the making: Tkinter+SQLite Random Recipe Picker and comparing the exact same C++ app with a Python app, so definitely stay tuned! 🙂 Also, thank you so much for the incredible comment! Best of luck with Shark Catcher! 😃😃😃
Great video, as usual. I notice someone else commented on a new(?) microphone setup. This might just be a "me" thing, but my subwoofer is very triggered by the typing in this video. 🥁
Hi Graydon, this video was filmed with the old mic 😀 it was still in shipping when I premiered this one (now I'm only waiting for the fancy arm which was supposed to arrive yesterday, but never happened 😨) The new mic will be featured in the upcoming Numpy tutorial so hopefully you'll hear it this Thursday 😊
Mariya, sorry I had to leave the lesson earlier. I just finished watching it now and this helped me a toooon. Also, I checked your mic and looks awesome. I hope it sound as good as it looks. If you have questions about EQ your voice, don't hesitate to ask. Again, thank you for the lesson 😊
Hi Mariya, thanks for your little example. I change it a litle bit. Iam using it for my first reinforcement learning project. PS: python is my absolute favorite programming languaqe. Regards form germany. Joerg
I've been working on a game (in finger quotes) that also involves a stream of vehicles for what seems like a really long time. Some it's become really complex and doesn't work half the time. And yours seems to comparatively simple versus mine. I mean mine was made partially to help learn things like OOP. But it is jarring to seem something so simple do what I can only sometimes do in so few lines. So thanks for that.
Congratulations! you increased the font, it was great I could see it from my smartphone, my kids will like it a lot, one question, will there be the end of the game?, because it looks like you didn't finish it, right?...
so, as with many small projects like this a common error in using visual code is the dreaded "FileNotFound" error because the working directory doesn't synch with the actual directory where the images are stored. In my case, the default working dir is the root dir above the subdirectory i put this in. So, if others are having similar issues, just change the working dir in code. Add this at beginning after tge other import directives: import os os.chdir(os.path.dirname(os.path.abspath(__file__)))
The game actually ends when you park in front of the Parliament in Ottawa on level 10... and then they also take you to jail 😅😅😅 (a reference that only Canadians or folks who follow independent media will understand 🤪)
I never heard of Pygame before, I decided to attempt at cloning an old an atari 2600 and a speccy game on python. One thing I do know having to rewrite code due to duplication of the cars, moving charactors always must been drawn last. I sometimes think of it as CAD and how I drew the machinary for 1 of the swimming pools. I have followed this video to produce a little program that depicts a well on the old ET game.
So it’s always an exciting moment to learn with you ❤ I’m not a native English speaker but i understand easily when you explain something 🎉Be blessed From 🇭🇹
Hey Maria is there a way by which I can rum my pygame code along with kivymd login screen into an android app. It generally shows an error ie, android only supports one window. Is there a solution for it ....
tom & jerry :) another great video, thanks! if you run out of content ideas it would be neat to see a video using machine learning to give you advantage in a game (something like checkers, chess, starcraft, hearthstone, etc)
Hi Ali, great to see ya! 😀😀😀 You can actually implement a very fancy UI with Pygame, not only games! I just had this game stuck in my head as I was playing it as a kid on my Tetris console... I had to implement it before I cover anything else that this library has to offer! 😊
@@PythonSimplified you can't be happier than me when I see you haha! Mariya, aren't u focused on AI stuff nowadays? (Well I would happily learn anything you teach. You can try something like cooking as well 😁)
I suggest you to also cover Godot Engine, the language GDScript is close to Python and it has a lot of built-in nodes/classes to help create 2d and 3d games but also interfaces (the software interface is made by his own nodes).
I respect it but this channel is totally dedicated to python and GDScript's syntax is mostly derived from Python, but it doesn't support all of the language features that Python does 😊
I guess the point here is to learn pygame basics as a convenient input/visualization interface that can be used for many purposes by python users. Someone who is really looking to make and publish a 2D game would not use pygame in the first place, but something like Unity or Godot.
Tutorials like these are very interesting, if i see how many People need to develop a whole Game :D Currently i have a Side Project with python Ursina (Its a similar Game Engine like pygame) and i will create a Crash Bash and a normal Crash Bandicoot FAN Game with this Engine. The logical Part of Programming is in my Case not the Problem, later i must create some Animations, Textures and Models for this Game and make all that compatible with this Engine :-D
I only get a collision on the right hand side but not the left. My image size was larger which ive accounted for but it just goes right through on the left hand side
Overall, this was a good video, but I do have two issues with it. First off, you made more work for yourself than you needed to with regards to checking for collision of the cars. Your long "if" statement could have been replaced with a call to colliderect() using the image rects. Second was a missed opportunity. This program's relative speed is beholden to your CPU speed. The proper way to control the speed of your game is to use a pygame.time.Clock() object where you can confine the game to a set FPS and have consistent results across different machines. This is an absolute must for designing realtime games in pygame and I was surprised to see it missing here.
How does the draw function work? Having it redraw in the while loop does it write over the previous or just slap a new copy on top. Would that eventually have memory leak issues?
Hi! Nice video! I've tried your code and I've noticed some kind of a bug. If you hit twice the left key an image of the car appears out of the lane. Same thing for the right key. To solve the bug I've introduced two variables before the while loop: left = 0 and right = 0 . So my code while pressing is if event.type == KEYDOWN: if event.key in [K_LEFT] and left == 0: car_loc = car_loc.move([-(road_w/2),0]) left = 1 right = 1 if event.key in [K_RIGHT] and right == 1: car_loc = car_loc.move([(road_w/2),0]) left=0 right = 0 It seems to work but I don't understand if it is THE proper way to achieve that.
I found out the same bug too, and she did in fact talk about solving it on our own. I'm a little late there, but here's my solution: if event.type == KEYDOWN: if event.key in [K_a, K_LEFT] and car_loc.center[0] == right_lane: car_loc = car_loc.move([-int(road_w/2), 0]) if event.key in [K_d, K_RIGHT] and car_loc.center[0] == left_lane: car_loc = car_loc.move([int(road_w/2), 0]) So it's nothing too different from the original code, except I put in some additional conditions: car may only go left if car_loc.center[0] (which is its x coordinate) is equal to the value "right lane". Similar thing for going right but instead, I put "left lane" there instead of "right lane". Simply put, car can only go left if it's not already on left side of the road (we don't want it to go out of bounds), and same thing if car wants to go right .
Yeyyyy Udbhav!! I'm super happy you liked it!! 😁😁😁 We can expand this game and add lots of new things like a start screen with a "play" button, a high score screen (combined with a database that keeps track of all the previous games too). We can also add music, sounds effect, nudging animation for both vehicles to convey combustion, as well as trees, holes in the road or other obstacles like bears crossing or flooding, etc. These are just some of the ideas I had in mind, but they would make this video a few hours long so I decided to stop as soon as the game is fully functional 😊 I'll probably keep expending it and create a follow-up tutorial in the future which will definitely keep track of the high score 😉
@@PythonSimplified I'm waiting for the next part of pygame video 🤝😄 Change the title of your video pygame to (pygame tutorial part- 1) but make sure that no one can see you doing that. XDD even John cena 🥴 Lol.
Dear Mariya, thanks for all your amazing videos.. May I ask for a video that is sort of a composite of 2 videos you already made? Creating a exe file of a project that makes use of torch/torchvision since it is very difficult and there are tons of people online failing at it. Would be great.. thank you!
Sure, I'll look into it! It will take me some time to get there but it's officially on my "to do" list 😊 Thank you so much for the suggestion and for your lovely comment, Igor! 😃😃😃
Great video, you explained each point really well. I couple of questions,1-How do we learn the visual part, i mean about the game screen, in your another video, you used OpenCV for drawing trees . Is there any special video where we can learn to draw step by step for our game screens? 2- Secondly what if we wanted to display messages of level up and game over on the game screen, not terminal and add cools sound effects, e.g car sounds , and car crashing sound.
I learnt python but don't where to use for loop while define classes objects and all other basic and advance things because I want to create a app but how to change code into a gui
Both the end game / collisions aswell as the speed increments just don't work for me, i first tried when i "copied" it myself and then when that didnt work i copied all your code from github and it just doesn't work, no idea why...
That's awesome!! Super happy to hear that Arijan! 😁 I'll start working on a new Tkinter tutorial once I'm done covering Numpy (filming it tomorrow if my new fancy microphone arrives today) 😉 Still not sure what kind of application it would be... I'm aiming for something that has to do with sound and audio 😊
Which editor I use for python And my some programs wrong bcz latest version of python installed then also programs wrong I write in correct way then also show error like indentation
Hello Hello from the West Coast! 😀 Entrepreneurship is a very big topic and I wouldn't trust programmers with advices on the matter as creating a product and turning this product into a fully-functional profitable business are completely different things. Entrepreneurs usually start with a problem that concerns a big portion of the population, so you think of what audience you want to target first, then you think "what is the biggest problem I am able to solve for this audience", next you think of how can you make money from this solution while conducting a full-market research and only then you try to implement it. Programmers very often start from the implementation and only when the product is ready they think of "OK, now how can I make money from it?" or "will somebody pay me for it?" which sometimes works, but often doesn't turn into a profitable venture. I would consult with somebody who is either an established business person, a marketing adviser or something along these lines. I must admit, I do have some background in marketing, but I've never used it to create my own personal business (Python Simplified was a hobby of mine, I didn't expect it to turn into an actual business therefore it doesn't really count 😉) so I'm lacking the on-hands experience that would make my advices credible... for now, everything I wrote above is just theory 😅 But yeah, if it's an implementation - I'd love to help! if it's business advice, I don't believe I'm qualified at this point of time 😉 Good luck and cheers from beautiful British Columbia! 😊
I'm using Visual Studio Code in Debian Linux on Chromedome using Python 3.9.2 64-bit Question: I have pip3 installed pygame through the terminal inside VSCODE and it recognizes it. It doesn't recognize "event" It gives me the option to import from tkinter. How should I import "event"? I apologize as im new to VSC coming from IDLE
I hope this will help a little with your English... These ( ) are not brackets, they are parentheses. There are two kinds of brackets... Curly Brackets { }, and Square Brackets [ ]. This one is Open parentheses (, and this one is closed Parentheses ). I hope this is helpful. 🙂 It's pronounced Pa Ren theh seas.
Thank you so much Richee! 😀 VR and AR are quite a big topic jumps from what we currently cover on the channel. It involves a very large degree of graphics and 3D modelling in addition to code... It's not on my "to do" list but I also never say never! 😉
Yup! you'll need to set some limitations to the move commands (I've briefly mentioned it in th video) 😃 Try a conditional statement that only moves the vehicle if it's located within certain bounds (move left, only if vehicle is in the right lane and etc.) This will fix it! 😉
Dear Mariya, width // 1.6 and Int( width / 1.6 ) gives exactly the same result. Tested many times and I always use the first solution.
aha! you're using the floor division arithmetic operator, eh?? 😉
It's definitely an extra elegant alternative to my int() conversion, thank you so much for sharing the tip!! 😁😁😁
@@PythonSimplified no problem. I'm always here to help
so does it matter which one to use ? like can we use width/2 ? cuz it seems easy kind.
You can’t use width/2 because you need integer number and since width/2 returns floating point number you need to convert it to integer. Two ways to convert it is use int(width/2) or width//2
@@realmadwolf the operator "a/b" != "a//b" != "a%b" -- the subtleties of syntax of different "languages". In some syntax you have to use "ab" or "a NOT b".
You rock! I'm teaching python to my 9 y.o. I taught him Scratch when he was 7 y.o., and now it's time for him to learn a real programming language. But all the talk of strings and arrays are not at all interesting to a child. We tried a snake program, but it lacked line numbers and contained several errors. Then I found your channel and you're awakening the 9 y.o. within me, making coding fun again! 👍🙂👍
Thank you for your amazing content as usual. Have an amazing day!
Great tutorial. You’re covering what I’m doing with my school aged son, but you’re way quicker and more accurate. He’ld love it if he got to your level one day. You’re a great role model.
You really do a way better job teaching coding than other channels. Other tutorials are the same old scripts over and over never really explaining the syntax, just saying "type this" .. keep up the awesome work!
Very nice tutorial! I love how thought through the process seems while still keeping it light and fun. I also like the fact that you actually create a working game before the sponsor ad is run as it keeps the flow and add bonus instead of making the video into a two part one like most of the creators seem to do. The only thing i would add in a beginners guide is a ToDo list commented into the code for easy progression and structured work flow.
Thanks for this tutorial Maria! I'm going to make some minor changes (add a motorcycle and sand instead of a second car and grass) and add it to an upcoming video I have for a podcast episode on the book 'Zen and the Art of Motorcycle Maintenance'. I will link back to this video for my viewers that are interested in creating games with Pygame. Nice t-shirt too by the way!
I had no idea Pygame finally moved to Python 3. Like your other videos this is clear and straight to the point. Excellent work, and thank you!
Me too! It's actually available since Oct 2020 but not too many people heard about it! 🙃
I think the biggest holdback is that Anaconda still didn't update its package to the current version so you can only install Pygame 2 with "pip install pygame". I believe that's a big part of the problem!
With "conda install -c cogsci pygame" folks receive a message in the terminal that "Pygame only works with Python 2.7 - 3.5" but they don't realize it refers to Pygame 1 so it's a total Anaconda mess up! 🤪
And thank you so much for the lovely comment!! I'm really happy you like my tutorials! 😀😀😀
Great job! Also happy to see another Canadian RUclipsr!
This step-by-step approach is excellent! Great teaching style. well done.
Yeah, it definitely helped Me.
dear mariya! you,re great i have learnt many things from your video.......keep it up and upload these type of videos😍😍😀😍👍
I really love your tutorials on Python. You make complex programming syntax look easy. Huge thumbs up.
Bon travail, félicitations Mariya.
Thanks so much for this!!!
Have been talking through the design phase of a game my 6 year daughter wants to create called Shark Catcher...
My office wall is covered in design notes and sketches she has been creating and it is time we started dev.
I code Python everyday but never Pygame so this tutorial / live coding example is a great framework for us to bootstrap from.
Especially happy that my daughter has such a well versed female tutor / role model who is able to communicate quite difficult principles in such a understandable way!
Will be sure to share our fork with you for you to review and play.
Personally I have been coding for over 20 years now but still learn at least one thing new in every one of your videos (sometime many and totally new new design patterns)
Please keep up the excellent work, it is very much appreciated!!!
Rob
That's awesome, Rob!! I can't wait to see Shark Catcher in action! 🤩🤩🤩
Creating software and learning coding at 6 is VERY impressive!! Sounds like you have a young Elona Musk at home! 😉
I hope to have an entire "Python for kids" series by the time she's old enough to independently study. I've been planning it for a while but still stuck on picking the best coding interface to use (I hope I won't need to build one 😅)
Super happy to hear you enjoy my tutorials! I have some really nice projects in the making:
Tkinter+SQLite Random Recipe Picker and comparing the exact same C++ app with a Python app, so definitely stay tuned! 🙂
Also, thank you so much for the incredible comment!
Best of luck with Shark Catcher! 😃😃😃
Mariya, thank you very much for you help with this tutorial. Your teaching style is very clear and concise. Much appreciated.
Great video, as usual.
I notice someone else commented on a new(?) microphone setup.
This might just be a "me" thing, but my subwoofer is very triggered by the typing in this video. 🥁
Hi Graydon, this video was filmed with the old mic 😀 it was still in shipping when I premiered this one (now I'm only waiting for the fancy arm which was supposed to arrive yesterday, but never happened 😨)
The new mic will be featured in the upcoming Numpy tutorial so hopefully you'll hear it this Thursday 😊
It was very interesting!
Thanks for another great guide!
Also I loved the shirt! 😁
Kinda genius, I managed to complete the tutorial and got a lot out of it. Thank you!
Mariya, sorry I had to leave the lesson earlier. I just finished watching it now and this helped me a toooon. Also, I checked your mic and looks awesome. I hope it sound as good as it looks. If you have questions about EQ your voice, don't hesitate to ask. Again, thank you for the lesson 😊
Hi Mariya, thanks for your little example. I change it a litle bit. Iam using it for my first reinforcement learning project.
PS: python is my absolute favorite programming languaqe. Regards form germany. Joerg
I've been working on a game (in finger quotes) that also involves a stream of vehicles for what seems like a really long time. Some it's become really complex and doesn't work half the time. And yours seems to comparatively simple versus mine. I mean mine was made partially to help learn things like OOP. But it is jarring to seem something so simple do what I can only sometimes do in so few lines. So thanks for that.
Congratulations! you increased the font, it was great I could see it from my smartphone, my kids will like it a lot, one question, will there be the end of the game?, because it looks like you didn't finish it, right?...
so, as with many small projects like this a common error in using visual code is the dreaded "FileNotFound" error because the working directory doesn't synch with the actual directory where the images are stored. In my case, the default working dir is the root dir above the subdirectory i put this in. So, if others are having similar issues, just change the working dir in code. Add this at beginning after tge other import directives:
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))
Thanks to your tutorial, Mariya, I've managed to draft my own version of River Raid, something I've been desiring to do for the last 30 years 🤪😇
You understand very decent all the process while you are creating the video game.Also your English are very comprehensive!!
I got to level 2 in this game, then a police car blocked the road and took me to jail. Great work, Python Lady 👍
The game actually ends when you park in front of the Parliament in Ottawa on level 10... and then they also take you to jail 😅😅😅
(a reference that only Canadians or folks who follow independent media will understand 🤪)
I watched the entire thing, it's a great introduction and looks like pygame is the way to go for a little dice roll app I'm making.
Thanks. Great tutorial. Now I can saw my son that if he learn python he will able to make games...maybe not Minecraft but still 🙂
Thank you Mariya for the tutorial, much appreciate
Thank you so much. Just finished making the game. Took me like 4 hours but yeah. Progress. Haha
I never heard of Pygame before, I decided to attempt at cloning an old an atari 2600 and a speccy game on python. One thing I do know having to rewrite code due to duplication of the cars, moving charactors always must been drawn last. I sometimes think of it as CAD and how I drew the machinary for 1 of the swimming pools. I have followed this video to produce a little program that depicts a well on the old ET game.
great job.
Thank you from Nova Scotia
Do u know about any python gui library that supports vulkan. Pyimgui does not have a vulkan backend
So it’s always an exciting moment to learn with you ❤ I’m not a native English speaker but i understand easily when you explain something 🎉Be blessed
From 🇭🇹
Hey Maria is there a way by which I can rum my pygame code along with kivymd login screen into an android app.
It generally shows an error ie, android only supports one window.
Is there a solution for it ....
Thank you .
Your video increased my confidence
Looking forward to this very much !
Yey! I hope you found it helpful! 😀
tom & jerry :) another great video, thanks! if you run out of content ideas it would be neat to see a video using machine learning to give you advantage in a game (something like checkers, chess, starcraft, hearthstone, etc)
Hi Mariya! How are you 🙂🙂
Was never interested in games but going to watch this whole tutorial haha
Hi Ali, great to see ya! 😀😀😀
You can actually implement a very fancy UI with Pygame, not only games!
I just had this game stuck in my head as I was playing it as a kid on my Tetris console... I had to implement it before I cover anything else that this library has to offer! 😊
@@PythonSimplified you can't be happier than me when I see you haha!
Mariya, aren't u focused on AI stuff nowadays?
(Well I would happily learn anything you teach. You can try something like cooking as well 😁)
Great tutorial . I will follow more of Your tutorials.
thank you soo much, I learned a lot!
I suggest you to also cover Godot Engine, the language GDScript is close to Python and it has a lot of built-in nodes/classes to help create 2d and 3d games but also interfaces (the software interface is made by his own nodes).
I respect it but this channel is totally dedicated to python and GDScript's syntax is mostly derived from Python, but it doesn't support all of the language features that Python does 😊
I guess the point here is to learn pygame basics as a convenient input/visualization interface that can be used for many purposes by python users. Someone who is really looking to make and publish a 2D game would not use pygame in the first place, but something like Unity or Godot.
Thanks for you info sister.😊😊😊😊
Tutorials like these are very interesting, if i see how many People need to develop a whole Game :D Currently i have a Side Project with python Ursina (Its a similar Game Engine like pygame) and i will create a Crash Bash and a normal Crash Bandicoot FAN Game with this Engine. The logical Part of Programming is in my Case not the Problem, later i must create some Animations, Textures and Models for this Game and make all that compatible with this Engine :-D
I only get a collision on the right hand side but not the left.
My image size was larger which ive accounted for but it just goes right through on the left hand side
My favorite channel
Yeeeeey!!! Thank you so much Amanual!!! 😁😁😁
Wow awesome 😎 you make python programming more easier and enjoyable. Thanks for sharing.
umm your pygame tutorials are pretty well-made keep it up
Overall, this was a good video, but I do have two issues with it.
First off, you made more work for yourself than you needed to with regards to checking for collision of the cars. Your long "if" statement could have been replaced with a call to colliderect() using the image rects.
Second was a missed opportunity. This program's relative speed is beholden to your CPU speed. The proper way to control the speed of your game is to use a pygame.time.Clock() object where you can confine the game to a set FPS and have consistent results across different machines. This is an absolute must for designing realtime games in pygame and I was surprised to see it missing here.
How does the draw function work?
Having it redraw in the while loop does it write over the previous or just slap a new copy on top.
Would that eventually have memory leak issues?
why are there double parenthesis for things like the pygame.display.set_mode expression?
beautiful work and good luck 💙
Hi! Nice video!
I've tried your code and I've noticed some kind of a bug. If you hit twice the left key an image of the car appears out of the lane. Same thing for the right key.
To solve the bug I've introduced two variables before the while loop: left = 0 and right = 0 .
So my code while pressing is
if event.type == KEYDOWN:
if event.key in [K_LEFT] and left == 0:
car_loc = car_loc.move([-(road_w/2),0])
left = 1
right = 1
if event.key in [K_RIGHT] and right == 1:
car_loc = car_loc.move([(road_w/2),0])
left=0
right = 0
It seems to work but I don't understand if it is THE proper way to achieve that.
same here... i was looking for a solution
Worked for me mate. Thanks for sharing.
I found out the same bug too, and she did in fact talk about solving it on our own. I'm a little late there, but here's my solution:
if event.type == KEYDOWN:
if event.key in [K_a, K_LEFT] and car_loc.center[0] == right_lane:
car_loc = car_loc.move([-int(road_w/2), 0])
if event.key in [K_d, K_RIGHT] and car_loc.center[0] == left_lane:
car_loc = car_loc.move([int(road_w/2), 0])
So it's nothing too different from the original code, except I put in some additional conditions: car may only go left if car_loc.center[0] (which is its x coordinate) is equal to the value "right lane". Similar thing for going right but instead, I put "left lane" there instead of "right lane".
Simply put, car can only go left if it's not already on left side of the road (we don't want it to go out of bounds), and same thing if car wants to go right
.
Very understandable. I love t. Already subscribe
Very useful !!! 🏆🏆🏆Thank you so much !!!
Finally finally pygame is here..
best tutorial ever!!👏👏why don't you write high score thing ?
Yeyyyy Udbhav!! I'm super happy you liked it!! 😁😁😁
We can expand this game and add lots of new things like a start screen with a "play" button, a high score screen (combined with a database that keeps track of all the previous games too).
We can also add music, sounds effect, nudging animation for both vehicles to convey combustion, as well as trees, holes in the road or other obstacles like bears crossing or flooding, etc.
These are just some of the ideas I had in mind, but they would make this video a few hours long so I decided to stop as soon as the game is fully functional 😊
I'll probably keep expending it and create a follow-up tutorial in the future which will definitely keep track of the high score 😉
@@PythonSimplified I'm waiting for the next part of pygame video 🤝😄
Change the title of your video pygame to (pygame tutorial part- 1) but make sure that no one can see you doing that. XDD even John cena 🥴 Lol.
Omg this is awesome content. Thank you!
your videos always helped always taught me about some interesting and useful 🥰♥️ thanks Soo much I am your big fan
Thank you so much for the lovely comment Abdul! 😀😀😀 I'm super happy to help!
Dear Mariya, thanks for all your amazing videos.. May I ask for a video that is sort of a composite of 2 videos you already made? Creating a exe file of a project that makes use of torch/torchvision since it is very difficult and there are tons of people online failing at it. Would be great.. thank you!
Sure, I'll look into it! It will take me some time to get there but it's officially on my "to do" list 😊
Thank you so much for the suggestion and for your lovely comment, Igor! 😃😃😃
Loved it thank you so much i found what i was missing
Congratulations again, may God bless you more and more. thanks for helping me train and learn Python.
"god" is just an imaginary friend that never helps, Evolution is True.
I think you is 🔥🔥🔥 girl 😍, nice vid btw 👍🏼
Excellent Tutorials!!
Thanks for awesome Explanation
You're absolutely welcome! enjoy! 😊
Great video, you explained each point really well. I couple of questions,1-How do we learn the visual part, i mean about the game screen, in your another video, you used OpenCV for drawing trees . Is there any special video where we can learn to draw step by step for our game screens? 2- Secondly what if we wanted to display messages of level up and game over on the game screen, not terminal and add cools sound effects, e.g car sounds , and car crashing sound.
I learnt python but don't where to use for loop while
define classes objects and all other basic and advance things
because I want to create a app but how to change code into a gui
first project done very happy
First thought: She is gonna create Spy Hunter video game! Good presentation though.
Both the end game / collisions aswell as the speed increments just don't work for me, i first tried when i "copied" it myself and then when that didnt work i copied all your code from github and it just doesn't work, no idea why...
Hi! Where did you get the photos for the cars?
new subscriber here, thank you so much for this, as a beginner this is very good tutorial.
una duda: como haces un personaje que empuje un objeto pero al mismo tiempo colisione con el
Hello @PythonSimplified, I have a question. My enemy car is not moving as fast as yours and mine is also leaving a trail. How do I fix that?
You' re amazing... Thanks for sharing!!!
Thank you so much Michael! I'm happy to help! 😀
great video your videos always motivate me to learn python further great videos ma'am love your videos
I did today the tkinter tutorial THX best timing for me 😍😍😍
That's awesome!! Super happy to hear that Arijan! 😁
I'll start working on a new Tkinter tutorial once I'm done covering Numpy (filming it tomorrow if my new fancy microphone arrives today) 😉 Still not sure what kind of application it would be... I'm aiming for something that has to do with sound and audio 😊
Hello i m interesting in learning python and want to know if there is a market especially in freelancing thnks
BBBIIIIGGGG THANKS 🙏 👍👋😀😃😄🤩🤩🙋♀️👍🎈🎉🎊
Super, Great Video, Thank You !
Which editor I use for python
And my some programs wrong bcz latest version of python installed then also programs wrong I write in correct way then also show error like indentation
Cool tutoriasls Mariya!!, Can you add some tut for PY and Mysql Crud? Thank you so much!
Hello from Toronto! Can you focus on how these topics intersect with entrepreneurship in Canada?
Hello Hello from the West Coast! 😀
Entrepreneurship is a very big topic and I wouldn't trust programmers with advices on the matter as creating a product and turning this product into a fully-functional profitable business are completely different things. Entrepreneurs usually start with a problem that concerns a big portion of the population, so you think of what audience you want to target first, then you think "what is the biggest problem I am able to solve for this audience", next you think of how can you make money from this solution while conducting a full-market research and only then you try to implement it.
Programmers very often start from the implementation and only when the product is ready they think of "OK, now how can I make money from it?" or "will somebody pay me for it?" which sometimes works, but often doesn't turn into a profitable venture.
I would consult with somebody who is either an established business person, a marketing adviser or something along these lines.
I must admit, I do have some background in marketing, but I've never used it to create my own personal business (Python Simplified was a hobby of mine, I didn't expect it to turn into an actual business therefore it doesn't really count 😉) so I'm lacking the on-hands experience that would make my advices credible... for now, everything I wrote above is just theory 😅
But yeah, if it's an implementation - I'd love to help! if it's business advice, I don't believe I'm qualified at this point of time 😉
Good luck and cheers from beautiful British Columbia! 😊
thank you so much it really helped me out
I'm using Visual Studio Code in Debian Linux on Chromedome using Python 3.9.2 64-bit
Question:
I have pip3 installed pygame through the terminal inside VSCODE and it recognizes it. It doesn't recognize "event"
It gives me the option to import from tkinter. How should I import "event"? I apologize as im new to VSC coming from IDLE
It was great... but the car goes out of the road if you press the key left or right two times.. how to take care of it...
Great work you are doing it great👍 and I love your videos 😋 all are awesome. Can you make a video on tensorflow too.
You explain stuff very well.
I've just made a similar app with the millennium falcon recently.. pygame is fun :)
Ive done dozens of games and never imported locals, initiated pygame or used .quit() pygame, what are those for?
很有意思的課程解說、謝謝分享😄
I hope this will help a little with your English...
These ( ) are not brackets, they are parentheses. There are two kinds of brackets... Curly Brackets { }, and Square Brackets [ ]. This one is Open parentheses (, and this one is closed Parentheses ). I hope this is helpful. 🙂 It's pronounced Pa Ren theh seas.
Brazilian here, I often confuse parentheses with brackets a lot. Also never knew those were called curly brackets! You learn something new every day!
Thanks for the tutorial, it's very helpful. I really like your contents.
THANK YOU!!! 😄😄😄😄😄😄😄😄😄😄😄😄😄
Can I automate this car, like when a car comes from opposite side it will change it's position automatically??
Hi, love your tutorials, sometimes, pls do a VR and AR,
Thank you so much Richee! 😀
VR and AR are quite a big topic jumps from what we currently cover on the channel. It involves a very large degree of graphics and 3D modelling in addition to code... It's not on my "to do" list but I also never say never! 😉
What will happen if we tap two or more times to left or right? The image get out of the road. Maybe, I think so.
Yup! you'll need to set some limitations to the move commands (I've briefly mentioned it in th video) 😃
Try a conditional statement that only moves the vehicle if it's located within certain bounds (move left, only if vehicle is in the right lane and etc.)
This will fix it! 😉
Hello from Baku, great tutorial
and also you always respone and respect 🥰♥️
I know it's first command, but I'm having trouble with vscode recognizing import pygame. Any helps?
Great tutorial
Thank you! 😊