This has to be the most useful learn-by-doing Pygame tutorial I've seen. You start with the basics, explain what you want to do and how Pygame allows you to do it, and work it in with concepts a learning programmer should be aware of, without jumping right into the more complex aspects.
1:35:00 For collision detection pygame actually has a method called 'colliderect' which detects collision between rectangles. So, if you want to check if the enemy rectangle has collided with the bullet rectangle, instead of checking the distance between the two for every frame, you just write: if enemy_rectangle.colliderect(bullet_rectangle) [whatever you want to do when the enemy collides with a bullet, or vice versa] Hope this helps
I imagine you might not be monitoring the comments anymore by now, but I'm finding this really helpful! I have to try to help some students pick up some programming skills, and this tutorial is great! The detail that you go into about why things have to be the way they are is very helpful. Thanks!
@@@samuelamare3080 Dont worry this will always be free they have a paid version which is like an other site named CodeAcademy. However i like how the quality of the content is so high but it still is free, its like standfords free machine learning course videos
Very beginner friendly, you have taught in a step by step manner that allows us students to try them out , which is very helpful and needed. Thank you .
Great tutorial bruh, really easy to follow along to without speed up or slow down on video play speed. Didn't slow talk the basics like it's somehow news that a String can be a variable value or something. Just gets right into a python library and explains how to build a game.
1:06:00 these 2 conditions can be simplified as if enemyX = 736: enemyDx = -enemyDx enemyY += enemyDy this way the enemy speed value can be modified in the global only instead of changing in 3 different places
@@adhirajsingh1806You don't have to. He already changed the movement direction. For example, enemy approach a border and turn back instantly and go to opposite direction with the same speed.
⌨️ (0:00:00) Installing Python and Pycharm ⌨️ (0:04:12) Creating Our First Game Window ⌨️ (0:12:39) Changing the Title, Logo and Background Color ⌨️ (0:20:33) Adding Images into Our Space Invader Game ⌨️ (0:29:57) Movement Mechanics in Game Development ⌨️ (0:38:13) Keyboard Input Controls & Key Pressed Event ⌨️ (0:49:53) Adding Boundaries to Our Game ⌨️ (0:53:28) Creating the Enemy ⌨️ (0:59:14) Movement Mechanics of the Enemy Space Invader ⌨️ (1:06:51) Adding a Background Image ⌨️ (1:12:08) Creating Bullets for Shooting ⌨️ (1:26:21) Shooting Multiple Bullets at Space Invaders ⌨️ (1:34:24) Collision Detection ⌨️ (1:48:05) Creating Multiple Enemies ⌨️ (1:55:08) Adding Text and Displaying Score ⌨️ (2:03:17) Adding Sounds and Background Music ⌨️ (2:09:05) Game Over --
If you've installed python (by yourself)you definitely know the distance between two points formulas in all it's forms. It's math. If you think this is hard, Wait until you need to apply trig functions.
@@troyna77 I'm afraid this is actually objectively false. The principals of Algebra-However basic in this example- have absolutely nothing to do with the ability to use a computer to connect to the internet and then click the download button on the Python public website. Furthermore, on your-poorly hidden- implication that you can't be a real programmer without the backhand knowledge of both Algebra and-at least fundamental- Trigonometry, there are plenty of programmers who have created respectable and renowned programs without the use of any Algebraic Formulas for calculating distance or any Trigonometry. And though I understand it's probably a bit hard for you to understand, these people are just as much of a programmer as you and me. This comment isn't a good-willed attempt to clarify the mindset of the instructor, it's a short-sighted jab at someone who just wanted to make a joke. And quite frankly, the fact that there are people like this outwardly representing this art in this way appalls me.
@@TheRealLyonic well said ... trigonometry also isn't objectively "difficult" to use in programming, you're just calling a function and letting it do all the calculations for you. The only important thing is to know why and when you need to call a particular function and what part of the result matters to you. Someone who needs to know can learn it by reading some simple rules about trigonometry and what the terminology means. But in no way is trigonometry connected to how good of a programmer someone is, unless they work in a very specific field where it's critically important. I'm DirectX/C++ programming and Unity/C# development (which is considerably more complex) I only used trigonometry in a few isolated cases where I found some novel use for the properties of triangles, like determining how high off a ground an object will be if it's rotated about an axis X-distance away from by so many radians. That guy's comment reads like someone with no dev experience trying to sound like an elitist expert by tossing around some things that sound intimidating and pretending to understand them lol.
@@GameDevNerd I agree completely! And appreciate the well-thought out reply. Also, I respect the DirectX/C++ programming stuff, I focus more on Java and the Web Development tools (HTML, CSS, and Javascript), and always found that stuff to be a bit complicated for my understanding. Though, I will say, I actually worked in Unity with C# for a while too a good bit ago, which was relatively easy to migrate into language wise, since Java and C# are almost the exact same language in terms of Syntax. Though it did take a while for me to learn the ins and outs of Unity as a game engine, working with Rigidbodies and all the other various elements in a game. All that being said, love the input, and thanks for the reply ❤️
You are really a good teacher . I don't know why but i guess Indian college would be disappear in the upcoming years if legends like you keep teaching. Keep going it love you 3000 The things we learnt in 2 hours in this video our college's will take more than 1 month to cover all of this method .....
Python wasn't really designed for it.. it is really important, though, to apply Pygame knowledge to future computer vision projects (if you choose to do so). CV2 is super valuable in combination with pygame and blitting.
Some things in this just don't make sense. Like the spaceship seems to be shooting from it's left and right cannons, but really you shoot a huge bullet from the nose of your ship. But hey, that's not the point, right? You should be focused on the education!
Best way to learn when watching these videos for me at least was to watch each section, example: displaying the window, adding icon. Then go and try it yourself without re watching that section. If you run into a problem remembering what he typed just go look it up and search around instead of just re-watching what he typed out. Thank you for these videos!
Wow! You have answered all my questions! It's just like two weeks ago I said I wanted to make a game app and I had no idea at all where to start. So I began watching videos on TH-cam and I found your video. I am so greatful for your video bro. I certainly subscribed to your channel and I look forward to more of your educational videos. I know you said it's all basic stuff but bro, for me, oh men believe me, it's so professional that I would call it advanced. But you made it so logical and fun that I understood everything. Muchas gracias...Merci beaucoup.
In my few months of learning coding this video has brought a lot of positive vibe to me as i finally got the feeling of creating something solid real thank you
Thank you! I know less than jon snow about programming, but I followed your every step and I made my own game with my own cool graphics and story. And I think I understood most of it, even the collision part. Great teacher.
@TerrorWest yeah, I agree with you it's really annoying special when his accent has so much effect on the English characters so, I really have so much respect for Indians who can overcome his accent those are only Indians who can really impress me
@@Avighna Actually like it is annoying because for coding we Indians have only watched tutorials by foreigners and we get addicted to that sound. Plus Indian accent if heard on devices is very annoying to be it anyone. NotRude
Its good that you are repeating many things again and again, its actually really helpful for us, beginners as we tend to miss out on details sometimes.
well this is one of the best tutorials that I've seen. It's so easy to understand and well-explained also those recaps after each lesson are so awesome Thank you so much 🙏🙏
Awesome Tutorial! Thank you for the spread of your knowledge! Super grateful for people like you who take the time to explain how and why it works and why it does not! That is definitely good teaching practices! I wish my CS teachers were as good as you when it comes to explaining the internals of code! Much appreciated! Take care!
1:03:00 Sorry for the mistakes in English (I'm French). Yes there is a way to do it quicker. You select the block you want to change. You go to Edit > Search > Replace you press Ctrl + R to replace only things that are in selection. Then you type player in the search field and enemy in the replace field. Please like so as many as possible know this trick.
Really cool coding exercise covering the basics. Great fun while following throw it and playing with the functions here and there. Keep up the good work and kindly share more courses like this one. Also looking forward to a object-oriented approach for games involving lots of sprites. Thanks again.
he ffucking explained the pygame library so easily that i cant define, i was stuck on understanding how to use them, these 2 hours are the most productive of my life.......more power to u bro, please give us an option to applaud your work through money...
Fantastic... one of the best tutorial I have seen ... if maybe a bit too detailed for me (with a bit of experience in programming you can fast forward some parts even if you are a beginner in python as me). One comment on something I found missing. For the continuous movement of the spaceship to function properly I had to add apygame.key.set_repeat(10) in the initialization part. Without it, it would only take one keystroke at a time (took me one hour to understand why it didn't work as shown on the screen.
technically this would place the left edge of playerImg at center. to align the center of playerImg at the center of the screen you'd need: playerX = screen.get_width() / 2 - playerImg.get_width() / 2
[1:36:20] I would have instead used: if 0 < bulletX - enemyX < 32 and 0 < bulletY - enemyY < 32: as that makes sure the bullet is touching the enemy, since the enemy is a square and not a quarter circle. Edit: You could also use bullet.get_rect() and enemy.get_rect to then check for collisions using pygame.sprite.groupcollide() or pygame.sprite.spritecollideany()
Can you please help me? it looks like you know what is happening in this game. I got at the part when shooting multiple bullets but I can only shot one and that's it. Also when I try to type if bullet_syate IS ready it doesn't let me. It say syntax error and that I can't use it with a string. PLS HELP! i'm not native
@@paula19335 change to bullet_state == "ready", same with below code, bullet_state == "fire" Once you get the below lines to work you will be golden! if bullet_state == "ready" bulletX = playerX fire_bullet(playerX, rocketY)
Awesome tutorial, I like it😁👍 By the way, I recently found a tutorial which helped me a lot while following this one. It will help you a lot especially if you are from India. The channel name is NSP Tech. Enjoy 😁
"So its thinking about its existence and the meaning of life and what's happening to me.... So we are going to give it a meaning in the next video so i'll see you over there" (;
# Enemy enemyimg = [] enemyX = [] enemyY = [] enemyX_change = [] enemyY_change = [] num_of_enemies = 10 for i in range(num_of_enemies): enemyimg = pygame.image.load("alien.png") enemyimg = pygame.transform.scale(enemyimg, (64, 64)) enemyX.append(random.randint(0, 735)) enemyY.append(random.randint(50, 150)) enemyX_change.append(2) enemyY_change.append(40) This is what my code looked like to accommodate for a different sized picture. My enemies were so big they were spawning off screen with a small portion of them on screen.
At 17:43, he said something wrong. The less the value of a certain colour is, the darker it is not the lighter. Just correcting it for you guys out there so u dont get confusef
got "SyntaxWarning: "is" with a literal. Did you mean "=="? if bullet_state is "ready":" and not sure if I should keep it as "is" or change it to "==" to remove the angry red text
Ok i know this is 6 months ago but the bullet doesn't show up ? Is there anything that I can do Nvm fix it no clue I just think my space bar is dog water
i have a problem in the pic every time i am defining a pic they are telling me playerImg = pygame.image.load('the pic) py game error couldnt open super mario 1 png so what should i do
I think i might have a solution to what you're asking. If you're using Pycharm, make sure that the png you are using isn't in your downloads, but instead in the Pycharm folder where all your projects should be. Once it's there, it should appear on the left side where you previous projects are and then you can continue with this tutorial! Hope this helps!
@@zadiac_6976 Hmmm that's weird cuz that did the trick for me. The only thing I can say to that is maybe the file is corrupted, but i think you probably already thought of that and redownloaded it. Maybe try putting the images in a folder, putting it in the pycharm folder like before, and using the 'import os' method, which you can find explained in Tech with Tim's channel or just the pycharm website. Hope it works this time.
I have a problem. When both the left and the right keys are pressed, the ship moves towards the direction which was instructed last. But when any one of the 2 keys are released, the ship stops. I need it to move towards the pressed key's direction
instead of using events use the pygame.key.get_pressed() method by doing this in the while loop keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: playerX -= player_vel elif keys[pygame.K_RIGHT]: playerX += player_vel and it should work
@@yuvraj6013 Hi, please help me. My problem is this: If I hold down the right key and keep it held down AND THEN hold down the left key, it switches to go left. If I then release the left key, it switches to go right. However, If I hold down the left key and keep it held down AND THEN hold down the right key (or press the right key) it just keeps on going left... Please please help, I can't wrap my head around a solution.
Tip: If for whatever reason you cant set a variable to true, set it to 0 or 1 and do while running == 0: thingy.do_some_crap Edit: Frick me nvm you have to capitalize true or false
nice tutorial but you could make everything dynamic by using more variables, as example i set my initial space ship location to ScreenY - 100 and ScreenX*0.45 and this way it is always centered even if you change the screen size
ive followed along every step and im stuck on getting 6 enemies to appear ive looked over my code multiple times to try to figure out where the problem is but im stuck, when i shoot my bullet sometimes it dissapears mid screen so i feel as if the enemies are there but they just arent visable
I'm only at the part where you make the game window but keep getting an error despite doing exactly as shown in the video. I don't know how to fix it if it's pycharm being broken or some such this is the error (and yes I have pygame installed) line 13, in if event.type == pygame.QUIT(): TypeError: 'int' object is not callable edit: I rewatched for a 5th time and saw what I did wrong haha! The brackets should have been removed
When im at the section: if bullet is "fire": I get the syntaxWarning "is" with a literal. Did you mean "=="? I can't play the bullet. What I'm I doing wrong?
@@AayaatAlakhras-Codegirls Can you pls help me? I am at the part when shooting multiple bullets but it shots one and then it stops. Do you know how to fix? I'm not native
This has to be the most useful learn-by-doing Pygame tutorial I've seen. You start with the basics, explain what you want to do and how Pygame allows you to do it, and work it in with concepts a learning programmer should be aware of, without jumping right into the more complex aspects.
First guy who has made a proper tutorial glad to see that people like them exist in this world
Indians rock bro. Wait r u indian????
You are so much true
@@37.vigneshgopal3 l am Indian. I am proud
@@object5369 yeaaaa
Yea man
1:35:00
For collision detection pygame actually has a method called 'colliderect' which detects collision between rectangles. So, if you want to check if the enemy rectangle has collided with the bullet rectangle, instead of checking the distance between the two for every frame, you just write:
if enemy_rectangle.colliderect(bullet_rectangle)
[whatever you want to do when the enemy collides with a bullet, or vice versa]
Hope this helps
thanks for the tip
Is it simple rectangle overlap? Or does it then further check for pixel overlap (if there is transparency in either image)?
@@hossumquat im trying to figure out the same, gotten any results? Also how do you call the enemy rectangle if the enemy is an image?
helped soo much thanks
why are you even here your an expert
I imagine you might not be monitoring the comments anymore by now, but I'm finding this really helpful! I have to try to help some students pick up some programming skills, and this tutorial is great! The detail that you go into about why things have to be the way they are is very helpful. Thanks!
I still can't figure out why this channel is so amazing with its video contents and on top of that ABSOLUTELY FREE.
ikr
This channel is pure HEAVEN!
Don't give them any ideas
@@@samuelamare3080 Dont worry this will always be free they have a paid version which is like an other site named CodeAcademy. However i like how the quality of the content is so high but it still is free, its like standfords free machine learning course videos
they still get ad money bruh
I watched the whole thing. THANK YOU SO MUCH.
I learned so much.
Legend.
bruh listening to indian dudes on youtube is wayyyyy better than school
Lol I was just thinking the same
no it is not
.
@@its_layth2530 you might be enjoying something else. Why tell everybody??
Right?! I was assigned to make a game using pygame but my teachers such a horrible teacher that no one understood anything 😃-
@saketh p
#ThioJoke
Very beginner friendly, you have taught in a step by step manner that allows us students to try them out , which is very helpful and needed. Thank you .
Great tutorial bruh, really easy to follow along to without speed up or slow down on video play speed. Didn't slow talk the basics like it's somehow news that a String can be a variable value or something. Just gets right into a python library and explains how to build a game.
Only this man can make a spaceship question their existence
Haha
Haha
Haha
Haha
Haha
1:06:00 these 2 conditions can be simplified as
if enemyX = 736:
enemyDx = -enemyDx
enemyY += enemyDy
this way the enemy speed value can be modified in the global only instead of changing in 3 different places
Yeah.
Working with variables is much more comfortable than putting numbers.
Ok but how do you make them return to 0 or 736 depending on if they end up less than 0 or more than 736
@@adhirajsingh1806You don't have to. He already changed the movement direction. For example, enemy approach a border and turn back instantly and go to opposite direction with the same speed.
I have searched a lot of videos for pygame but none was as good as this
Thank you
I have an exam tomorrow and i watch this video till the end.
*Yep thats worth it*
i have two weeks to make a game and I have to learn this, plus I have school for one more week.
*ill be fine right?
I watched it on exam day. Love freecode camp
⌨️ (0:00:00) Installing Python and Pycharm
⌨️ (0:04:12) Creating Our First Game Window
⌨️ (0:12:39) Changing the Title, Logo and Background Color
⌨️ (0:20:33) Adding Images into Our Space Invader Game
⌨️ (0:29:57) Movement Mechanics in Game Development
⌨️ (0:38:13) Keyboard Input Controls & Key Pressed Event
⌨️ (0:49:53) Adding Boundaries to Our Game
⌨️ (0:53:28) Creating the Enemy
⌨️ (0:59:14) Movement Mechanics of the Enemy Space Invader
⌨️ (1:06:51) Adding a Background Image
⌨️ (1:12:08) Creating Bullets for Shooting
⌨️ (1:26:21) Shooting Multiple Bullets at Space Invaders
⌨️ (1:34:24) Collision Detection
⌨️ (1:48:05) Creating Multiple Enemies
⌨️ (1:55:08) Adding Text and Displaying Score
⌨️ (2:03:17) Adding Sounds and Background Music
⌨️ (2:09:05) Game Over
--
Bruh, it from description
You come up with the idea of a game, teaching everything one needs to accomplish it. Much better than any book or tutorial I ever read!
some how after adding sound effect the game feels soooo cool... well by the way must complete the full tutorial. its gr8.
This was a really good tutorial. He explained everything in detail. Highly recommend.
How do you add an image/icon to Pycharm? I had a lot of trouble trying to import a logo for the icon
49:30 lol, at least you said something to laugh during the tension! 😂😂
It's funny how he explains that adding negative numbers is subtracting but also assumes we know the distance between two points algebraic equation
If you've installed python (by yourself)you definitely know the distance between two points formulas in all it's forms. It's math. If you think this is hard, Wait until you need to apply trig functions.
@@troyna77 I'm afraid this is actually objectively false. The principals of Algebra-However basic in this example- have absolutely nothing to do with the ability to use a computer to connect to the internet and then click the download button on the Python public website. Furthermore, on your-poorly hidden- implication that you can't be a real programmer without the backhand knowledge of both Algebra and-at least fundamental- Trigonometry, there are plenty of programmers who have created respectable and renowned programs without the use of any Algebraic Formulas for calculating distance or any Trigonometry. And though I understand it's probably a bit hard for you to understand, these people are just as much of a programmer as you and me. This comment isn't a good-willed attempt to clarify the mindset of the instructor, it's a short-sighted jab at someone who just wanted to make a joke. And quite frankly, the fact that there are people like this outwardly representing this art in this way appalls me.
@@TheRealLyonic wowza
@@TheRealLyonic well said ... trigonometry also isn't objectively "difficult" to use in programming, you're just calling a function and letting it do all the calculations for you. The only important thing is to know why and when you need to call a particular function and what part of the result matters to you. Someone who needs to know can learn it by reading some simple rules about trigonometry and what the terminology means. But in no way is trigonometry connected to how good of a programmer someone is, unless they work in a very specific field where it's critically important. I'm DirectX/C++ programming and Unity/C# development (which is considerably more complex) I only used trigonometry in a few isolated cases where I found some novel use for the properties of triangles, like determining how high off a ground an object will be if it's rotated about an axis X-distance away from by so many radians. That guy's comment reads like someone with no dev experience trying to sound like an elitist expert by tossing around some things that sound intimidating and pretending to understand them lol.
@@GameDevNerd I agree completely! And appreciate the well-thought out reply. Also, I respect the DirectX/C++ programming stuff, I focus more on Java and the Web Development tools (HTML, CSS, and Javascript), and always found that stuff to be a bit complicated for my understanding. Though, I will say, I actually worked in Unity with C# for a while too a good bit ago, which was relatively easy to migrate into language wise, since Java and C# are almost the exact same language in terms of Syntax. Though it did take a while for me to learn the ins and outs of Unity as a game engine, working with Rigidbodies and all the other various elements in a game. All that being said, love the input, and thanks for the reply ❤️
Great tutorial! After watching I made it so the enemies could fire bullets to make it a bit more interesting
Just to Clarify would you take the spaceships shooting speed and then put it on an enemy sorry for asking a stupid question I am New to Python
how did u set at what place the bullets will spawn?
@@hello-wx9wh the enemy variables
I love this guy! He explains all the function of python so well, it really makes me want to learn more. Keep it up!
You are really a good teacher . I don't know why but i guess Indian college would be disappear in the upcoming years if legends like you keep teaching.
Keep going it love you 3000
The things we learnt in 2 hours in this video our college's will take more than 1 month to cover all of this method .....
This tutorial was amazing, I've learned so many concepts in python game development.
Python wasn't really designed for it.. it is really important, though, to apply Pygame knowledge to future computer vision projects (if you choose to do so). CV2 is super valuable in combination with pygame and blitting.
Was a bit skeptical at first but the guy def teaches is very well
I'm a 12 year old and it's really very easy learning Pygame with you . Keep it up!!👍👍
Same!
@@kumarpulivarthi8780 I know right
Yes it proves you are a *12years old* as only a *12year old* will tell his age in a public forum
@@bogdanasaurus no just felt like saying
Am also 12
the video: bullet_state = "Fire"
boolean: "Am I a joke to you?"
ikr
Some things in this just don't make sense. Like the spaceship seems to be shooting from it's left and right cannons, but really you shoot a huge bullet from the nose of your ship. But hey, that's not the point, right? You should be focused on the education!
Truuueee haha😂
Boolean is fired
Sorry
@@4glassmilk635 😂😂😂
Best way to learn when watching these videos for me at least was to watch each section, example: displaying the window, adding icon. Then go and try it yourself without re watching that section. If you run into a problem remembering what he typed just go look it up and search around instead of just re-watching what he typed out. Thank you for these videos!
Wow! You have answered all my questions! It's just like two weeks ago I said I wanted to make a game app and I had no idea at all where to start. So I began watching videos on TH-cam and I found your video. I am so greatful for your video bro. I certainly subscribed to your channel and I look forward to more of your educational videos. I know you said it's all basic stuff but bro, for me, oh men believe me, it's so professional that I would call it advanced. But you made it so logical and fun that I understood everything. Muchas gracias...Merci beaucoup.
In my few months of learning coding
this video has brought a lot of positive vibe to me as
i finally got the feeling of creating something solid real
thank you
Thank you! I know less than jon snow about programming, but I followed your every step and I made my own game with my own cool graphics and story. And I think I understood most of it, even the collision part. Great teacher.
You know that a tutorials going to be good when u have an indian talking :)
Ya absolutely Indian English is easy to understand for both indians as well as others
@TerrorWest lol ur being self racist. I think it's good
@TerrorWest yeah, I agree with you it's really annoying special when his accent has so much effect on the English characters so, I really have so much respect for Indians who can overcome his accent those are only Indians who can really impress me
@@m-gendy1512 wow ur as bad as that white police
@@Avighna Actually like it is annoying because for coding we Indians have only watched tutorials by foreigners and we get addicted to that sound. Plus Indian accent if heard on devices is very annoying to be it anyone. NotRude
59:00
(just letting myself know where i left off)
EDIT 2: Finished :)
this is the best tutorial, no one teached properly like him for pygame.
Its good that you are repeating many things again and again, its actually really helpful for us, beginners as we tend to miss out on details sometimes.
Thank you so much Sir..... After 5 days i have created this game with the help of your video.....
Which pubg
👈@@planet.ai1 nahi bro bro mera channel dekho
I want to press the like button 100000 times. This is the best video I have ever seen on this topic. Great Sir..keep it up.
Getting your Oscar ready.
It was like a damn good crash course.
Appreciated how digestible you made everything. Tough material to do that with 👍👍
BARELY
This is how teaching should be!!!🙏🙏🙏
Huge respect, from a student to you, sir...
well this is one of the best tutorials that I've seen.
It's so easy to understand and well-explained also those recaps after each lesson are so awesome
Thank you so much 🙏🙏
Awesome Tutorial! Thank you for the spread of your knowledge! Super grateful for people like you who take the time to explain how and why it works and why it does not! That is definitely good teaching practices! I wish my CS teachers were as good as you when it comes to explaining the internals of code! Much appreciated! Take care!
only around 20minutes in, but already the best programming tutorial for this that i have ever seen
I can't express how happy I am for this video
1:03:00 Sorry for the mistakes in English (I'm French). Yes there is a way to do it quicker. You select the block you want to change. You go to Edit > Search > Replace you press Ctrl + R to replace only things that are in selection. Then you type player in the search field and enemy in the replace field. Please like so as many as possible know this trick.
Your English is Perfect
@@5staryzzz Thanks your comment make me happy especially from you 😉
@@davidmace1856 Lol, np
@saketh p Yeah 🤣
አመሰግናለሁ!ከ ኢትዮጵያ በጣም ግሩም ድንቅ መምህር! እድሜህ ይርዘም!❤❤❤🏆🏆🏆🏆🏆
i needed 3 days to finish, but now i am way smarter and understood it
feels so good to see our Desi boys conquer the internet
Yup dude. Desi Zindabad!
@@tahaahmed6655 yes desi zindabaad
Thank you for this. I missed coding with python and i don't know where to start again; this is a great start for me.
Cool intro to python game development 💪
Thanks :)
Really cool coding exercise covering the basics. Great fun while following throw it and playing with the functions here and there. Keep up the good work and kindly share more courses like this one. Also looking forward to a object-oriented approach for games involving lots of sprites. Thanks again.
he ffucking explained the pygame library so easily that i cant define, i was stuck on understanding how to use them, these 2 hours are the most productive of my life.......more power to u bro, please give us an option to applaud your work through money...
How many guys are noticed this amazing guys voice was changed in the class of adding audio to game
pygame is really cool when it comes to 2-D game development
True Story.
@A Google User why not 3D
Thank you so much! I have been wanting to learn how to make a game with python for ages!
Started and completed the whole course in 4 hrs no skips and not discontinuty... Just because of the way this guy explains Stuff..
umm the course is 2 hrs lmao
You just earned yourself a like !
Fantastic... one of the best tutorial I have seen ... if maybe a bit too detailed for me (with a bit of experience in programming you can fast forward some parts even if you are a beginner in python as me). One comment on something I found missing. For the continuous movement of the spaceship to function properly I had to add apygame.key.set_repeat(10) in the initialization part. Without it, it would only take one keystroke at a time (took me one hour to understand why it didn't work as shown on the screen.
I was just wondering the same thing. Thanks!
Tip : those who can't get the image or logo in pygame window, just add the png in the folder where ur game's/.py file is
Also if we have a path that involves back slash rather than typing one type 2 backslash. Like C:\\Users\
ame\\game\\pic.png
just finished this tutorial - it's great. Many thanks for making this and making it easy to follow.
2:00:25
- "And when we shoot someone"
*Misses drasticaly
😂
i need help there as well
He: which you have played in your childhood.
13 yrs old me: pretty sure I haven't
I am also 13
Me too
I was born a few hours ago and I'm learning this :)
same lol
@@husainjinia1618 they grow up so fast😭😭😭
i created my first ever game thank you so much bro
the tutorial is not even bored .well understanding .no error
I nearly played this game for 1 hour while creating it... :)
I set the number of asteroids to 5000 and I reached a score of over 3 million
To center player along x-axis can also be auto-calculated instead of hardcoding playerX = 370
playerX = screen.get_width() / 2
technically this would place the left edge of playerImg at center. to align the center of playerImg at the center of the screen you'd need:
playerX = screen.get_width() / 2 - playerImg.get_width() / 2
Wow Finally I successfully completed coding , implemented and played the game. Thanks a lot
[1:36:20] I would have instead used:
if 0 < bulletX - enemyX < 32 and 0 < bulletY - enemyY < 32:
as that makes sure the bullet is touching the enemy, since the enemy is a square and not a quarter circle.
Edit: You could also use bullet.get_rect() and enemy.get_rect to then check for collisions using pygame.sprite.groupcollide() or pygame.sprite.spritecollideany()
Can you please help me? it looks like you know what is happening in this game. I got at the part when shooting multiple bullets but I can only shot one and that's it. Also when I try to type if bullet_syate IS ready it doesn't let me. It say syntax error and that I can't use it with a string. PLS HELP! i'm not native
@@paula19335 change to bullet_state == "ready", same with below code, bullet_state == "fire"
Once you get the below lines to work you will be golden!
if bullet_state == "ready"
bulletX = playerX
fire_bullet(playerX, rocketY)
1:03:00
it can be done in vs code, using alt+click trick.
Really enjoying how he explains everything well. Bit tedious for when you know basics, but it is a really good course, def recommend
Awesome tutorial, I like it😁👍
By the way, I recently found a tutorial which helped me a lot while following this one. It will help you a lot especially if you are from India. The channel name is NSP Tech. Enjoy 😁
funny thing, after the code was done for multiple enemy i was into it "for real"
Can you send the codes please :(
@@tuis6276 why not just watch the video, it will be worth your time
You are the best teacher I have ever met on youtube
42:49 (where I left off so I can remember)
I just right clic and copy the url on the actual minute xD
@@michaelandillocr Thannk you!
You haven't finished it yet don't stop yet you can do it!
Thanks!
Hey finish the course lazy......
"So its thinking about its existence and the meaning of life and what's happening to me.... So we are going to give it a meaning in the next video so i'll see you over there" (;
Another Indian guy who should have his own silicon valley 💓 thanks for making coding easy , Ty from side of community
16:00 one problem i had was the icon was too big, so instead it just displayed the python logo, to fix this change it to around 32x32
# Enemy
enemyimg = []
enemyX = []
enemyY = []
enemyX_change = []
enemyY_change = []
num_of_enemies = 10
for i in range(num_of_enemies):
enemyimg = pygame.image.load("alien.png")
enemyimg = pygame.transform.scale(enemyimg, (64, 64))
enemyX.append(random.randint(0, 735))
enemyY.append(random.randint(50, 150))
enemyX_change.append(2)
enemyY_change.append(40)
This is what my code looked like to accommodate for a different sized picture. My enemies were so big they were spawning off screen with a small portion of them on screen.
At 17:43, he said something wrong.
The less the value of a certain colour is, the darker it is not the lighter. Just correcting it for you guys out there so u dont get confusef
Most enjoyable pygame tutorial on the interwebs
2hr 15min tutorial - takes 8 hours for me to complete....
Complete the installing python + pycharm part xD
Totally true for me 'coz I pause and type in the same code after he adds a word to his code - gotta stop doing that though
good job
bruh, I've watched it 3 days already
internet speed didnt go brr
@@Jiggly12 speedn't
Just made a shooting game
Fear me Elon Musk
thankyou because of your tutorial i am about to lean pygame
got "SyntaxWarning: "is" with a literal. Did you mean "=="?
if bullet_state is "ready":" and not sure if I should keep it as "is" or change it to "==" to remove the angry red text
Is recommended to use == in this case
@@felixriddle Thanks for this
Ok i know this is 6 months ago but the bullet doesn't show up ?
Is there anything that I can do
Nvm fix it no clue I just think my space bar is dog water
@@pizzaisneat coding really do be like that sometimes
Do you have any idea why my bullet only shots once and then it stops? I can't shot the second time. I'm stuck. I'm not native
i have a problem in the pic every time i am defining a pic they are telling me playerImg = pygame.image.load('the pic)
py game error couldnt open super mario 1 png
so what should i do
I think i might have a solution to what you're asking. If you're using Pycharm, make sure that the png you are using isn't in your downloads, but instead in the Pycharm folder where all your projects should be. Once it's there, it should appear on the left side where you previous projects are and then you can continue with this tutorial!
Hope this helps!
@@zadiac_6976 Hmmm that's weird cuz that did the trick for me. The only thing I can say to that is maybe the file is corrupted, but i think you probably already thought of that and redownloaded it. Maybe try putting the images in a folder, putting it in the pycharm folder like before, and using the 'import os' method, which you can find explained in Tech with Tim's channel or just the pycharm website.
Hope it works this time.
@@aaronh4030 yeah btw i downloaded it like 3 or 2 times does that matter\
@@zadiac_6976 maybe? Not really sure.
@@aaronh4030 till now I don't know what to do I stopped from that time and I am now learning unity and 3d
Nothing better than a cold morning, a warm cup of coffee, and an indian dude teaching you how to code Space Invaders.
Hey,
getting this error,
if event.type == pygame.QUIT():
TypeError: 'int' object is not callable
Dushyant Kumar no brackets on QUIT
No brackets
@@hydra1346 had the same probmem. it works now! thanks.
remove the brackets from quit
Remove the brackets from beside the quit.
I have a problem. When both the left and the right keys are pressed, the ship moves towards the direction which was instructed last. But when any one of the 2 keys are released, the ship stops. I need it to move towards the pressed key's direction
bro meri bhi same problem h
Me too, please, if you find a solution - or anybody else. PLEASE. Post it here. I've been trying all sorts of things and none of it seems to work...
instead of using events use the pygame.key.get_pressed() method by doing this
in the while loop
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
playerX -= player_vel
elif keys[pygame.K_RIGHT]:
playerX += player_vel
and it should work
@@yuvraj6013 Hi, please help me. My problem is this:
If I hold down the right key and keep it held down AND THEN hold down the left key, it switches to go left. If I then release the left key, it switches to go right.
However,
If I hold down the left key and keep it held down AND THEN hold down the right key (or press the right key) it just keeps on going left... Please please help, I can't wrap my head around a solution.
43:39 - cool print statement to add to find which key exactly was pressed
print(f"{pygame.key.name(event.key)} Key was released")
or add this adter the KEY DOWN print(f"{pygame.key.name(event.key)} Key was pressed")
Tip:
If for whatever reason you cant set a variable to true, set it to 0 or 1 and do
while running == 0:
thingy.do_some_crap
Edit:
Frick me nvm you have to capitalize true or false
hahaahahahah underrated comment
If anyone is having trouble opening images in mac. save the files to iCloud document
Someone give this man a medal.
:( im stuck at bullet movement. bullet is not appearing
how do i fix It!!!
nice tutorial but you could make everything dynamic by using more variables, as example i set my initial space ship location to ScreenY - 100 and ScreenX*0.45 and this way it is always centered even if you change the screen size
ScreenY - 100 isn't really dynamic, a better choice would be ScreenY * ( 5 / 6)
Man, this helps me a lot. I srsly struck gold with yt recommendation huh.
Lots kudos!
ive followed along every step and im stuck on getting 6 enemies to appear ive looked over my code multiple times to try to figure out where the problem is but im stuck, when i shoot my bullet sometimes it dissapears mid screen so i feel as if the enemies are there but they just arent visable
Even I am stuck there please help
ever figure it out?
3 hours were lost saying "hand side" after every "right" or "left".
ah yes, that one guy who has the exact instructions I needed. Thank you !
Tru Dat!
the multiple enemies thing is better done with a class no ?
exactly although we could use that for the player and the bullet as well
I'm only at the part where you make the game window but keep getting an error despite doing exactly as shown in the video. I don't know how to fix it if it's pycharm being broken or some such
this is the error (and yes I have pygame installed)
line 13, in
if event.type == pygame.QUIT():
TypeError: 'int' object is not callable
edit: I rewatched for a 5th time and saw what I did wrong haha! The brackets should have been removed
yeah, was about to day that
you can just delete () after QUIT and all right 😉😉
Salute , you sir 🙏
you made a two hour video and subtitles too
It surely took you so much time
When im at the section: if bullet is "fire": I get the syntaxWarning "is" with a literal. Did you mean "=="? I can't play the bullet. What I'm I doing wrong?
He is using an older version of Python, just add == instead of “is” and it should work.
@@AayaatAlakhras-Codegirls Can you pls help me? I am at the part when shooting multiple bullets but it shots one and then it stops. Do you know how to fix? I'm not native