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
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
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.
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
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?
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)
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.
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)
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
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 ?
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()
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
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?
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'
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...
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.
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.
@@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
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
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.
@@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.
Please SUBSCRIBE! & help me to reach 50k❤ GOAL
Thanks everyone.
great bro, carry on.
@@Tech2etc sir i have created but don't know the key to start it. From which botton it starts????
@@sameermore9757 click any one of the arrow buttons on your keyboard.
@@Tech2etc yes sir i have done it
@@Tech2etc thanks a lot sir 🔥🔥🔥🔥
Bro I have problem in line 118 can u plz tell me how to solve?
Please join our discord for discuss about it
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
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!
Thx bro, it worked! NICE tutorial!!!
Most welcome
Nice one all work as it should🎉
i know why there is a bug because it doesn't work in pycharm it only works in python
Hi bro. I typed the same but my snake isn't moving instead showing error in turtle.Terminator() line. Please reply asap.
It's work bro... Thnk u❤️
Hi, great lecture, I did everything step by step, but having error here # snake & fruit colision , if snake.distance(fruit) < 20:
its not lined up perfectly, how to fix that
Thank you so much. highly appreciate!
welcome brother.
it works! tysm
I kept getting errors help?
TECH 2etc your amazing thanks very much have helped me alot in learning
Glad u enjoyed.
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
Perfect a project brooo
Thanks
please teach to add play, replay and quit buttons in this code
why
line 11, in screen.bgcolor("#ididid")
unindent does not match any outer in dentation level (,line 125)
Hello! I've compared my code and the source code and it's the same but the snake still doesn't move :(
exactly yr
nice vaia
Thank u vaia.
My problem,at line 7, in
screen = turtle.screen( )
Attribute Error: module 'turtle' has no attribute 'screen'.
So, help me
same problem! did you solve it ?
Write Screen S in capital letter
screen=turtle.Screen()
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.
Source code is given in the description. Have a look at that. You will find your error.
when i run the code my screen is freezed and snake does not move please help asap!
At line 89 , if snake.direction == "right":
I am getting " indentationerror : unindent does not match any outer indentation level
Pls help me!
I will recommend you to checkout the code again. There maybe any condition is wrong.
@@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 😀
@@trickysnipy sure bro
thansk brooo
My isn't working!?
Very good
Thank you
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
I got an IindentationError: unident doesnot match any outer indentation level at line 125
Please help me
it means your line is too far forward, you may have accidentally added a space to the beggining of your line. Hope this helps.
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.
Python Projects | Create Snake Game Step By Step In Python For Beginners
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
Great video.. Your laptop model?
Thank uu.. Its Dell Inspiron 15 3000 series.
@@Tech2etc i5 10 gen variant?
@@harshjain8345 No. Its i5 5th gen.
So, I completed it and it’s working but the problem here is my snake is not moving 😂 how do I set the controls?
the video is outdated, i asked chatgpt to fix it.
@@user-qo5jn2ye3z what's that
@@user-qo5jn2ye3z how do we do that?
Same here
and how can we save the highscores every time it should show the highscore and update it
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?
Please check the shortcut key conditions code again which you have created for moving the snake.
@@Tech2etc i tried but facing the same error, even after changing the shortcut key.
@@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)
Same error
I get the same error
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)
this is not "one...key....press".
Correct form is "on.....key.....press".
It will be screen.onkeypress......
Please correct your spelling mistakes.
@@Tech2etc Thank you, that really helped
I'm also getting same error with right spelling.
Bro plz tell me the version of python you are using for it
Im using the latest version of pycharm
@@Tech2etc he is asking python version 🙄
@@akgang602 Oh sorry.. then its version 3.8.3 im currently using .
@@Tech2etc thanx bro
@@abhishekmalpote9411 Pressure
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
Main loop is not working for me
While True but it's not working
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.
i gor error line 138
'>' not supprted between instance of 'method' and 'int'
I followed your process but after I run, it doesn't pop up
It saying direction is in turtle attribute has no direction
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)
My python is different which one is this
Screen.listen () is error for me
bad event type or keysym error generated
What should I do?
It shows error on .direction while designing snake how can i fix it ?
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
Please get the code from link given in the description.
Hi bro.. I executed this code in pycharm.. But.. At last it is showing the error that is last line turtle. Terminator ()
turtle.Terminator()
are u writing with space?
Hi, i am having an issue than when i score a point i suddenly lose. I did the same code like you.
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
I finish it, but it shows up for a second then goes away, why does this happen
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
Output screen is not able to hold waht to do
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 ?
have u fixed it? I have the same error
It is not working
i have a problem that when i take the food the head is seperated from the body
Oh my god!.....
Please recheck your code & save the snake.
i request someone to paste the whole code in the comment sec!! it would be helpful.
#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()
Bro I can't get this
line 140, in
screen.clear()
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
old_fruit.append(new_fruit)
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.
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?
I think you need the capitalize the U in "up"
Line no 140:-screen.clear() error AA Raha ha please help me bro 😢
ek kam kar coding choude de
it was amazing even tho when my snake eats an apple his speed goes to the moon and idk how to fix it
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'
hello this will help you also plz sub to my yotube
#snake
snake= turtle.Turtle()
snake.speed()
snake.shape("circle")
snake.color("green")
snake.penup()
snake.goto(0,0)
snake.direction = 'stop'
@@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
Hello Buddy ,
I can't play this game. Even if I press any key and I try in both system (Mac and Windows) but the same problem game does not start.
Bro did u fixed it?
bro turtle.Terminator() error
it says code is unreachable
AttributeError: module 'turtle' has no attribute 'screen'. Did you mean: 'Screen'. WHAT SHOULD I DO TO CORRECT THIS ERROR?
It means that You Need to Make the s letter To Capital S Not like just screen Captial S
What did you use to run the code?
Pycharm code editor.
I have an error when running on powershell. it says that speed should have an argument
here's my code
#import packages
import turtle
import random
import time
#creating screen
screen = turtle.Screen()
screen.title("SNAKE GAME")
screen.setup(width=700,height=700)
screen.tracer(0)
screen.bgcolor("#1d1d1d")
#creating border
turtle.speed(5)
turtle.pensize(4)
turtle.penup()
turtle.goto(-310, 250)
turtle.pendown()
turtle.color("red")
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
turtle.speed(speed=)
snake.shape("square")
snake.color("green")
snake.penup()
snake.goto(0, 0)
snake.direction = 'stop'
#food
fruit = turtle.Turtle
fruit.speed()
fruit.shape()
fruit.color()
fruit.penup()
fruit.goto()
old_fruit = []
#scoring
scoring = turtle.Turtle
scoring.speed(0)
scoring.color("white")
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":
y = snake.ycor()
snake.sety(y - 20)
if snake.direction == "right":
x = snake.xcor()
snake.setx(x + 20)
#keyboard binding
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 collision
if snake.distance(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.xcor() < -248:
time.sleep(1)
screen.clear()
screen.bgcolor("turquoise")
scoring.goto(0, 0)
scoring.write("GAME OVER
Your score is {}".format(score), align="center", font=("Courier", 30, "bold"))
#snake collision
for food in old_fruit:
if food.distance(snake) < 20:
time.sleep(1)
screen.clear()
screen.bgcolor("turquoise")
scoring.goto(0, 0)
scoring.write("GAME OVER
Your score is {}".format(score), align="center", font=("Courier", 30, "bold"))
time.sleep(delay)
turtle.Terminator
for index in range(len(old_fruit),-1,0,-1):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: range expected at most 3 arguments, got 4
Bro please Help Me
I did everything but I kept getting invalid direction
it is not moving wat i should do
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
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...
Sir my snake is not moving from which botton it moves. Or i have done any error
@@sameermore9757 did u find any solution ? i have the same probleme
@@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
old_fruit [ ] is showing a problem on pycharm
AttributeError: partially initialized module 'turtle' has no attribute 'title' (most likely due to a circular import). Did you mean: 'turtle'?
error
WICH python do u use
Is this only for pc or we can play this game in Android?
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.
Bro, I also wrote the same code, but it's not working
why the snake can't move in any direction , even tho i followed all the steps and fixed the errors
Source code link given in the description. Please compare that with your code.
My snake wont move. I checked all the snake_move functions and it still didint work
Source code link given in the description. Please compare your code with that one. Your will find the error if there is any.
@@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.
Which software
Pycharm
I did everything also everythings the same as yours but mine wont work
Brother I am having a small TRACEBACK error and an ATTRIBUTE error from where can i get ur help plzz repl y
please explain the error.
@@Tech2etc are u at instagram or telegram or may i have your whatsapp number
I shall send you the pic of error
@@ashwintiwari103 My insta & fb account link given in the description.
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.
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.
man why when i start the game the sanke dosent move
why dont you share the code
The game just crashes when i open up it
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.
Code link given in the description. Please match with my code... There must be any x or y position mistake in your code.
@@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
your code is error,
But how to run your code?
error in line 125
what is the name of this program?
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
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.
@@Tech2etc ok thanks
@@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.
bro i like your content, btw why can't i install the turtle in my terminal
Thanks... Is there any message or error ?
i got the screen update error
Screen is bit blur
Will it be okay for python 3.9
Yeah it will be ok.
How do start a game