Learning pygame by creating Snake [python tutorial]

  Рет қаралды 359,544

Clear Code

Clear Code

Күн бұрын

Пікірлер: 615
@ClearCode
@ClearCode 3 жыл бұрын
Slight correction at 0:03:12 the text at the bottom is supposed to say python 3.9 not pygame 3.9
@hariharanthegreat5576
@hariharanthegreat5576 3 жыл бұрын
Can you give link to assets you used here
@ClearCode
@ClearCode 3 жыл бұрын
@@hariharanthegreat5576 check the video description, there is a link to all the files :)
@aarushpal3736
@aarushpal3736 3 жыл бұрын
you are so sensitive to your mistake love it xD :->
@jakelanghel8917
@jakelanghel8917 3 жыл бұрын
do you hav a link to all the graphics you used??
@jakelanghel8917
@jakelanghel8917 3 жыл бұрын
nvm I didn't notice the github link lol thank you.. I've been trying to teach myself how to program and this is by far one of the best tutorials I have found for free!!! super detailed and you explain everything!! alot of other tutorial I felt like I was just copying what they were doing but not rly understanding why im doing it!! thanks again
@marnierogers3931
@marnierogers3931 2 жыл бұрын
If anyone is new here and gets stuck around the 40min mark returning an attribute error. Try adding a double underscore before and after __init__. I just learnt a looooong lesson that I'll now never forget! haha
@kafactz7710
@kafactz7710 Жыл бұрын
Thanks bro
@BonkySonky
@BonkySonky 5 ай бұрын
this does nothing
@rad0stin
@rad0stin 2 ай бұрын
​@@BonkySonky You have to put 2 underscores, not 1 or it will not work
@uiebwuiowebuiopwebfoipbewfoip
@uiebwuiowebuiopwebfoipbewfoip 3 жыл бұрын
yor channel is INSANELY underrated. I've seen many pygame tutorials yet I only understood 100% of what I was told is in your video, you explain everything so in depth and stop at every line of code to explain. You give examples and even show little animations to show us what you're trying to say. 10/10 keep it up man
@zagrajzguru
@zagrajzguru 2 жыл бұрын
This
@UniquelyMadeIAm
@UniquelyMadeIAm Жыл бұрын
This is so true!!! Keep making these please
@flippingflipbooks565
@flippingflipbooks565 3 жыл бұрын
I am currently learning Python, but I don't know ANYTHING about pygame! I really wanted to learn it: My main motive for learning programming was to make games! You are the best person for me to help me learn. You add in litte bits of humor, so your vids aren't just plain coding. I really think that you are the best!
@uskumru3106
@uskumru3106 2 жыл бұрын
Python is realy bad choice if you want making game
@ПожилойСкарабей
@ПожилойСкарабей 2 жыл бұрын
Hey friend! How did it go for you?
@No3inator
@No3inator Жыл бұрын
yeah after learning python you can easily start using Godot using gd script which is 90% similar to python because python just has many bad things in game development which you cant avoid
@Bluemoon_wav
@Bluemoon_wav Жыл бұрын
@@No3inator could you tell me in a broad way what those "bad things" are?
@jeremyhubaker1199
@jeremyhubaker1199 Жыл бұрын
IF YOU REALLY WANT TO MAKE GAMES THEN YOU NEED TO LEARN C++ ,C#, JAVA YOU WILL BE LIMITED WITH PYTHON AS IT IS BETTER SUITED FOR DATA MANIPULATION AND BACK ND STUFF. ALTHOUGH PYTHON IS A GOOD START BECAUSE IT IS SIMPLE
@mixlaproduction
@mixlaproduction 3 жыл бұрын
I just found out your stuff. I was blown away by the amount of detail and effort you put into your videos! Your channel seems golden! Can’t wait to watch all your python game-developing related videos. Keep up with those awesome simple projects! 😎
@RandomJeevanYT
@RandomJeevanYT 2 жыл бұрын
1:06:39 "Well takes no time at all to create it" More like 2 days for me cuz im doing this sort of stuff for first time 😥 But i understood everything clearly cuz u explain so well so thanks for that🤗
@MouseCodes
@MouseCodes 3 жыл бұрын
I was happy getting the notification of this video. Keep it up, bro.
@RohanKumar-zd3pc
@RohanKumar-zd3pc 3 жыл бұрын
Amazing, It is explained in a very detailed way Of all the logic from the setup to finishing
@tayyabsajid7552
@tayyabsajid7552 3 жыл бұрын
How do you not already have a huge fan base, you're epic!
@TheDrumtracks
@TheDrumtracks 3 жыл бұрын
This is the best tutorial I found so far to this topic. (and the prettiest one. :D) Every line is explained in more detail than all others tutorial I watched. You Sir, did a great Job! I felt like I was able to understand everything!
@dogesh828
@dogesh828 3 жыл бұрын
It's midnight i am gonna watch it tomorrow. But i know it's will be awesome as always.😆😆😆 Please keep making more quality content. Lots of love❤❤❤
@thecomputer1424
@thecomputer1424 2 ай бұрын
This is a great tutorial even without having a solid understanding of python classes, I am still able to comprehend this a bit.
@cup624
@cup624 3 жыл бұрын
i believe this tutorial is the most underrated one of other pyhton tutorials. thanks for your efforts.
@JayeshSarvaiya
@JayeshSarvaiya 3 жыл бұрын
I am just blown away by such an effort taken for smooth explanation, planning and gaming skills, you really came up with beautiful channel, All the Best for upcoming videos. Great Stuff !!! Thanks a tonnnnn... for everything. 😃
@parthgupta4850
@parthgupta4850 3 жыл бұрын
100th comment says that this is awesome tutorial you teach explain everything as other skip many things and at last we are confused but you are not like them you teach and explain and write everything, best tutorial as well as game of your channel.
@burak9802_
@burak9802_ 3 жыл бұрын
Christian you're awesome keep on loading videos. We all have been waiting for new game videos!
@roiho5405
@roiho5405 3 жыл бұрын
I love your Pygame videos. I'm having so much fun with this module, I hope to see more from you :)
@sarankumar9370
@sarankumar9370 3 жыл бұрын
Ohh my God!! This is the best tutorial I had ever seen till today... The way you are explaining every tiny bit details is just amazing... Keep doing more video's..
@mr.curious1714
@mr.curious1714 2 жыл бұрын
This is the best video on #PygameBasics and #SnakeGamePython . You have explained everything in the perfect pace. I would recommend this tutorial to everyone who wants to learn pygame and also snake game using pygame. Best tutorial!!!! You Earned a sub!!!!
@yussefhallak981
@yussefhallak981 3 жыл бұрын
I got so happy when I saw the notification. This tutorial is gonna help a lot. Thank you!
@bobbyreily3018
@bobbyreily3018 3 жыл бұрын
You definitely deserve more subscribers! Keep the videos coming and they will flock in.
@Daloshka
@Daloshka 3 жыл бұрын
I've just started watching your video about Flappy Bird. I want to say thanks for your videos. You make a huge influence on me and other people
@OettingerPirat
@OettingerPirat 2 жыл бұрын
I can't imagine how I've could have invested the last 2-ish hours better than following your video and code along. Thank you so much for your fantastic work! :)
@thelogbob281
@thelogbob281 Жыл бұрын
Incredible incredible video! Very descriptive and thorough with every little detail! You are an amazing youtuber, and I love the effort!
@parthgupta4850
@parthgupta4850 3 жыл бұрын
Congrats! 1 unlike only out of 5000 views great job this proves that you're videos are quality driven.
@e.e.schonborn9344
@e.e.schonborn9344 Жыл бұрын
This was by far the most helpful python tutorial I have ever watched! Every single detail was explained super precisely and yet so easily at the same time! Thank you so so much!
@momanirful
@momanirful 9 ай бұрын
Fantastic tutorial, explains concepts clearly and then applies knowledge to write code. Love your delivery style, perfect for young children to learn coding.
@muradarif7373
@muradarif7373 2 жыл бұрын
I have finished the tutorial, Huge thank you for such a video 🤝👌
@christophercoronaios4732
@christophercoronaios4732 3 жыл бұрын
Wow, you are extremely helpful. I love how you explain each and every single line of code and just how you have put this tutorial together in general. This has been a great experience for me. Keep it up man!
@chikaosita662
@chikaosita662 2 жыл бұрын
This channel is truly amazing ive recently got into pygame and I will definetly be using this channel for all my needs. Thank you so much !!!!!
@zCrabOG
@zCrabOG 2 жыл бұрын
Thank you for explaining the "why's". The puzzle pieces just fall straight into place
@HarryTK
@HarryTK 2 жыл бұрын
broken it down makes it seem so user-friendly and easy to use. I can’t wait to start making soft! Thanks again!
@atharvapatil7474
@atharvapatil7474 3 жыл бұрын
Best tutorial of snake game ever found on KZbin
@kareemyounes7371
@kareemyounes7371 3 жыл бұрын
Just pixel perfect tutorial. I think there is a small bug, not sure if I am the only one having this; however, if you press the down arrow key and right arrow key (while moving to the left) the snake will turn into its self. My solution is I added a variable called moved = False (in class Snake) that I used to make sure the snake moved before talkin in another input. I am not sure if this is the best solution, but it works.
@DarkSideYT
@DarkSideYT Жыл бұрын
hey can u please share detailed step how to solve that bug! soon
@nathanwhite704
@nathanwhite704 3 жыл бұрын
Ive been working on this tutorial for nearly 6 hours and im only half way through it, programming is fun but challenging I spent an hour fixing indentation errors.
@builder481
@builder481 3 жыл бұрын
Friends : what did you had for breakfast? Me : I had some eggs in a rectangle plate
@nullifier_
@nullifier_ 2 жыл бұрын
Thank you so much! You helped me create my first game ever. I even added things like out-of-bound wrapping check for when the snake goes outside of the grid and tail cut for when the head intercepts the body
@jananni123456789
@jananni123456789 3 жыл бұрын
Such clean, logical, well organised code!
@andrewmaksimovich2432
@andrewmaksimovich2432 2 жыл бұрын
This is an amazing tutorial and I'm really grateful for it. I was wondering about a a small bug I encountered that when I press two arrow keys at the same time, like trying to turn around, the snake crashes. Just curious, is this related to how we handle key events, and is there an easy fix? Another thing I found was that at the beginning the reason why the snake doesn't move is because the game is constantly resetting, as the snake collides with itself for some reason. I found this out when I added a sound to the player losing. Nonetheless, this tutorial has been a great help and, being the beginning programmer I am, figuring out how the game works and bugs I encountered has taught me a lot.
@thojmen8585
@thojmen8585 5 ай бұрын
I've been on this same problem aswell and I have tried many ways to fix it, haven't found the solution yet but I will tell if you if I ever find it
@YanisCharef-dy5rk
@YanisCharef-dy5rk Жыл бұрын
That was a simple and a clear tutorial, thank you!
@sebzanardo
@sebzanardo 3 жыл бұрын
AWESOME VIDEO! Super clear explanations of how pygame works and breaking down the program into manageable sections. subscribed and can't wait to see more pygame and coding videos in the future : D
@RandomJeevanYT
@RandomJeevanYT 2 жыл бұрын
I wanted to creat snake game in python i saw so many tutorials could do the code and it worked but i wasn't satisfied cuz i understood only partly. But ur vids are amazing the differences u show between surfaces and display surface, explaining each line code. Just prefect 🤗🤗
@shariqshaikh2421
@shariqshaikh2421 Жыл бұрын
I am getting an error about FRUIT class at 39:27. It says that 'Fruit' object has no attribute 'pos' after running it.
@teyzx123
@teyzx123 16 күн бұрын
its because u probably did a single underscore for init (_init_) when it should be __init__
@chiragaparadh1417
@chiragaparadh1417 3 жыл бұрын
Sooo good of a tutorial...2 things...we can use only one image of head, body and tail by transfroming them(rotating), and i found a bug....if i change direction very fast i go in reverse direction and i loose the game...
@thojmen8585
@thojmen8585 Жыл бұрын
Awesome code and tutorial but I noticed 1 little flaw what can effect the game a lot. Right now you only check when you press left if the snake is going right. But if you press up or down and then quickly or at the same time left it breaks that and still goed directly left and causes you to die❤
@anemomenoma
@anemomenoma 6 ай бұрын
you can store the movements in a separete variable. newDirection = None if event.type == pygame.KEYDOWN: if event.key == pygame.K_UP and main.snake.direction != Vector2(0,1): newDirection = Vector2(0,-1) if event.key == pygame.K_DOWN and main.snake.direction != Vector2(0,-1): newDirection = Vector2(0,1) if event.key == pygame.K_LEFT and main.snake.direction != Vector2(1,0): newDirection = Vector2(-1,0) if event.key == pygame.K_RIGHT and main.snake.direction != Vector2(-1,0): newDirection = Vector2(1,0) if newDirection: main.snake.direction = newDirection
@thojmen8585
@thojmen8585 6 ай бұрын
@@anemomenoma thanks, I will look into this
@astrowow9377
@astrowow9377 3 жыл бұрын
You are the best mate, my greetings from Mexico ✌️🇲🇽💕
@catastrophiccarrots5626
@catastrophiccarrots5626 3 жыл бұрын
I love this tutorial it is so clear and informative! Plus every error i get is always my fault as i did a typo or forgot the () thanks so much i will definitely watch more of your videos and you got another sub!
@sahidabegum7365
@sahidabegum7365 8 ай бұрын
This is the best tutorial about pygame. I enjoyed it and also understand the concepts and logics very easily.
@soumenmondal7638
@soumenmondal7638 3 жыл бұрын
THANK YOU SOO MUCH FOR CLEARING EACH AND EVERY PORTION SOO WELL ❤
@muhammadahmadkhan3304
@muhammadahmadkhan3304 Жыл бұрын
Jazakallah ... Very beautiful explanation ... Thank you so much❤❤❤❤
@salouhimohammed1030
@salouhimohammed1030 2 жыл бұрын
i think is more efficient to use a while loop to avoid the fruit spawns over the snake, this part i coded it like below while self.fruit.pos in self.snake.body[1:]: self.fruit.randomize() thanks for the great tutorial, a channel like the yours i never seen before
@Code_in_simple_English
@Code_in_simple_English 2 жыл бұрын
These lessons are just awesome. Thank you for posting them. What would be useful in the comments, if you were interested in adding them, are the key concepts taught: like Vector2, enumerate, slicing.. and so on.
@aimeedillard9665
@aimeedillard9665 2 жыл бұрын
So glad I found this channel, I immediately subscribed! Can’t wait to try some of this out
@Thoalfeqargamer
@Thoalfeqargamer 3 жыл бұрын
What a legendary channel. Keep up the amazing work man!
@usmanamjad1409
@usmanamjad1409 11 ай бұрын
Nice tutorial every beginner will understand this. Btw is there anyway to make snake movement smooth?? pls let me know
@rubenbartelet756
@rubenbartelet756 3 жыл бұрын
You need more subscribers man! This is quality content!
@Codingforkids
@Codingforkids 3 жыл бұрын
Thank you for the detailed and precise tutorial! Keep up the great work!
@charlesmartinjr3971
@charlesmartinjr3971 2 жыл бұрын
Okay, so let's be real: I actually created a snake game last year using a different "teaching" channel. The channel was awful. I had the game at the end, but I had on earthly idea what any of the code meant, how it worked, or how to replicate it. I'm 5 minutes into your video, and I already learned more stuff in that five minutes - without even coding anything - than I did *making the project at the other channel.* Keep up the great work, my friend!
@PixelGaming_2020
@PixelGaming_2020 2 жыл бұрын
Really good tutorial. You explained everything in amazing detail. With a few other tutorials, they move too quickly, which causes me to have errors in my code that I don't know how to correct. This one is nicely paced, and I end up with a fully working and functional snake game.
@imSHEN
@imSHEN 2 жыл бұрын
how do you fixed 'MAIN' object has no attribute 'snake'
@AbhishekMishraiitkgp
@AbhishekMishraiitkgp Жыл бұрын
Extremely well explained tutorial. Thanks!!!
@WanKy182
@WanKy182 Жыл бұрын
At 1:44:10 you can just check in order to draw grass : for row in range(cell_number): for col in range(cell_number): if (col+row) % 2 == 0:
@bycorrohmarketingdesigns7852
@bycorrohmarketingdesigns7852 2 жыл бұрын
you are AMAZING MAN! Very clear and good class man!! CONGRATS!!!
@solijanov_05
@solijanov_05 Жыл бұрын
good man👍 thank you for video
@sabirkhan6898
@sabirkhan6898 3 жыл бұрын
Well explained! I loved the amount of detail given throughout the video
@armeidiandanny0522
@armeidiandanny0522 2 жыл бұрын
Very Helpful and really easy to understand man.. keep fight and consistenly upload to create implementation PyGame learning with another game 👍
@kalashshah1049
@kalashshah1049 3 жыл бұрын
Hey clear code you deserved more subscribers. really nice videos.
@parthgupta4850
@parthgupta4850 3 жыл бұрын
please please please come up with a tutorial of Tetris with pygame. I will be very thankful to u. And thanku for this tutorial too.
@ultra_xd
@ultra_xd 3 жыл бұрын
If you're having issues with your game running too slow, try this: import pygame import time window = pygame.display.set_mode((screendimensionshere)) last = time.time_ns() numberOfTicks = 60.0 ns = 1_000_000_000 / numberOfTicks delta = 0 running = True while running: now = time.time_ns() delta += (now - last) / ns last = now while delta >= 1: delta -= 1 for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # event loop goes here # surface updates goes here pygame.display.update() pygame.quit() I hope this helps!
@mrmizan1977
@mrmizan1977 3 жыл бұрын
You’re really a great programmer!
@horilalyadav2774
@horilalyadav2774 3 жыл бұрын
Firstly I use pygame for making games .But due to limitations I leaved it .Now I use godot for game development because it is light wight easy to use etc. But I am not professional. I want be a professional in godot and game development field .So plz help me bro. Because your totorials are to good. And I want that you will never discontinue it and upload awsome videos like that.Thank You
@electrocute6745
@electrocute6745 3 жыл бұрын
In 48:25 my terminal said line 42, in snake.draw_snake() line 9, in draw_snake for block in self.body: AttributeError: 'SNAKE' object has no attribute 'body'
@xchar777yt5
@xchar777yt5 2 жыл бұрын
I have the same problem
@Extorc
@Extorc 3 жыл бұрын
Hey bro i understand you are doing a very noble job for people who are beginers , but i would like to suggest you , upload more often
@ClearCode
@ClearCode 3 жыл бұрын
Will start uploading stuff more regularly soon!
@aditgaur1585
@aditgaur1585 3 жыл бұрын
You defeated the entire purpose of the game in the thumbnail 😂 BTW nice tutorial 👍
@Schachlover
@Schachlover 3 жыл бұрын
Awesome as always. Plz. keep up the good work!!
@mehakverma7043
@mehakverma7043 2 жыл бұрын
i dont even need the video, I just enjoyed watching you make it lol
@yisus.avocado
@yisus.avocado 3 жыл бұрын
This so awesome, really interesting video, keep up doing well!
@banji8171
@banji8171 3 жыл бұрын
Wow, we need more tutorial like this, keep it up🥺❤️❤️
@hoatran-dg3ir
@hoatran-dg3ir 2 жыл бұрын
Wow this tutorial is really good! Thanks man!
@mrtechdikshant4933
@mrtechdikshant4933 2 жыл бұрын
I really admire you and your hard work I have a problem with this code, that is whenever I run the code the game starts (without any errors) but the head and body of snake don't gets displayed. So can you tell the solution
@LeonTheEpik
@LeonTheEpik 2 жыл бұрын
I have the same problem
@eyeteeee9507
@eyeteeee9507 Жыл бұрын
have you fixed it?
@eyeteeee9507
@eyeteeee9507 Жыл бұрын
@@LeonTheEpik have you fixed it?
@LeonTheEpik
@LeonTheEpik Жыл бұрын
@@eyeteeee9507 nope
@eyeteeee9507
@eyeteeee9507 Жыл бұрын
@@LeonTheEpik damn
@FFMaglione
@FFMaglione Жыл бұрын
Thank you for another amazing tutorial!
@psynatic5309
@psynatic5309 2 жыл бұрын
Big thanks for this instructive tutorial, you are damn good. I have learned so much add the last 3 hours, I can't say it often enough thank you thank you thank you :) I have one more question, is it possible for the snake after it runs against the wall to spawn att the other side like the original snake from the old nokia phones ?
@blankcanvas3554
@blankcanvas3554 2 жыл бұрын
You can set the take the modulo of the block's x and y values and set those as the new values... def draw(self): for block in self.body: # Wrap around window block.x = block.x % cell_num block.y = block.y % cell_num x_pos = int(block.x * cell_size) y_pos = int(block.y * cell_size) ...
@zgreatest69
@zgreatest69 3 жыл бұрын
You explained it so well I'm so glad
@JohnSmith952
@JohnSmith952 3 жыл бұрын
Every your video is pure gold
@PennyThePerson
@PennyThePerson Жыл бұрын
There is a better way to right the checker board draw_grass. If you add the row to the col 3 things can happen: 1. odd + odd 2. odd+even 3. even+even. Only instances 1 and 3 is the outcome even. If you create an if statement that take the sum of the col and row and mod 2 then you can create the def without writing the same for loop for col (or row) twice. Example shown below. def drawGrass(self): grassColor = (167, 209, 61) for row in range(cellNumber): for col in range(cellNumber): if (col + row) % 2 == 1: grassRect = pygame.Rect(col * cellSize, row * cellSize, cellSize, cellSize) pygame.draw.rect(screen, grassColor, grassRect)
@GUITARATION
@GUITARATION 3 жыл бұрын
can anyone tell me how to slow down snake speed in my game it is moving too fast that i can't even touch the fruit..plz answer my question i will be gratefull if you answer.
@basharjbour9783
@basharjbour9783 3 жыл бұрын
GUITARATION you can change the screen_update timer so the snake movment, collision will happen slower. SCREEN_UPDATE = pygame.USEREVENT pygame.time.set_timer(SCREEN_UPDATE,*150*) although its very laggy and you can't change the speed directly because the snake movment depends on the screen number of cells i think changing the number of cells or squares on the screen is better cell_size = 20 cell_number = *30*
@GUITARATION
@GUITARATION 3 жыл бұрын
Thanks Bashar Jbour 👍👍
@shadower3707
@shadower3707 Жыл бұрын
Hey , I found your video very very usefull and i want to use an alternative method so people learn how to make it , so i'm willing to use your code to make an asmr vide writing the code with explanation in comments , I have done the same in my video , I will of course credit you and mention that it is not me who have written the code It just another way to learn how to code it and learn python and pygame at the same time Just wanted to tell you that to make you aware of it , It is a sign to show appreciation for the knowledge you share and help people learn it in another way (Even tough you allowed to use it for personnal and commercial, showing appreciation )
@diptivishnoi7715
@diptivishnoi7715 3 жыл бұрын
Thx brother i am a kid 14 years old n i wanna be like u, i wanna learn coding n i so thankful to u that u make your videos with such a detailing Plz help me underderstand some stuff I will write it on the comments n once again thx
@sifan3327
@sifan3327 3 жыл бұрын
Creat this game easily. Lots of love.
@Mr0as1s
@Mr0as1s 3 жыл бұрын
line 43, in snake.draw_snake() AttributeError: 'SNAKE' object has no attribute 'draw_snake'
@Xnothen
@Xnothen 3 жыл бұрын
conceptualizing the vector for the corner of the snake was a real headache for me, if anyone else is having issue understanding it then perhaps getting a pen and some paper and drawing it personally will make it easier, at least it did for me. good luck
@MrMatt30987
@MrMatt30987 3 жыл бұрын
Hello. New to python, great video, I understand most of it, I probably need to watch it again, a few times! I found a glitch in the game I am trying to fix, but I can't get my head around it. if you press up and left really fast the snake eats itself, this is easily simulated by changing screen update to 1500 or something outrageous. Why does this happen? I think its because when the key is pressed the direction is changed, so when pressing the second key within the screen update time window the failsafe of if main_game.snake.direction.x != 1: doesn't work because the direction has already changed, even though the block doesn't actually "move" yet, due to the slow screen refresh. I can replicate this down to 5ms screen update, with cell size 1, so its not like I can increase speed to fix it. I don't think I understand the relationship of the while true loop to the pygame.time setting. I think the loop is running really fast, but the screen event is only called/updated every x ms. If thats the case it means I can press many keys before the loop picks up the actual position. Do I need to put a timer on the event.key somehow? I'm lost.
@jeffreywen8901
@jeffreywen8901 3 жыл бұрын
awesome tutorial, I learned a lot. great work!
@lu34z
@lu34z 9 ай бұрын
DAY 1: 50:00
@andrecarneiro1256
@andrecarneiro1256 9 ай бұрын
Amazing tutorial. However, has anyone found a bug when clicking left and down arrow error almost simultanely when going up? It's like since the user is clicking super fast in 2 arrow keys the snake would hit itself missing some validation or whatever.
@dominiknowec9837
@dominiknowec9837 Жыл бұрын
I was thinking a little and i come up with idea that there may be a better way to check body block and it's relation with previous and next blocks. if ... # head elif ... # tail else: # body # First i have created a list of nearby_blocks that contains Vector2 of next block and Vector2 of previous block. nearby_body = [self.body[index-1], self.body[index+1]] if block + Vector2(0, 1) in nearby_body: # Then i check if one of nearby blocks is under currect block if block + Vector2(-1, 0) in nearby_body: # If there is one under then i check if second of them is on the current_block's left screen.blit(self.body_bl, block_rect) # There are nearby blocks under and on its left so it's ╗(body_bottomleft) elif block + Vector2(0, -1) in nearby_body: # If second of them is not on the current block's left then mabye it is above it screen.blit(self.body_vertical, block_rect) # There are nearby blocks under and above it so it's ║ (body_vertical) else block + Vector2(1, 0) in nearby_body: # If it is not on current block's left nor above it then it must be on it's right screen.blit(self.body_br, block_rect) # There are nearby blocks under and on its right so it's ╔ (body_bottomright) elif block + Vector2(0, -1) in nearby_body: # If under current block there are no nearby blocks then maybe there's one above it if block + Vector2(-1, 0) in nearby_body: # If there is one above then i check if second of them is on the current block's left screen.blit(self.body_tl, block_rect) # There are nearby blocks above and on its left so it's ╝ (body_topleft) else block + Vector2(1, 0) in nearby_body: # If second of them isn't on its left then it must be on its right screen.blit(self.body_tr, block_rect) # There are nearby blocks above and on its right so it's ╚ (body_topright) else: # If there are no nearby blocks under nor above current block then there must be on its left and on its right screen.blit(self.body_horizontal, block_rect) # There are nearby blocks on its left and right so its ═ (body_horizontal) I just dont know how much resource consuming is "in list" operation, but whole code seems more intuitive at least for me
@adnanumer415
@adnanumer415 7 ай бұрын
my background checker board is being displayed over the snake rather than under it how can i fix it
@Underratededits9
@Underratededits9 11 ай бұрын
If the cell number is greater than the cell size then the graphics just don't work properly. Is there any fix for that.
@ElloBruh69
@ElloBruh69 3 жыл бұрын
Thank you. I have learnt a lot from this video!
@Sc4rletAss4ssin
@Sc4rletAss4ssin 3 жыл бұрын
Your tutorial is fantastic thank you so much for making this
@big123lak
@big123lak 9 ай бұрын
hell yea dude took like 2 days but I can write this whole program without looking at anything and I understand every piece of it im gonna try to move into a platform type game with more freedom now I wanna make a platformer or 2d adventure game once I understood the previous and next block I pretty much had everything down pack
I made Games with Python for 10 Years...
28:52
DaFluffyPotato
Рет қаралды 337 М.
Coding Adventure: Simulating Fluids
47:52
Sebastian Lague
Рет қаралды 1,8 МЛН
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 1,7 МЛН
Do you choose Inside Out 2 or The Amazing World of Gumball? 🤔
00:19
Can Dangerous Saw Blades Cut Wood?
25:34
Waterjet Channel
Рет қаралды 8 М.
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
Why Scientists Are Puzzled By This Virus
10:44
Kurzgesagt – In a Nutshell
Рет қаралды 2,9 МЛН
Simulating the Evolution of Rock, Paper, Scissors
15:00
Primer
Рет қаралды 1,7 МЛН
I Tried the $1 Billion Dollar Side Hustle
16:39
viyaura
Рет қаралды 548 М.
AI Plays Minecraft Forever (and dies)
23:22
Emergent Garden
Рет қаралды 332 М.
The rarest move in chess
17:01
Paralogical
Рет қаралды 1,9 МЛН
The Most Valuable File Format You've Never Heard Of
15:33
Acerola
Рет қаралды 424 М.
I Built the Pyramids in LEGO!
16:08
Brick Science
Рет қаралды 26 М.
2 YEARS of PYTHON Game Development in 5 Minutes!
4:54
Coding With Russ
Рет қаралды 925 М.
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 1,7 МЛН