Python Game Programming Tutorial: Snake Game Part 1

  Рет қаралды 346,352

TokyoEdtech

TokyoEdtech

Күн бұрын

Пікірлер: 612
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Check out the full playlist here: kzbin.info/www/bejne/eIGafICil9unhdE Become a member and support the channel: kzbin.info/door/2vm-0XX5RkWCXWwtBZGOXgjoin
@balaji.n7819
@balaji.n7819 4 жыл бұрын
can you say what to doin terminal should we install turtle?
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
The turtle module comes with Python so you don't need to install it
@sahirbinsaud680
@sahirbinsaud680 3 жыл бұрын
File "c:\Users\*****\Desktop\PyGame\main.py", line 8, in wn = turtle.screen AttributeError: module 'turtle' has no attribute 'screen' plz plz plz help anyone
@sahirbinsaud680
@sahirbinsaud680 3 жыл бұрын
@@TokyoEdTech File "c:\Users\*****\Desktop\PyGame\main.py", line 8, in wn = turtle.screen AttributeError: module 'turtle' has no attribute 'screen' plz plz plz help anyone
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
@@sahirbinsaud680 Screen should be capitalized. Screen not screen.
@neonboy1998
@neonboy1998 3 жыл бұрын
found you from free code channel. the guy who was teaching snake there was completely useless in teaching and i got the concepts of the pong so easily due to your teaching methods. thanks again for uploading these kind of videos of aspiring software engineers like us. really appreciate your time and effort in doing so.
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Thanks for the kind words - much appreciated. Keep on codin'!
@اقراء-و5ه
@اقراء-و5ه 5 жыл бұрын
the best educator on the internet tysm...your videos are really helpful
@milkshakeinasnowstorm
@milkshakeinasnowstorm 5 жыл бұрын
I came here to seek out the snake tutorial because I've seen your Pong tutorial on an other video (compilation of Python game tutorials). Just want to say thank you, and to tell you that the way you're explaining and presenting everything line by line is very, very helpful for us beginners.
@sephplayzshortz8943
@sephplayzshortz8943 2 жыл бұрын
The way you explain things are SPOT ON. Most programming tutorials for snake game always say you need to put on curses you need to import the pygame modual. You have done none of that and has made sure this tutorial is compatible for Mac and Windows and Linux. I love how you mentioned that you need to test after every paragraph of code you do, I used to be one of those people who did the whole thing but you t a ugh me that you aren't going to go far without testing a new peice of code! Yesterday, I did the Pong game you did and it was the best tutorial I have ever seen. You have earnt a sub!
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
Thank you, I try! I teach middle and high school coding, so that is my intended audience - it needs to be spelled out clearly. Plus, it is easier if you don't have to install something like curses or pygame. The turlte module is pretty powerful once you learn it. Check out my Space Arena tutorial to see what is possible.
@sephplayzshortz8943
@sephplayzshortz8943 2 жыл бұрын
@@TokyoEdTech thank you for the advice! I'll be a pro at python in no time!
@marc135
@marc135 2 жыл бұрын
I am currently at summer camp working on a coding project and I have absolutely no experience with python AT ALL. Your videos are very easy to understand and very very helpful. It took me 4 hours to find the right snake game tutorial - good thing I found this video.
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
Great to hear! Glad I could help. Keep on codin'!
@chloekimball536
@chloekimball536 5 жыл бұрын
I have finished the series and I am commenting here so people who are in a dilemma to continue can read my comment. THIS SERIES IS ABSOLUTELY FANTASTIC! Clear, concise and absolutely no bullshit
@rushaan3039
@rushaan3039 4 жыл бұрын
I love this, thank you so much for helping me out i will be watching all the parts of creating snake game and subbed also keep making videos like this! A big thumbs up
@sc0utop741
@sc0utop741 4 жыл бұрын
I just love ur effort and would like to say Thanks a ton my hero!!!😃😃😃😃
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Thanks! Keep on codin'!
@Yzrie
@Yzrie 5 жыл бұрын
How do you get that kind of python? I can't press backspace in my version. (Sorry if it looks like a dumb question. Beginner here)
@konoyaro09
@konoyaro09 21 күн бұрын
1:33 how did you get that list,in my python there is no list by default please help
@TokyoEdTech
@TokyoEdTech 21 күн бұрын
@@konoyaro09 It depends on which editor or IDE you are using. Check out Geany or VS Code.
@heartoffire5902
@heartoffire5902 2 жыл бұрын
I can't tell you how deeply I appreciate you both using and encouraging others to use iterative programming to ensure you can quickly locate and fix issues. I naturally use this technique, partly because I'm new to programming and I know how easily things can break, and partly because I simply enjoy seeing my creation develop and grow in a tangible way. It also helps extraordinarily when watching tutorials like this. I was watching someone else's earlier and frankly it was extremely stressful because he was making mistakes and didn't check his code until at least 10 minutes into the video, at which point he ran into the consequence that I had spotted from the start. But I assumed he knew what he was doing because he was more experienced, so I spent a lot of time simply typing without explanation as to what I was doing - and I didn't get to figure out where any other problems were because there were no points for comparison along the way for testing. I felt like there wasn't much point in continuing because I just ended up feeling frustrated with myself, the code, and the guy who was actually kind enough to make a tutorial in the first place. I did decide to check out your channel after that. Your Pong series was the first one I used and it made programming feel not only possible, but also sensical. Your teaching technique is clear, efficient, and encouraging. I'm actually learning things along the way and understanding the purpose and use of each piece of code instead of just copying and attempting to google everything frantically hoping I'll flail across the internet enough until I hit the right answer. So thank you for sharing all these techniques and putting so much of yourself into allowing things to make sense to people who are new to this world.
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
You are quite welcome - glad you found value here! I do try to keep things step by step - I teach middle and high school students and small digestible chunks are very helpful. It drives me nuts when my students don't test their code as they go along - so I have to model the correct behavior. Learning to code is a long process - there's always something new to learn! But, once you get the basics down, it becomes much easier. Keep on codin'!
@Hunkzes
@Hunkzes 5 ай бұрын
I have no idea how to thank you, I really appreciate the effort. It is my first python project and you helped me a lot.
@TokyoEdTech
@TokyoEdTech 5 ай бұрын
Thank you is enough...keep on codin'!
@littlenickey3554
@littlenickey3554 4 жыл бұрын
Thank you so much for the tutorial! Just finished the basics, but I was wanting to know how you would go about coding a computer to play snake against you. Thank you!
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Thanks! The first thing I'd do is to get a second player on the screen that works with with the keyboard. Once you do that, then you can start thinking about automating the snake.
@noskillant6168
@noskillant6168 6 жыл бұрын
Love your videos man. Please keep it up! Definitely helps someone like me who is self teaching off mainly youtube.
@olakolade6656
@olakolade6656 4 жыл бұрын
You are an amazing youtuber! I'm a teenager learning to code and you have really helped me! Thanks!
@Tanzanight-yo9lw
@Tanzanight-yo9lw 4 жыл бұрын
This is soo much better than other tutorials!!
@konoyaro09
@konoyaro09 21 күн бұрын
1:32 in my python i dont get that list,how can i fix that
@liamg.-devkat9451
@liamg.-devkat9451 6 жыл бұрын
The version you made is very simple and great for beginners! I really like this because there is so much you could add on to it like a Game Over screen or buttons with tkinter
@aidenpd1006
@aidenpd1006 4 жыл бұрын
Hey, I really like your videos and I think it's great how fast you respond to these comments! Just a quick question - nothing's wrong with my code, but I get this message every time I run the program: "DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning." Is there a way to fix this or at least stop this from showing every time? (where do I "set TK_SILENCE_DEPRECATION=1"?). Also, if it helps I'm on a mac, and if you don't know that's okay. Thanks for the super helpful videos!
@tentekgaming3687
@tentekgaming3687 5 жыл бұрын
This is my first Python practice with your video and it worked at first try :D. Subed and liked.
@I_Am_Kot
@I_Am_Kot 4 жыл бұрын
I followed these tutorials and made my first game in python. Thanks for making this tutorial! P.S I checked out the github and I really like the multiplayer version!
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Great to hear - keep on codin'!
@bountyhunter8132
@bountyhunter8132 5 жыл бұрын
Plus, I loved that space invaders series of yours. Amazing
@Grunge_Lemon
@Grunge_Lemon 2 жыл бұрын
cannot believe you still help people to this day. absolute legend!!
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
Thanks - I try!
@alishavandi3613
@alishavandi3613 3 жыл бұрын
Thank you for these awesome tutorials. Is there a way to display a grid where the snake is moving?
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Yep - you just need to use a background image or draw the lines indivudually.
@DOARE
@DOARE 4 жыл бұрын
here is the code import turtle import time import random delay = 0.1 # Score score = 0 high_score = 0 # Set up the screen wn = turtle.Screen() wn.title("Snake Game by @TokyoEdTech") wn.bgcolor("green") wn.setup(width=600, height=600) wn.tracer(0) # Turns off the screen updates # Snake head head = turtle.Turtle() head.speed(0) head.shape("square") head.color("black") head.penup() head.goto(0,0) head.direction = "stop" # Snake food food = turtle.Turtle() food.speed(0) food.shape("circle") food.color("red") food.penup() food.goto(0,100) segments = [] # Pen pen = turtle.Turtle() pen.speed(0) pen.shape("square") pen.color("white") pen.penup() pen.hideturtle() pen.goto(0, 260) pen.write("Score: 0 High Score: 0", align="center", font=("Courier", 24, "normal")) # Functions def go_up(): if head.direction != "down": head.direction = "up" def go_down(): if head.direction != "up": head.direction = "down" def go_left(): if head.direction != "right": head.direction = "left" def go_right(): if head.direction != "left": head.direction = "right" def move(): if head.direction == "up": y = head.ycor() head.sety(y + 20) if head.direction == "down": y = head.ycor() head.sety(y - 20) if head.direction == "left": x = head.xcor() head.setx(x - 20) if head.direction == "right": x = head.xcor() head.setx(x + 20) # Keyboard bindings wn.listen() wn.onkeypress(go_up, "w") wn.onkeypress(go_down, "s") wn.onkeypress(go_left, "a") wn.onkeypress(go_right, "d") # Main game loop while True: wn.update() # Check for a collision with the border if head.xcor()>290 or head.xcor()290 or head.ycor() high_score: high_score = score pen.clear() pen.write("Score: {} High Score: {}".format(score, high_score), align="center", font=("Courier", 24, "normal")) # Move the end segments first in reverse order for index in range(len(segments)-1, 0, -1): x = segments[index-1].xcor() y = segments[index-1].ycor() segments[index].goto(x, y) # Move segment 0 to where the head is if len(segments) > 0: x = head.xcor() y = head.ycor() segments[0].goto(x,y) move() # Check for head collision with the body segments for segment in segments: if segment.distance(head) < 20: time.sleep(1) head.goto(0,0) head.direction = "stop" # Hide the segments for segment in segments: segment.goto(1000, 1000) # Clear the segments list segments.clear() # Reset the score score = 0 # Reset the delay delay = 0.1 # Update the score display pen.clear() pen.write("Score: {} High Score: {}".format(score, high_score), align="center", font=("Courier", 24, "normal")) time.sleep(delay) wn.mainloop()
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Thanks for sharing - there is also a link the description to the code on GITHUB.
@jasejoe8117
@jasejoe8117 3 жыл бұрын
thanks dude im not familiar with git hub
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
@@jasejoe8117 Check it out - it is very helpful!
@megashock1319
@megashock1319 5 жыл бұрын
Whenever I do anything with "import (whatever)" it gets greyed out and the word "import" isn't red anymore. Im prolly just dumb, but I don't know how to not make it go grey after I press anything
@megashock1319
@megashock1319 5 жыл бұрын
@@TokyoEdTech I fixed it, I was using pycharm and it sends an message if something is imported but isn't being used.
@thestartupguy3975
@thestartupguy3975 6 жыл бұрын
Helped sooooo much to keep my game window open!!! Thanks sooo much!!!
@Oderwat
@Oderwat Жыл бұрын
I just want to let you know that I just got a snake game with your name as "creator" from an AI that uses the LLM "deepseek-coder". So they have for sure used your code for training and the AI kind of copies what you did.
@TokyoEdTech
@TokyoEdTech Жыл бұрын
Thanks for letting me know. It's all good - if my code can help others I'm happy. Keep on codin'!
@BigDaddyGuagg
@BigDaddyGuagg 5 жыл бұрын
Isn't there something better than the turtle module?
@SUNYBOI
@SUNYBOI 4 жыл бұрын
Sir I ran the code ....my green screen came but it vanished quickly
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Check the link that says "NEED HELP?".
@colwarsstudiobrickfilmandm8580
@colwarsstudiobrickfilmandm8580 4 жыл бұрын
I had that issue you have to open the python idle and make open the file. Than run it through there its not a code error it took me forever to figure that out! I guess on some laptops you cant run a .py file through terminal...
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
@@colwarsstudiobrickfilmandm8580 Glad you figured it out on your own. But I wish people would realize I can't help without seeing the code and save me the effort of having to ask every time.
@theSoberSobber
@theSoberSobber 5 жыл бұрын
Sir, I am not able to Run the File In Terminal (I am also Using VS Code). The Terminal Pops up for about a second and then just disappears. I am not able to drag the window from above as you do......... Please help...
@DrNupurDubey
@DrNupurDubey 4 жыл бұрын
hi, I want an image in the background what should I do?
@DrNupurDubey
@DrNupurDubey 4 жыл бұрын
@@TokyoEdTech thank u so much
@DrNupurDubey
@DrNupurDubey 4 жыл бұрын
@@TokyoEdTech hello ,instead square shape of head can we use a image
@poketube7222
@poketube7222 4 жыл бұрын
A lots of Thanks from India 🇮🇳
@prod.shanmuga5379
@prod.shanmuga5379 4 жыл бұрын
U teach really well just started with python and I'm really happy . Print("Thanks Mann")😂
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
print("Happy to hear that!")
@sahirbinsaud680
@sahirbinsaud680 3 жыл бұрын
File "c:\Users\*****\Desktop\PyGame\main.py", line 8, in wn = turtle.screen AttributeError: module 'turtle' has no attribute 'screen' plz plz plz help anyone
@dam22522
@dam22522 3 жыл бұрын
thanks for leading in my first python project
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
You're welcome - keep on codin'!
@codingisfun007
@codingisfun007 4 жыл бұрын
Source Code: import turtle # Set up the screen wn = turtle.Screen() wn.title("Snake Game") wn.bgcolor("green") wn.setup(width=600, height=600) wn.tracer(0) wn.mainloop()
@shaka4448
@shaka4448 4 жыл бұрын
Yay I have come from pong and am excited to start on this
@yuvithegreat3878
@yuvithegreat3878 4 жыл бұрын
Same
@anugeeta7420
@anugeeta7420 4 жыл бұрын
I'm not getting the title in output. What should i do?
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Check the link that says "NEED HELP?"
@hanli4977
@hanli4977 5 жыл бұрын
Hi Christian. Thank you for the amazing tutorial. Is there any way to add a "pause" function to the game? When the snake hits the wall, can we make the snake coming out from the other wall, insteaded of game over? Great Job!!
@jordynmuldrow3885
@jordynmuldrow3885 2 жыл бұрын
Thank you so much for your tutorials, they have been super helpful.
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
You're very welcome - glad I could help. Keep on codin'!
@dadipy58
@dadipy58 9 ай бұрын
fr
@迷路人-i8l
@迷路人-i8l 4 жыл бұрын
hello ,Mr thompson,i want to ask you a question for the visual studio, i have been written a same code with you, but i cannot display a canvas, can you tell me how to correct?
@迷路人-i8l
@迷路人-i8l 4 жыл бұрын
@@TokyoEdTech thx,I have found the reason why it cannot to run, I actually missed the last line of code. lol
@迷路人-i8l
@迷路人-i8l 4 жыл бұрын
@@TokyoEdTech Yeah,I have done it XD
@bestcreationinpoetry1422
@bestcreationinpoetry1422 4 жыл бұрын
@@TokyoEdTech may i run this in pycharm
@mantease2715
@mantease2715 4 жыл бұрын
Yesss!!!! It worksss!!! hope you upload more videos like this
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
I will try my best.
@Rl-tn1ys
@Rl-tn1ys 4 жыл бұрын
yes he does a lot
@itzeclipse7449
@itzeclipse7449 3 жыл бұрын
My code works, but the screen is only staying up for a millisecond. What do I do?
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Check the Link that says Need Help? And get back to me.
@ssayorr
@ssayorr 3 жыл бұрын
check if you wrote wn.mainloop() if you did then make a new line and just keep there it somehow fixed for me
@Hanzoxloww
@Hanzoxloww 3 жыл бұрын
@@ssayorr do turtle.done() at the end
@ALLINONETV1
@ALLINONETV1 3 жыл бұрын
@@Hanzoxloww thanks
@Hanzoxloww
@Hanzoxloww 3 жыл бұрын
@@ALLINONETV1 np
@tripplekidhacker
@tripplekidhacker 6 жыл бұрын
i wanted to create a snake for my project but make it fun and interesting, could we add like graphics. custom tiled map or something?
@colwarsstudiobrickfilmandm8580
@colwarsstudiobrickfilmandm8580 4 жыл бұрын
Dude you should write a book on turtle module it would be so helpful i bet you could make some good money.... coding books most of the time are like 30 bucks (united states dollars)
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
I'm definitely thinking about it!
@iknees6056
@iknees6056 4 жыл бұрын
Hello, i copied and pasted the code from github, but when i put it in pycharm, but when i play it, whenever i click a directional key, the snake teleports directly on the wall and you loose
@owenbrowne9288
@owenbrowne9288 4 жыл бұрын
Oooooooooooooooooooooooooooooooooof
@aryanpatel8476
@aryanpatel8476 4 жыл бұрын
I got a little error on my end. I followed the code EXACTLY and even was able to launch. My keys don't work and when I was trying to figure out why I see this: Traceback (most recent call last): File "/Users/my_username/Documents/Python Programs/my_folder/snake.py", line 76, in
@aryanpatel8476
@aryanpatel8476 4 жыл бұрын
@@TokyoEdTech line of code: wn.update() error code: File "/Users/my_username/Desktop/snakehame.pyw , line 76, in
@aryanpatel8476
@aryanpatel8476 4 жыл бұрын
@@TokyoEdTech and the snake does'nt move when i start up snake
@loganvaldez889
@loganvaldez889 6 жыл бұрын
For some reason I am getting AttributeError: 'TurtleView' Object has no attribute 'mainloop'
@loganvaldez889
@loganvaldez889 6 жыл бұрын
pastebin.com/xTui0tFJ Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/776CBE57-9756-443B-A18B-77E1A17DC5E6/Pythonista3/Documents/snake.py", line 12, in wn.mainloop() AttributeError: 'TurtleView' object has no attribute 'mainloop'
@loganvaldez889
@loganvaldez889 6 жыл бұрын
I'm using an IPad Pro. I think I'll just have to do it on a computer.
@human.earthling
@human.earthling 6 жыл бұрын
try using turtle.mainloop() instead.
@loobersoog
@loobersoog 6 жыл бұрын
Riaz Husain I love you
@theemacsen1518
@theemacsen1518 5 жыл бұрын
paste this instead of wn.mainloop(): turtle.mainloop()
@letsthinkit
@letsthinkit 4 жыл бұрын
Have you made a tutorial for asteroids?, I couldn't find one on your channe;. Thanks for all the content you make! It helps me as a 14 year old learning to code as a hobby.
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars 6 жыл бұрын
Thanks to Reddit, I was wondering what to do after completing Python 3.
@samuelhirn1415
@samuelhirn1415 6 жыл бұрын
So I've been doing the basics of Python for a while now, and I can make text-based games and such. But I was wondering what to make, is using GUI the next step?
@alok7485
@alok7485 6 жыл бұрын
please make more games and also tell about how to increase difficulty level in game, how to make more levels in games and how to generate enemies more in pygame
@jezonfernando1583
@jezonfernando1583 4 жыл бұрын
I am not getting the Screen eventhough I'm working on a lap
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
I’m happy to help, but I need to see the actual code. Please share your code via pastebin.com link so I can download and test it. To learn how, please watch this video and then get back to me: kzbin.info/www/bejne/gmekqImrqpuCabs Keep on codin’!
@mrspice2024
@mrspice2024 4 жыл бұрын
Hi plz help, I want to add sound on my turtle project but it doesnt play the sound its just play the warning win sound(I am using win) so plz can you help
@kurawtw
@kurawtw 4 жыл бұрын
to make the window stay there, you must use turtle.done() instead of the wn.mainloop() if you are using the newest version of pycharm. and the game is not finished, you must follow the 2nd tutorial until you finish all of the tutorials.
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
It will probably depend on your version of Python, but if that works for you and others, great!
@kurawtw
@kurawtw 4 жыл бұрын
@@TokyoEdTech yep! im a kid programmer and this really helped me, thanks @TokyoEdTech!
@oster4083
@oster4083 3 жыл бұрын
hi! is there a way i can detect what the score is, im trying to see when the score reaches certent numbers
@oster4083
@oster4083 3 жыл бұрын
nvm i figured it out i used "if score == (number):"
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
@@oster4083 Glad you figured it out!
@robertmawdsley8418
@robertmawdsley8418 5 жыл бұрын
Hi Christian, Honestly in my first day of knowing anything about Python, this may be a silly question, but what "IDE( i think its called)" are you using in the video, i have python running in CMD and can do the basic Print("Hello World") but i am really struggling to follow the video when using CMD, for example when you create the wn.Mainloop() statement as above it allows you to compile code inbetween that and the wn.tracer(0), I may be so lacking in understanding and knowledge about all this but in CMD it does not allow me to do so, it doesnt even let me edit code, I am forced to backspace all and re-write, and it does not allow me to change where i am typing, I am sure that i am just ignorant of all this but could just use some help, not sure if you could assist, Thanking you in advance, Robert
@robertmawdsley8418
@robertmawdsley8418 5 жыл бұрын
@@TokyoEdTech Thank You very Much Christian, I appreciate the help and time.
@nair38
@nair38 5 жыл бұрын
Hello. I am stuck. I am trying to do the first part of just making the screen but it says that mainloop is not an attribute of Screen(). I am using Python 2 so maybe it doesn't work for Python 2.
@معمغربنا-د4ص
@معمغربنا-د4ص 4 жыл бұрын
thanks but its not work in windows or python 3.8 i coped in past in pycharm but not work
@bikashpandey8637
@bikashpandey8637 3 жыл бұрын
can you teach us how to add pause and quit button in the game
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Try this: kzbin.info/www/bejne/oau3naJ6ppZ5n7M
@budgiesandlizardstheguide410
@budgiesandlizardstheguide410 5 жыл бұрын
Hi - I'm building a small game where what you basically do is click on objects that appear randomly throughout the screen. Do you have a good tutorial for this?
@gimmecookies5405
@gimmecookies5405 4 жыл бұрын
I copied GUITHUB like 2 month ago and when i copy it now, it dosent work
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Don't know what to tell you.
@gimmecookies5405
@gimmecookies5405 4 жыл бұрын
@@TokyoEdTech :)
@gimmecookies5405
@gimmecookies5405 4 жыл бұрын
@@TokyoEdTech that was the answer i was looking for
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
@@gimmecookies5405 Glad to hear it! lol
@kodaea223
@kodaea223 4 жыл бұрын
what kind of terminal are you using how do I get it?
@lqn7260
@lqn7260 4 жыл бұрын
How do you run turtle in Visual Studio Code? I can only seem to get it to run code which isn't using a module.
@ndidiowonibi8327
@ndidiowonibi8327 6 жыл бұрын
Thanks i am using Windows 8.1 And i use Sublime text to right codes
@sirisgoated4173
@sirisgoated4173 4 жыл бұрын
Hey my background only stays for half a second and then disappears, why is that? Here is my code import turtle # Set up the screen wn = turtle.Screen() wn.title("Snake game by Saif Aldaour") wn.bgcolor("green") wn.setup(width=600, height=600) wn.tracer(0)
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
You're missing the rest of the code - keep going.
@rakeshreddy1365
@rakeshreddy1365 4 жыл бұрын
at last instead if wn.mainloop() use turtle.mainloop()
@nope8306
@nope8306 4 жыл бұрын
AttributeError: 'tuple' object has no attribute 'append'
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
There is a link in the description labeled “NEED HELP?” Check that out and get back to me. Keep on codin’!
@makrophoenix3069
@makrophoenix3069 6 жыл бұрын
you are gold sir! glad i find you!
@makrophoenix3069
@makrophoenix3069 6 жыл бұрын
@@TokyoEdTech thanks for your reply, and just something to add, in this sea of python "programmers" on youtube you are the first to explain every line of code you type and every line of code is i would say compatible with all the versions of python(windows, linux, macOS). Just finished programming snake and believe me i could type whole line of code out of memory because you explained it perfectly. Thank you again.
@chloekimball536
@chloekimball536 5 жыл бұрын
I feel the same way. He is absolutely amazing
@karamabumallouh8550
@karamabumallouh8550 4 жыл бұрын
i wrote these code but the screen keeps closing after I run the code(it opens only for 1 sec the closes)how could I fix that?
@Zousky
@Zousky 5 жыл бұрын
How do I upgrade to python 3 on mac? I downloaded python 3 but whenever I run turtle module, it goes back to 2.7
@jackhammerdevelopment3159
@jackhammerdevelopment3159 2 жыл бұрын
Hey there it seems someone has been plagiarising all your work and they uploaded a video claiming the code to be theirs
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
Heya - yep, it happens pretty regularly. I'm totally OK with anyone using any of my code for any purpose, but I do appreciate a link back in the description. Everything I do is Creative Commons Attribution Share-Alike. Some people do ask - in particular I appreciate people who translate my videos, or use my code in their native language. Could you share a link to the code/content you found? Usually, when I ask, I get a positive response to my request for them to include a link. Thanks!
@jackhammerdevelopment3159
@jackhammerdevelopment3159 2 жыл бұрын
@@TokyoEdTech sure kzbin.info/www/bejne/kHe3c3qga9uUaJI is the link i hope the guy does the right thing and credit you but I don't have high hopes cause he literally pretended to wrote the whole code by himself all along but good luck.
@roxycamilo
@roxycamilo 4 жыл бұрын
Hi, christian my son is 10 years old and he using python (spider anaconda) for his project at school, he wants to show in a you tube video the codding and the graphic turtle both at the same time (like you doing here), the problems is the recording only shows the codding part or the graphic turtle, not both at the same time, is he missing something? or whats the right way to show both at the same time thank you
@roxycamilo
@roxycamilo 4 жыл бұрын
thank you , !! we will try that, my son watch your videos all the time, he start liking python because of your videos , thank you for all your work !!!
@g.t.1012
@g.t.1012 4 жыл бұрын
thanks for you time i did everything and works perfect, i like it, i add -turtle.register_shape("food.gif") -turtle.register_shape("slangenlichaam.gif") -turtle.register_shape("slanghoofd.gif") to change the snake and food and its looks cool Its so fun
@erdiksha8104
@erdiksha8104 4 жыл бұрын
Sir i was trying to add sound..durring collision...and i did so...but no sound is coming...may os is mac... os.system("afplay Arrow flyby right to left .mp3") I hv attched in same file also....but no sound is coming...plzzz help me sir
@erdiksha8104
@erdiksha8104 4 жыл бұрын
@@TokyoEdTech ok sir..👍😊
@erdiksha8104
@erdiksha8104 4 жыл бұрын
Sir i renamed the file...and as per u said...but still no sound is coming
@erdiksha8104
@erdiksha8104 4 жыл бұрын
@@TokyoEdTech I changed the name.. os.system("afplay hiss.mp3&") ...
@erdiksha8104
@erdiksha8104 4 жыл бұрын
@@TokyoEdTech Wn.update() t._update_data() Self.screen._incrementuduc() Raise terminator turtle.Terminator
@erdiksha8104
@erdiksha8104 4 жыл бұрын
@@TokyoEdTech Wn.update() t._update_data() Self.screen._incrementudc() raise Terminator turtle.Terminator .....this is showing in terminal win dow
@jalavl2972
@jalavl2972 6 жыл бұрын
When i do the run python file in terminal thing it just says "This is not an active python file" How should I make this a python file? Would be really appreciated if you could help!
@jalavl2972
@jalavl2972 6 жыл бұрын
@@TokyoEdTech OMG, it's the man himself! So glad I can talk to you, anyways I have not tried saving my files like that, lemme try and thank you very much!
@yesveryprofesionalnameyes6055
@yesveryprofesionalnameyes6055 5 жыл бұрын
did you download the turtle module?
@theemacsen1518
@theemacsen1518 5 жыл бұрын
python (FILENAME).py
@mmoonnaa
@mmoonnaa 3 жыл бұрын
line 8 NameError: name 'screen' is not defined What can I doooo ?
@anshul1047
@anshul1047 3 жыл бұрын
the s of the screen should be capital. it should be s = turtle.Turtle()
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Thanks for helping out!
@Plasticarmylabs
@Plasticarmylabs 10 ай бұрын
wn.bgcolor("green") doesnt work it says it's not defined
@TokyoEdTech
@TokyoEdTech 10 ай бұрын
Can you share all the code and the error message?
@Plasticarmylabs
@Plasticarmylabs 10 ай бұрын
@@TokyoEdTech the error message: Traceback (most recent call last): File "C:/Users/Win10R22h2/OneDrive/Desktop/Snake.py", line 3, in import turtle File "C:\Users/Win10R22h2/OneDrive/Desktop\turtle.py", line 3, in bgcolor("black") NameError: name 'bgcolor' is not defined the code: #simple Snake Game import turtle #settingu up the screen wn = turtle.Screen() wn.title("Snake") wn.bgcolor("green") wn.setup(width=600, height=600) wn.tracer wn.mainloop()
@TokyoEdTech
@TokyoEdTech 10 ай бұрын
@@Plasticarmylabs It looks like you have a file called turtle.py on your desktop. Delete it.
@Plasticarmylabs
@Plasticarmylabs 10 ай бұрын
@@TokyoEdTech thanks so much that helped
@TokyoEdTech
@TokyoEdTech 10 ай бұрын
@@Plasticarmylabs Sure thing - keep on codin'!
@arbazchaudhry9721
@arbazchaudhry9721 5 жыл бұрын
when i write main loop it says underfined
@saunaknandi1814
@saunaknandi1814 5 жыл бұрын
bro send the code first how can anyone will rectify ur mistake
@safabashe170
@safabashe170 5 жыл бұрын
i downloaded your code in description and run it in my computer but the snake does not move at all ... i have python 3.7 , pygame and i'm using pycharm ... what should i do ?
@walsand
@walsand 5 жыл бұрын
why is there no audio?, other videos on youtube have sound but for some reason not yours?
@walsand
@walsand 5 жыл бұрын
@@TokyoEdTech yep, restarted the whole computer, audio works on mobile though. so ill probably have it run on the phone while im doing this total kek
@juancruzarzani4502
@juancruzarzani4502 4 жыл бұрын
Hi there , i have an issue here . Im just learning to code , im using the lastest build of python and i cant get to import turtle . The word import wont turn pink or show no signs of working (it is grey text ) and the program tells me that " import turtle " is an unused import command and recomends me to delete it . Pycharm gives me the option of using " __import__ " but when i use "__import__" turtle is not a option :/
@juancruzarzani4502
@juancruzarzani4502 4 жыл бұрын
@@TokyoEdTech thanks a lot man , tomorrow ill continue whit the project then!
@divyakumar5161
@divyakumar5161 4 жыл бұрын
Everything is excellent But in which app I will program this
@divyakumar5161
@divyakumar5161 4 жыл бұрын
@@TokyoEdTech ohh thanks bro
@pranavguptaa
@pranavguptaa 4 жыл бұрын
I just found your videos,but i am not familiar with GUI in python,can you please suggest what topics should i learn for this playlist?
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
If you already know basic Python, give this a shot - it will explain what you need to know.
@pranavguptaa
@pranavguptaa 4 жыл бұрын
@@TokyoEdTech Thanks a lot man🔥🔥
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
@@pranavguptaa You're welcome.
@crake9510
@crake9510 4 жыл бұрын
is this on sublime text plz answer
@makingzebraop
@makingzebraop 5 жыл бұрын
Which software u r using to code python?
@makingzebraop
@makingzebraop 5 жыл бұрын
Pls tell fats
@Guyfamily1737
@Guyfamily1737 4 жыл бұрын
Can u tell me what ide you are using? Im using spider and when ever i try to run the code it says something like srry cant display game scrren
@louisapankow77
@louisapankow77 3 жыл бұрын
Hey TokyoEdtech, I dont know why, but no window is shown :( # Simple Snake Game in Python import turtle # Set up Screen wn = turtle.Screen() wn.title("Snake by Louisa") wn.bgcolor("green") wn.setup(600, 600) wn.tracer(0) wn.mainloop()
@louisapankow77
@louisapankow77 3 жыл бұрын
Python is only showing me this: /usr/bin/python3.8 /home/student_in/Game_snake_lp/main.py Traceback (most recent call last): File "/home/student_in/Game_snake_lp/main.py", line 4, in import turtle File "/usr/lib/python3.8/turtle.py", line 107, in import tkinter as TK ModuleNotFoundError: No module named 'tkinter' Process finished with exit code 1
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
@@louisapankow77 Are you on Linux? If so, you'll need to install tkinter separately. Try Googling instructions for your operating system..
@PreludeSon
@PreludeSon 5 жыл бұрын
very nice! By the way, how do I keep the game screen on? it closes on the first tutorial.
@tomthebigman7481
@tomthebigman7481 4 жыл бұрын
Stiofán Davies Thanks, was stuck.
@johankaruyan5536
@johankaruyan5536 5 жыл бұрын
Wait Why not Pygame ? isnt it easier there ?
@nuranaaliyeva6648
@nuranaaliyeva6648 4 жыл бұрын
TokyoEdTech , are you writing code in Pycharm ?
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Nope - I’ve made a video about this exact topic. Enjoy! kzbin.info/www/bejne/apOvXp95hZenm8U
@mohammedshaddy3741
@mohammedshaddy3741 4 жыл бұрын
plz help, I am using eclipse IDE with pydev plug-in , it is not showing the green box at all
@ismailjabarti9453
@ismailjabarti9453 6 жыл бұрын
What application are you using to write the code on?
@Player-fx3vt
@Player-fx3vt 4 жыл бұрын
Hello, is turtle a default library or i need to download it ? My editior is not knowing what turtle is also shoud i use visualt studion or visual studio code , i mean does it matter? Thanks for the help
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
It should come with Python. Here's a video about IDEs I use: kzbin.info/www/bejne/apOvXp95hZenm8U
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Thanks - good advice!
@thebest-fo1yr
@thebest-fo1yr 2 жыл бұрын
i have a problem, my python game window opens for a few seconds and closes immediately, what can i do?
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
Share your code so I can't take a look.
@iggelopiggelo5613
@iggelopiggelo5613 6 жыл бұрын
I have Windows 10, i just downloaded python 3.7.2 but mine does not look like that. Mines just a black screen and it just lets me write. I don’t have numbers on the side and all of that. Help me please
@iggelopiggelo5613
@iggelopiggelo5613 6 жыл бұрын
Christian Thompson Thank you so much! Really thankful for Your response. Now i Can Finally code
@mostaphamansoor3969
@mostaphamansoor3969 4 жыл бұрын
the green screen with the snake opens but how will i move the snake,the directional keys dont work
@g.t.1012
@g.t.1012 4 жыл бұрын
watch hes next clips and he will tell everything its works
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
You got it!
@ronaldmetube
@ronaldmetube 5 жыл бұрын
im having this error Traceback (most recent call last): File "C:\Users\mrsar\Desktop\RiyannRR\Codes\chess.py", line 2, in wn = turtle.Screen() AttributeError: 'module' object has no attribute 'Screen'
@nathangonzalez739
@nathangonzalez739 4 жыл бұрын
im running the code on pycharm bc for some reason i cant run it on visual studio. and when i run the same code on pycharm the screen dosnt change color or size but it pops up. is there a difference in code in these different software ?
@nathangonzalez739
@nathangonzalez739 4 жыл бұрын
Christian Thompson thanks bro 👍🏽 just started coding yesterday started watching your vids and some other ones and I’m already getting the hang of it thanks 🙏🏽
@nathangonzalez739
@nathangonzalez739 4 жыл бұрын
@@TokyoEdTech ok i setup visual studio code and i finally got the green square to pop up, it turned out that it wouldn't pop up on VS bc i spelled width and height wrong lol. im super happy
@nathangonzalez739
@nathangonzalez739 4 жыл бұрын
Christian Thompson ok got u 👌🏽
@liltxera253
@liltxera253 6 жыл бұрын
hi there, whats the IDLE you are using to code??
@artsketcherz2893
@artsketcherz2893 4 жыл бұрын
i am not able to find where has the code been run.i am using visual studio code itself.but cant find the output. please give me a solution.......
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Sorry, I don't know what to tell you - try finding a forum for Visual Studio Code problems.
@artsketcherz2893
@artsketcherz2893 4 жыл бұрын
@@TokyoEdTech ok thx
@galozer3179
@galozer3179 4 жыл бұрын
i cant run this exact code Traceback (most recent call last): File "C:/Networks/work/test.py", line 1, in import turtle File "C:\Networks\Python3.8\lib\turtle.py", line 107, in import tkinter as TK ModuleNotFoundError: No module named 'tkinter' thanks!
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
You may need to install tkinter separately - depends what OS you are on.
Python Game Programming Tutorial: Snake Game Part 2
14:19
TokyoEdtech
Рет қаралды 161 М.
2 YEARS of PYTHON Game Development in 5 Minutes!
4:54
Coding With Russ
Рет қаралды 993 М.
She wanted to set me up #shorts by Tsuriki Show
0:56
Tsuriki Show
Рет қаралды 8 МЛН
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
«Жат бауыр» телехикаясы І 30 - бөлім | Соңғы бөлім
52:59
Qazaqstan TV / Қазақстан Ұлттық Арнасы
Рет қаралды 340 М.
Python Game Programming: Simple Cookie Clicker
11:44
TokyoEdtech
Рет қаралды 126 М.
Python Game Tutorial: Pong
44:03
freeCodeCamp.org
Рет қаралды 519 М.
Creating a Snake game with Python in under 5 minutes
5:40
Engineer Man
Рет қаралды 3,1 МЛН
| How to create a Snake game using python | | AK python |
8:31
AK Python
Рет қаралды 1,1 МЛН
Making a Game in Python with No Experience
5:57
Goodgis
Рет қаралды 1,8 МЛН
15 Python Projects in Under 15 Minutes (Code Included)
12:37
Tech With Tim
Рет қаралды 2 МЛН
How to Make A Simple Game in Python (For Beginners)
15:47
Tech With Tim
Рет қаралды 525 М.
Top 18 Most Useful Python Modules
10:50
Tech With Tim
Рет қаралды 935 М.
Code Snake Game in Python
35:34
Kenny Yip Coding
Рет қаралды 40 М.
She wanted to set me up #shorts by Tsuriki Show
0:56
Tsuriki Show
Рет қаралды 8 МЛН