Python Projects | Create Snake Game Step By Step In Python For Beginners

  Рет қаралды 142,715

Tech2 etc

Tech2 etc

Күн бұрын

Пікірлер: 227
@Tech2etc
@Tech2etc 4 жыл бұрын
Please SUBSCRIBE! & help me to reach 50k❤ GOAL Thanks everyone.
@Tech2etc
@Tech2etc 4 жыл бұрын
great bro, carry on.
@sameermore9757
@sameermore9757 3 жыл бұрын
@@Tech2etc sir i have created but don't know the key to start it. From which botton it starts????
@Tech2etc
@Tech2etc 3 жыл бұрын
@@sameermore9757 click any one of the arrow buttons on your keyboard.
@sameermore9757
@sameermore9757 3 жыл бұрын
@@Tech2etc yes sir i have done it
@sameermore9757
@sameermore9757 3 жыл бұрын
@@Tech2etc thanks a lot sir 🔥🔥🔥🔥
@osamaal-saadi3821
@osamaal-saadi3821 3 жыл бұрын
When you make those kinds of videos can you explain each line of code and what it does, it will be more beneficial.. thank you
@petertiboldi5308
@petertiboldi5308 3 жыл бұрын
Thx bro, it worked! NICE tutorial!!!
@Tech2etc
@Tech2etc 3 жыл бұрын
Most welcome
@Vidyananda2002
@Vidyananda2002 Жыл бұрын
after game over to restart the game again we have to run the code again instead of that can u define any function of it and by clicking on the restart button we can start the game again
@manhwaboss1473
@manhwaboss1473 9 ай бұрын
its not lined up perfectly, how to fix that
@yashsapre1711
@yashsapre1711 Жыл бұрын
Hi bro. I typed the same but my snake isn't moving instead showing error in turtle.Terminator() line. Please reply asap.
@Eth_Mey
@Eth_Mey Жыл бұрын
Nice one all work as it should🎉
@edwardmakalski5185
@edwardmakalski5185 2 жыл бұрын
I love your content, very informative, my friend ari likes your content too, please keep it up!!!! I wish to see more of your videos!
@techofcraze
@techofcraze 8 ай бұрын
It's work bro... Thnk u❤️
@aniketagrawal8280
@aniketagrawal8280 Жыл бұрын
I was having a doubt that after the final score displayed on the screen, the blue screen is blinking and if we close the turtle then it is showing error in the "screen.clear()" command. In the end of the video, in your code also the same error was coming (time line 27:36) but you haven't explain it in the video. Can you explain this.
@EACWorksYT
@EACWorksYT Жыл бұрын
it works! tysm
@ezinnenath7421
@ezinnenath7421 Жыл бұрын
I kept getting errors help?
@rzzzdzas
@rzzzdzas 2 жыл бұрын
sir , i have problems in line 60 i cant run the code, what do i need to do, ive followed your code precisely, its still not run. ps:beginner here.
@Tech2etc
@Tech2etc 2 жыл бұрын
Source code is given in the description. Have a look at that. You will find your error.
@MarcixGames
@MarcixGames Жыл бұрын
i know why there is a bug because it doesn't work in pycharm it only works in python
@SuperAyanOp
@SuperAyanOp 2 жыл бұрын
Hi the video was nice but as I open the game it shows game over your score was 0 but i didn't even play the game and in terminal box it show your application has been destroyed pls tell me what to do
@WexterYoutube
@WexterYoutube 2 жыл бұрын
Perfect a project brooo
@Tech2etc
@Tech2etc 2 жыл бұрын
Thanks
@Gtlovers
@Gtlovers Жыл бұрын
unindent does not match any outer in dentation level (,line 125)
@trickysnipy
@trickysnipy 3 жыл бұрын
At line 89 , if snake.direction == "right": I am getting " indentationerror : unindent does not match any outer indentation level Pls help me!
@Tech2etc
@Tech2etc 3 жыл бұрын
I will recommend you to checkout the code again. There maybe any condition is wrong.
@trickysnipy
@trickysnipy 3 жыл бұрын
@@Tech2etc no , I have written the code exactly same , but I will check it again. If i ahve any problem I will ask you again! Thankyou 😀
@Tech2etc
@Tech2etc 3 жыл бұрын
@@trickysnipy sure bro
@Vidyananda2002
@Vidyananda2002 Жыл бұрын
and how can we save the highscores every time it should show the highscore and update it
@stan8966
@stan8966 4 жыл бұрын
Thank you so much. highly appreciate!
@Tech2etc
@Tech2etc 4 жыл бұрын
welcome brother.
@dukeankrah9453
@dukeankrah9453 Жыл бұрын
Hi, great lecture, I did everything step by step, but having error here # snake & fruit colision , if snake.distance(fruit) < 20:
@md.motiurrahman4724
@md.motiurrahman4724 3 жыл бұрын
My problem,at line 7, in screen = turtle.screen( ) Attribute Error: module 'turtle' has no attribute 'screen'. So, help me
@meryemelachhab7129
@meryemelachhab7129 2 жыл бұрын
same problem! did you solve it ?
@kawaljeetkaur138
@kawaljeetkaur138 2 жыл бұрын
Write Screen S in capital letter screen=turtle.Screen()
@hirakhan5852
@hirakhan5852 Жыл бұрын
when i run the code my screen is freezed and snake does not move please help asap!
@legendlambchop5
@legendlambchop5 8 күн бұрын
did you ever find a fix
@Maxwell_Integral
@Maxwell_Integral 2 жыл бұрын
Sir for some reason this error is showing and the game doesn't even open. please help me fix it screen.onekeypress(snake_go_down, "Down") AttributeError: '_Screen' object has no attribute 'onekeypress' (error)
@Tech2etc
@Tech2etc 2 жыл бұрын
this is not "one...key....press". Correct form is "on.....key.....press". It will be screen.onkeypress...... Please correct your spelling mistakes.
@Maxwell_Integral
@Maxwell_Integral 2 жыл бұрын
@@Tech2etc Thank you, that really helped
@Shweta-wz2cz
@Shweta-wz2cz Жыл бұрын
I'm also getting same error with right spelling.
@ScratchWithFrank-pw9cq
@ScratchWithFrank-pw9cq Жыл бұрын
so i went through the whole thing and copied it exactly but the score system doesnt work and my snake wouldnt grow. Any idea on how to fix this?? (I just started actual coding after moving from scratch so idk what im doing)
@sri74r
@sri74r 2 жыл бұрын
hi i tried to start but it shows error in line 3 where i typed import turtle i can't find the problem except it doesnt turn gray
@omkarmuni3995
@omkarmuni3995 2 жыл бұрын
I got an IindentationError: unident doesnot match any outer indentation level at line 125
@omkarmuni3995
@omkarmuni3995 2 жыл бұрын
Please help me
@benjaminmyers288
@benjaminmyers288 2 жыл бұрын
it means your line is too far forward, you may have accidentally added a space to the beggining of your line. Hope this helps.
@josephmcnew34
@josephmcnew34 3 жыл бұрын
TECH 2etc your amazing thanks very much have helped me alot in learning
@Tech2etc
@Tech2etc 3 жыл бұрын
Glad u enjoyed.
@abhishekmalpote9411
@abhishekmalpote9411 4 жыл бұрын
Bro plz tell me the version of python you are using for it
@Tech2etc
@Tech2etc 4 жыл бұрын
Im using the latest version of pycharm
@akgang602
@akgang602 4 жыл бұрын
@@Tech2etc he is asking python version 🙄
@Tech2etc
@Tech2etc 4 жыл бұрын
@@akgang602 Oh sorry.. then its version 3.8.3 im currently using .
@abhishekmalpote9411
@abhishekmalpote9411 4 жыл бұрын
@@Tech2etc thanx bro
@Tech2etc
@Tech2etc 4 жыл бұрын
@@abhishekmalpote9411 Pressure
@gikels
@gikels 2 жыл бұрын
i gor error line 138 '>' not supprted between instance of 'method' and 'int'
@mohammedonsi3797
@mohammedonsi3797 Жыл бұрын
why line 11, in screen.bgcolor("#ididid")
@harshjain8345
@harshjain8345 4 жыл бұрын
Great video.. Your laptop model?
@Tech2etc
@Tech2etc 4 жыл бұрын
Thank uu.. Its Dell Inspiron 15 3000 series.
@harshjain8345
@harshjain8345 4 жыл бұрын
@@Tech2etc i5 10 gen variant?
@Tech2etc
@Tech2etc 4 жыл бұрын
@@harshjain8345 No. Its i5 5th gen.
@manavwashal3243
@manavwashal3243 Жыл бұрын
It shows error on .direction while designing snake how can i fix it ?
@DrDelulu
@DrDelulu 3 жыл бұрын
When I press and key the snake does not move, I followed all of your steps and your fixes hut still nothing, and it says my line 88 is wrong the screen.update() and I don't know how to fix it, please help
@Tech2etc
@Tech2etc 3 жыл бұрын
Please get the code from link given in the description.
@LongNguyen-jx8dv
@LongNguyen-jx8dv Жыл бұрын
Hi, i am having an issue than when i score a point i suddenly lose. I did the same code like you.
@ayushpatel_0437
@ayushpatel_0437 2 жыл бұрын
bad event type or keysym error generated What should I do?
@whiterranger8206
@whiterranger8206 2 жыл бұрын
I did everything, but on line 117, something happened with the speed. I don’t know what it was, my code was the same as yours, pls help
@laguadoradrianr.1891
@laguadoradrianr.1891 2 жыл бұрын
I copy all the code .Why don't turn right and left after the snake has passed the border. I hope you can help me
@mohanlalmandal5513
@mohanlalmandal5513 3 жыл бұрын
Very good
@Tech2etc
@Tech2etc 3 жыл бұрын
Thank you
@hmdude
@hmdude 2 жыл бұрын
I finish it, but it shows up for a second then goes away, why does this happen
@m4rkoek768
@m4rkoek768 2 жыл бұрын
thansk brooo
@kumarayushman288
@kumarayushman288 Жыл бұрын
It saying direction is in turtle attribute has no direction
@tsa7736
@tsa7736 3 жыл бұрын
Bro I have problem in line 118 can u plz tell me how to solve?
@Tech2etc
@Tech2etc 3 жыл бұрын
Please join our discord for discuss about it
@vwvwvwvwvwvwvwvwvwvw9
@vwvwvwvwvwvwvwvwvwvw9 2 жыл бұрын
What did you use to run the code?
@Tech2etc
@Tech2etc 2 жыл бұрын
Pycharm code editor.
@daringd2147
@daringd2147 2 жыл бұрын
IDK what did I done wrong but after my snake eat the first fruit . The second food is literally invincible from getting eaten . My snake just run through the food . Can you help me ?
@thomasperez9785
@thomasperez9785 2 жыл бұрын
have u fixed it? I have the same error
@annakoukouri573
@annakoukouri573 2 жыл бұрын
it says to me File "C:\Users\User\AppData\Local\JetBrains\PyCharm Community Edition 2022.2.2\jbr\bin\snakegame\main.py", line 102, in screen.onkeypress(snake_go_up, "up") File i dont know what mistake i did can you help me?
@lailaguizel8979
@lailaguizel8979 2 жыл бұрын
I think you need the capitalize the U in "up"
@munlelapaulomunlela6207
@munlelapaulomunlela6207 4 жыл бұрын
Hello broh! i've a problem, when i run the code i can se the screen, but when i try to click any direction key nothing happens... What can i do to solve this?
@Tech2etc
@Tech2etc 4 жыл бұрын
checkout the keyboard building code again.... and on that part python goes case sensitive..
@munlelapaulomunlela6207
@munlelapaulomunlela6207 4 жыл бұрын
@@Tech2etc Alright, i'm going to ckeck it
@munlelapaulomunlela6207
@munlelapaulomunlela6207 4 жыл бұрын
@@Tech2etc Thanks broh! all done and now its running without problems.
@Tech2etc
@Tech2etc 4 жыл бұрын
@@munlelapaulomunlela6207 great bro. carry on❤
@munlelapaulomunlela6207
@munlelapaulomunlela6207 4 жыл бұрын
@@Tech2etc good bless you broh! I'm with you!
@king0fsilence
@king0fsilence 10 ай бұрын
My isn't working!?
@danielmorars4850
@danielmorars4850 2 жыл бұрын
hi I tried to do this but I have a problem in line 39 about speed it say line 39, in snake.speed() AttributeError: 'list' object has no attribute 'speed'
@Cat_6921
@Cat_6921 2 жыл бұрын
hello this will help you also plz sub to my yotube
@Cat_6921
@Cat_6921 2 жыл бұрын
#snake snake= turtle.Turtle() snake.speed() snake.shape("circle") snake.color("green") snake.penup() snake.goto(0,0) snake.direction = 'stop'
@benjie293
@benjie293 2 жыл бұрын
@@Cat_6921 # snake snake = turtle.Turtle() snake.speed(0) snake.shape("square") snake.color("green") snake.penup() snake.goto(0, 0) snake.direction = 'stop' had that error too, check your spacing between the 'snake = turtle.Turtle
@TechTanim
@TechTanim 4 жыл бұрын
nice vaia
@Tech2etc
@Tech2etc 4 жыл бұрын
Thank u vaia.
@evabucekova7305
@evabucekova7305 2 жыл бұрын
Hi, you're great, I did everything step by step, but when I start the game, everything looks as it should, but I can't move with the snake, would you please advise me?
@Tech2etc
@Tech2etc 2 жыл бұрын
Please check the shortcut key conditions code again which you have created for moving the snake.
@ankushhadge9571
@ankushhadge9571 2 жыл бұрын
@@Tech2etc i tried but facing the same error, even after changing the shortcut key.
@felipegomes6312
@felipegomes6312 2 жыл бұрын
@@ankushhadge9571 def snake_move(): if snake.direction == "up": y = snake.ycor() snake.sety(y + 20) if snake.direction == "down": y = snake.ycor() snake.sety(y - 20) if snake.direction == "left": x = snake.xcor() snake.setx(x - 20) if snake.direction == "right": x = snake.xcor() snake.setx(x + 20)
@suyashdhumal4361
@suyashdhumal4361 2 жыл бұрын
Same error
@jameskenneth4653
@jameskenneth4653 2 жыл бұрын
I get the same error
@ashwintiwari103
@ashwintiwari103 4 жыл бұрын
Brother I am having a small TRACEBACK error and an ATTRIBUTE error from where can i get ur help plzz repl y
@Tech2etc
@Tech2etc 4 жыл бұрын
please explain the error.
@ashwintiwari103
@ashwintiwari103 4 жыл бұрын
@@Tech2etc are u at instagram or telegram or may i have your whatsapp number I shall send you the pic of error
@Tech2etc
@Tech2etc 4 жыл бұрын
@@ashwintiwari103 My insta & fb account link given in the description.
@digitalpanda5969
@digitalpanda5969 2 жыл бұрын
Python Projects | Create Snake Game Step By Step In Python For Beginners
@greatwayabdu
@greatwayabdu 3 жыл бұрын
Hi Thanks for recording it is working I wrote all the words carefully But I want that, For example I played and touched the line and lose the game and it write GAME OVER YOUR SCORE IS ... then I have to exit and play again, But I want that press ENTER button and back to game not exiting
@chinnu9036
@chinnu9036 3 жыл бұрын
Sir there is Error in code. In ## snake and border collision Line no 150 Screen.clear() 👆🏻 here it is showing Error. Please help how to fix this.
@Tech2etc
@Tech2etc 3 жыл бұрын
Code link given in the description. Please match with my code... There must be any x or y position mistake in your code.
@chinnu9036
@chinnu9036 3 жыл бұрын
@@Tech2etc the code line number which I have mentioned is from your code source only sir. I have tried your code also to check and find but it is showing same Error only. Please check it
@nehakapoor3719
@nehakapoor3719 3 жыл бұрын
Bro, pls help me, I am getting error, Traceback (most recent call last): File "C:\Users\Rishitt\PycharmProjects\snakegame\main.py", line 121, in old_fruit = append(new_fruit) NameError: name 'append' is not defined
@sachinnaik10101
@sachinnaik10101 2 жыл бұрын
old_fruit.append(new_fruit)
@sachinnaik10101
@sachinnaik10101 2 жыл бұрын
bro turtle.Terminator() error it says code is unreachable
@PrernaJadhav-r4h
@PrernaJadhav-r4h Жыл бұрын
Output screen is not able to hold waht to do
@Ishmalirfan
@Ishmalirfan 9 ай бұрын
please teach to add play, replay and quit buttons in this code
@eliaremon802
@eliaremon802 2 жыл бұрын
i have a problem that when i take the food the head is seperated from the body
@Tech2etc
@Tech2etc 2 жыл бұрын
Oh my god!..... Please recheck your code & save the snake.
@KawiiNinja
@KawiiNinja 2 жыл бұрын
Is this only for pc or we can play this game in Android?
@Tech2etc
@Tech2etc 2 жыл бұрын
You can play it in android also. But you have to first convert it into apk file. I have another tutorial about the full process... code to apk.. check our channel for the tutorial.
@もろは-d9k
@もろは-d9k 3 жыл бұрын
Hello master they need the application to run this program this game or not? If need the application pls give the link for download the app.
@Tech2etc
@Tech2etc 3 жыл бұрын
I have a tutorial about how to convert a py file into an exe file/app.... I gave that snake app download link on that video description. You can download it from there. Please find out that tutorial on my channel.
@farhanrahman7664
@farhanrahman7664 Жыл бұрын
AttributeError: module 'turtle' has no attribute 'screen'. Did you mean: 'Screen'. WHAT SHOULD I DO TO CORRECT THIS ERROR?
@perryroblox
@perryroblox Жыл бұрын
It means that You Need to Make the s letter To Capital S Not like just screen Captial S
@Saturn_Uranus
@Saturn_Uranus Жыл бұрын
So, I completed it and it’s working but the problem here is my snake is not moving 😂 how do I set the controls?
@greenninja-f2q
@greenninja-f2q Жыл бұрын
the video is outdated, i asked chatgpt to fix it.
@michelleeldn
@michelleeldn Жыл бұрын
@@greenninja-f2q what's that
@Saturn_Uranus
@Saturn_Uranus Жыл бұрын
@@greenninja-f2q how do we do that?
@anjusehgal4936
@anjusehgal4936 Жыл бұрын
Same here
@neerudupavanachyuth6205
@neerudupavanachyuth6205 2 жыл бұрын
Hi bro.. I executed this code in pycharm.. But.. At last it is showing the error that is last line turtle. Terminator ()
@rafirehad3195
@rafirehad3195 Жыл бұрын
turtle.Terminator() are u writing with space?
@KarikariKwameAnim
@KarikariKwameAnim 9 ай бұрын
I followed your process but after I run, it doesn't pop up
@BEU167
@BEU167 10 ай бұрын
Line no 140:-screen.clear() error AA Raha ha please help me bro 😢
@SmartShinChan-15
@SmartShinChan-15 10 ай бұрын
ek kam kar coding choude de
@abhishekmalpote9411
@abhishekmalpote9411 4 жыл бұрын
Will it be okay for python 3.9
@Tech2etc
@Tech2etc 4 жыл бұрын
Yeah it will be ok.
@m-fazin
@m-fazin 2 жыл бұрын
AttributeError: partially initialized module 'turtle' has no attribute 'title' (most likely due to a circular import). Did you mean: 'turtle'? error
@3dgoosee
@3dgoosee 2 жыл бұрын
WICH python do u use
@VALORANTPLAYERZZZZ
@VALORANTPLAYERZZZZ 2 жыл бұрын
it is not moving wat i should do
@captainluffy177
@captainluffy177 2 жыл бұрын
Thank you for the amazing vedio everything is working except that my snake can only eat 1 food. For some reason the snake can't eat 2nd and it just goes past the 2nd food.
@g.n_amir76
@g.n_amir76 Жыл бұрын
Screen.listen () is error for me
@Theguywhoreallyjustrhymed
@Theguywhoreallyjustrhymed 2 жыл бұрын
My snake wont move. I checked all the snake_move functions and it still didint work
@Tech2etc
@Tech2etc 2 жыл бұрын
Source code link given in the description. Please compare your code with that one. Your will find the error if there is any.
@Theguywhoreallyjustrhymed
@Theguywhoreallyjustrhymed 2 жыл бұрын
@@Tech2etc i used the source code and it still didn't work. Whenever i pressed a key it would teleport my snake into the border in that direction.
@outcastongfuel1398
@outcastongfuel1398 3 жыл бұрын
HI question; when I play the game, i can't move for some reason, do you know why? I have followed everything in the video. Great vid btw
@Tech2etc
@Tech2etc 3 жыл бұрын
i also had the same problem... and i did debugged all errors at the end of the video. Please watch the full tutorial... Specially checkout the x, y position part and binding part again.. There must be any wrong value...
@sameermore9757
@sameermore9757 3 жыл бұрын
Sir my snake is not moving from which botton it moves. Or i have done any error
@meryemelachhab7129
@meryemelachhab7129 2 жыл бұрын
@@sameermore9757 did u find any solution ? i have the same probleme
@sameermore9757
@sameermore9757 2 жыл бұрын
@@meryemelachhab7129 just check the code very very care fully. It seems that there is no mistake but there is. So check it from first line to last
@AyaanMahmood-be2yj
@AyaanMahmood-be2yj Жыл бұрын
hi tech 2 etc can you put the link that you used to create the snake game in the comment box when you see it thanks.
@MEHRIMAENTERTAINMENT-cu5ni
@MEHRIMAENTERTAINMENT-cu5ni Жыл бұрын
your code is error, But how to run your code?
@sagargaming9236
@sagargaming9236 2 жыл бұрын
Main loop is not working for me While True but it's not working
@penguinman2044
@penguinman2044 2 жыл бұрын
man why when i start the game the sanke dosent move
@shravanimore5024
@shravanimore5024 3 жыл бұрын
i cant get the food its just taking 1 food only..so that's why my score is always 1..please tell me solution
@Tech2etc
@Tech2etc 3 жыл бұрын
please checkout the food & movement part code again. Also x & y values should be accurate.
@TheOfficialFliksPlayz
@TheOfficialFliksPlayz 4 ай бұрын
My python is different which one is this
@ezinnenath7421
@ezinnenath7421 Жыл бұрын
I did everything but I kept getting invalid direction
@govindl6348
@govindl6348 Жыл бұрын
Bro I can't get this line 140, in screen.clear()
@AnirudhSharma-qt7yj
@AnirudhSharma-qt7yj 2 жыл бұрын
old_fruit [ ] is showing a problem on pycharm
@eliaremon802
@eliaremon802 2 жыл бұрын
what is the name of this program?
@anveramanathullah7140
@anveramanathullah7140 Жыл бұрын
Bro, I also wrote the same code, but it's not working
@JonathanDaily
@JonathanDaily 4 жыл бұрын
bro i like your content, btw why can't i install the turtle in my terminal
@Tech2etc
@Tech2etc 4 жыл бұрын
Thanks... Is there any message or error ?
@vishals3234
@vishals3234 11 ай бұрын
Which software
@Tech2etc
@Tech2etc 11 ай бұрын
Pycharm
@bemschurger
@bemschurger Жыл бұрын
The game just crashes when i open up it
@jeffcastillo495
@jeffcastillo495 2 жыл бұрын
I did everything also everythings the same as yours but mine wont work
@jentibambhaniya4436
@jentibambhaniya4436 9 ай бұрын
It is not working
@meryemelachhab7129
@meryemelachhab7129 2 жыл бұрын
why the snake can't move in any direction , even tho i followed all the steps and fixed the errors
@Tech2etc
@Tech2etc 2 жыл бұрын
Source code link given in the description. Please compare that with your code.
@lilyimit4723
@lilyimit4723 2 жыл бұрын
it was amazing even tho when my snake eats an apple his speed goes to the moon and idk how to fix it
@slayer_xd9760
@slayer_xd9760 2 жыл бұрын
I am working on this for a whole day and my back is hurting alot. My all elements are okay but the snake doesn't move. if u have any message media give it. I will show u my work and see what have i done. Please this is my request I did this for school work
@Tech2etc
@Tech2etc 2 жыл бұрын
I have added the source code in the description. You can get the source code from there & compare it with your code. But still if you are facing any problems, check description to contact with me.
@slayer_xd9760
@slayer_xd9760 2 жыл бұрын
@@Tech2etc ok thanks
@slayer_xd9760
@slayer_xd9760 2 жыл бұрын
@@Tech2etc I am still having problem and I don’t know how to do anything now because it’s messed up. Just give ur contact info and let’s have the conversation there.
@MREditz170
@MREditz170 2 жыл бұрын
i got the screen update error
@a.hannan_06
@a.hannan_06 2 жыл бұрын
i request someone to paste the whole code in the comment sec!! it would be helpful.
@ryandavis3912
@ryandavis3912 Жыл бұрын
#importing libraries import turtle import random import time #creating turtle screen screen = turtle.Screen() screen.title('SNAKE GAME') screen.setup(width = 700, height = 700) screen.tracer(0) turtle.bgcolor('green') ##creating a border for our game turtle.speed(5) turtle.pensize(4) turtle.penup() turtle.goto(-310,250) turtle.pendown() turtle.color('black') turtle.forward(600) turtle.right(90) turtle.forward(500) turtle.right(90) turtle.forward(600) turtle.right(90) turtle.forward(500) turtle.penup() turtle.hideturtle() #score score = 0 delay = 0.1 #snake snake = turtle.Turtle() snake.speed(0) snake.shape('square') snake.color("black") snake.penup() snake.goto(0,0) snake.direction = 'stop' #food fruit = turtle.Turtle() fruit.speed(0) fruit.shape('circle') fruit.color('red') fruit.penup() fruit.goto(30,30) old_fruit=[] #scoring scoring = turtle.Turtle() scoring.speed(0) scoring.color("black") scoring.penup() scoring.hideturtle() scoring.goto(0,300) scoring.write("Score :",align="center",font=("Courier",24,"bold")) #######define how to move def snake_go_up(): if snake.direction != "down": snake.direction = "up" def snake_go_down(): if snake.direction != "up": snake.direction = "down" def snake_go_left(): if snake.direction != "right": snake.direction = "left" def snake_go_right(): if snake.direction != "left": snake.direction = "right" def snake_move(): if snake.direction == "up": y = snake.ycor() snake.sety(y + 20) if snake.direction == "down": y = snake.ycor() snake.sety(y - 20) if snake.direction == "left": x = snake.xcor() snake.setx(x - 20) if snake.direction == "right": x = snake.xcor() snake.setx(x + 20) # Keyboard bindings screen.listen() screen.onkeypress(snake_go_up, "Up") screen.onkeypress(snake_go_down, "Down") screen.onkeypress(snake_go_left, "Left") screen.onkeypress(snake_go_right, "Right") #main loop while True: screen.update() #snake and fruit coliisions if snake.distance(fruit)< 20: x = random.randint(-290,270) y = random.randint(-240,240) fruit.goto(x,y) scoring.clear() score+=1 scoring.write("Score:{}".format(score),align="center",font=("Courier",24,"bold")) delay-=0.001 ## creating new_ball new_fruit = turtle.Turtle() new_fruit.speed(0) new_fruit.shape('square') new_fruit.color('red') new_fruit.penup() old_fruit.append(new_fruit) #adding ball to snake for index in range(len(old_fruit)-1,0,-1): a = old_fruit[index-1].xcor() b = old_fruit[index-1].ycor() old_fruit[index].goto(a,b) if len(old_fruit)>0: a= snake.xcor() b = snake.ycor() old_fruit[0].goto(a,b) snake_move() ##snake and border collision if snake.xcor()>280 or snake.xcor()< -300 or snake.ycor()>240 or snake.ycor()
@EmirKayaloglu
@EmirKayaloglu Жыл бұрын
for index in range(len(old_fruit),-1,0,-1): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: range expected at most 3 arguments, got 4 Bro please Help Me
@AliMasterRoblox
@AliMasterRoblox 2 жыл бұрын
bro it tells me a lot of errors and stuff and i copied you from the start to the end but still i cant even start the game and it doesnt show me the game😩
@Tech2etc
@Tech2etc 2 жыл бұрын
Check description you will find the source code.
@AliMasterRoblox
@AliMasterRoblox 2 жыл бұрын
@@Tech2etc👌
@AliMasterRoblox
@AliMasterRoblox 2 жыл бұрын
@@Tech2etc hello the site tell me that it cant be reached so i dont know what to do and i really make a game like this
@PreetVadhiya
@PreetVadhiya 11 ай бұрын
why dont you share the code
@brendaonsare8173
@brendaonsare8173 2 жыл бұрын
How do start a game
@Gtlovers
@Gtlovers Жыл бұрын
error in line 125
@cxptan_mf
@cxptan_mf 2 жыл бұрын
This everything doesnt work it is work of edit
@yashnigam2926
@yashnigam2926 2 жыл бұрын
true
Learning pygame by creating Snake [python tutorial]
2:05:00
Clear Code
Рет қаралды 384 М.
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,7 МЛН
24 Часа в БОУЛИНГЕ !
27:03
A4
Рет қаралды 7 МЛН
Every team from the Bracket Buster! Who ya got? 😏
0:53
FailArmy Shorts
Рет қаралды 13 МЛН
Snake Game in Python Easy Tutorial | PyGame
20:38
Programmers' Place
Рет қаралды 17 М.
Create Snake with Python in 20 MINUTES!
22:59
baraltech
Рет қаралды 24 М.
How to Remember Everything You Read
26:12
Justin Sung
Рет қаралды 3,1 МЛН
Evolving AIs - More Complex Environment
22:24
Pezzza's Work
Рет қаралды 315 М.
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 113 М.
How to Create a Neural Network (and Train it to Identify Doodles)
54:51
Sebastian Lague
Рет қаралды 1,9 МЛН
PyCharm Tutorial | Introduction to PyCharm | Basics in 10 Minutes
10:00
Max Rohowsky (Max on Tech)
Рет қаралды 569 М.
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,5 МЛН