It's happening the same but learning programming overall, directly with web progrramming, it's kinda odd for me because I love and I'm studying graphic design, 3D design and motion graphics (and drawing but it's a hobby) and getting interested in web programming is striking for me now thanks by his videos 0:
There's a bug with the spawn of the apples, as they are random in all screen they can spawn inside the snake's body. It's not that difficult to change but be careful with that
Very encouraging ... I am not in gaming but I have several problems to be solved and if after learning python i can solve a problem in an hours coding effort then I have saved myself a ton of time. Thanks a lot. And yes, No Talking is phenomenal.
Incredible good friend I almost have no idea of the code you wrote because I am just beginning to learn to program some friend advice. By the way I loved your video, keep it up
The video is interesting and I loved the programming you did, but just as a recommendation, you should change the color of the pixel of the head of the snake to know which direction it will go.
I almost relaxed and then in the first 76 seconds: 0. # Because programmers count from 0 She resizes her window aggressively 1. She makes a lotta typos 2. She messed up equals on line 8 3. She puts a comment in self-explanatory variables 4. She uses brackets in if statement on line 13 5. Even if you have brackets in if statement, at least put a space! 6. She makes a whole lot of empty line, so much empty space that even your mom fits there # couldn't miss the opportunity 7. (probably) If the variable can't be negative and you check it to be bigger than 0, use != or not keyword. If the variable can be negative, ignore this. 7 mistakes on 13 lines! I mean, that's just mostly syntactic sugar, but umm... BrainError: brain exploded of such bad code
This is the code I used to program snake in python. I changed the colors from green and red to blue and yellow to give it the python colors. You can change the speed, screen size, how many tails to start with, and the colors. All that will be located at the top of the code, so feel free to modify the code however you like. from tkinter import * import random GAME_WIDTH = 1000 GAME_HEIGHT = 700 SPEED = 80 SPACE_SIZE = 50 BODY_PARTS = 3 SNAKE_COLOR = "#0000FF" FOOD_COLOR = "#FFFF00" BACKGROUND_COLOR = "#000000" class Snake: def __init__(self): self.body_size = BODY_PARTS self.coordinates = [] self.squares = [] for i in range(0, BODY_PARTS): self.coordinates.append([0,0]) for x, y in self.coordinates: square = canvas.create_rectangle(x, y, x + SPACE_SIZE, y + SPACE_SIZE, fill=SNAKE_COLOR, tag="snake") self.squares.append(square) class Food: def __init__(self): x = random.randint(0, (GAME_WIDTH / SPACE_SIZE)-1) * SPACE_SIZE y = random.randint(0, (GAME_HEIGHT / SPACE_SIZE) - 1) * SPACE_SIZE self.coordinates = [x, y] canvas.create_oval(x, y, x + SPACE_SIZE, y + SPACE_SIZE, fill=FOOD_COLOR, tag="food") def next_turn(snake, food): x, y = snake.coordinates[0] if direction == "up": y -= SPACE_SIZE elif direction == "down": y += SPACE_SIZE elif direction == "left": x -= SPACE_SIZE elif direction == "right": x += SPACE_SIZE snake.coordinates.insert(0, (x, y)) square = canvas.create_rectangle(x, y, x + SPACE_SIZE, y + SPACE_SIZE, fill=SNAKE_COLOR) snake.squares.insert(0, square) if x == food.coordinates[0] and y == food.coordinates[1]: global score score += 1 label.config(text="Score:{}".format(score)) canvas.delete("food") food = Food() else: del snake.coordinates[-1] canvas.delete(snake.squares[-1]) del snake.squares[-1] if check_collisions(snake): game_over() else: window.after(SPEED, next_turn, snake, food) def change_direction(new_direction): global direction if new_direction == 'left': if direction != 'right': direction = new_direction elif new_direction == 'right': if direction != 'left': direction = new_direction elif new_direction == 'up': if direction != 'down': direction = new_direction elif new_direction == 'down': if direction != 'up': direction = new_direction def check_collisions(snake): x, y = snake.coordinates[0] if x < 0 or x >= GAME_WIDTH: return True elif y < 0 or y >= GAME_HEIGHT: return True for body_part in snake.coordinates[1:]: if x == body_part[0] and y == body_part[1]: print("Game Over") return True return False def game_over(): canvas.delete(ALL) canvas.create_text(canvas.winfo_width()/2, canvas.winfo_height()/2,font=('consolas',50), text="GAME OVER", fill="red", tag="gameover!") window = Tk() window.title("Snake Game") window.resizable(False, False) score = 0 direction = "down" label = Label(window, text="Score:{}".format(score), font=('consolas', 40)) label.pack() canvas = Canvas(window, bg=BACKGROUND_COLOR, height=GAME_HEIGHT, width=GAME_WIDTH) canvas.pack() window.update() window_width = window.winfo_width() window_height = window.winfo_height() screen_width = window.winfo_screenwidth() screen_height = window.winfo_screenheight() x = int ((screen_width/2) - (window_width/2)) y = int ((screen_height/10) - (window_height/10)) window.geometry(f"{window_width}x{window_height}+{x}+{y}") window.bind('', lambda event: change_direction('left')) window.bind('', lambda event: change_direction('right')) window.bind('', lambda event: change_direction('up')) window.bind('', lambda event: change_direction('down')) snake = Snake() food = Food() next_turn(snake, food) window.mainloop()
i dont get, why you never read doc for pygame and so on pygame.display.set_mode((1920, 1080)) # Initialize a window or screen for display set_mode(size=(0, 0), flags=0, depth=0, display=0, vsync=0)
Ah yes the art of copying from a second monitor Also the framework you are using, pygame, a wrapper for SDL2 written in C Allows you to use colors within strings You dont need to define constant global variables at the top, and can directly use "blue" or "black" wherever you want.
It sounds like a mechanical keyboard you can find on Amazon, but it is WAY too small. Not sure what he thinks he's accomplishing by using something that isn't ergonomic.
As someone who has just started learning Python, I'm just like "How the hell does he know all of this from memory" I feel like I will never be capable of doing this on my own... Did anyone else feel the same at the beginning?
I feel the same but I think this comes from experience. He/she has probably done this a million times, it's almost like a second nature to them. Just like driving a car or a bike.
This makes me motivated and excited to learn python for full stack development
This video is great. All this code makes me want to learn more. Keep up the good work!
It's happening the same but learning programming overall, directly with web progrramming, it's kinda odd for me because I love and I'm studying graphic design, 3D design and motion graphics (and drawing but it's a hobby) and getting interested in web programming is striking for me now thanks by his videos 0:
o
There's a bug with the spawn of the apples, as they are random in all screen they can spawn inside the snake's body. It's not that difficult to change but be careful with that
не баг, а фича
Внатури
У тебя должно быть много друзей
What on earth are these guys talking about lol
@@wingersonly about ur mom
Very encouraging ... I am not in gaming but I have several problems to be solved and if after learning python i can solve a problem in an hours coding effort then I have saved myself a ton of time. Thanks a lot. And yes, No Talking is phenomenal.
I love this clicks of keyboard. This is enjoyable.
Glad to hear that 🎉🎉🎉
@@ServetGulnaroglu :3
@@ServetGulnaroglu is that K2 keyboard?
Incredible good friend I almost have no idea of the code you wrote because I am just beginning to learn to program some friend advice. By the way I loved your video, keep it up
Thanks for the support! I'm glad to hear that
hey are you good at programming now its 3 years im just curious because im starting too
This is a really interesting and original content.
Нифига не оригинальный контент
Шутька!
I like ASMR, i like games AND i like proramming.
This video is the best combo.
The video is interesting and I loved the programming you did, but just as a recommendation, you should change the color of the pixel of the head of the snake to know which direction it will go.
Keyboard sounds satisfying bro👍
1:01 i aint a programmer but i can tell that this pygame is british
Can u please make an asmr on how to setup visual code? (The way u have it setup looks very nice!)
follow code with harry...
ruclips.net/video/ks6wF_ooYqo/видео.html
Go watch gibi
Better layout than before 👍🏿
Thank you for the feedback
non coders: wow this is very inspiring. coders: i give up
DAMN THAT FINGERSS
anyone today who doesn’t know what to do, start recording how to make snake game 😂😂😂
yeah 🤣
Here
@@Yahavoni death?
@@Yahavoni I translated it, it literally says "death"
@@Yahavoni yeah I know, you meant "smart", but somewhat reason youtube decided you translate is to "death" 🌚
5:16 line 40, why are you dividing the frame size with square size and multiplying it again? It will just return the frame size.
double / isn't dividng, its called floored division where it for example:
5//2=3
so you multiply this back up and you get a rounded frame size
@@KaylonR 5 // 2 will be 2
I almost relaxed and then in the first 76 seconds:
0. # Because programmers count from 0
She resizes her window aggressively
1. She makes a lotta typos
2. She messed up equals on line 8
3. She puts a comment in self-explanatory variables
4. She uses brackets in if statement on line 13
5. Even if you have brackets in if statement, at least put a space!
6. She makes a whole lot of empty line, so much empty space that even your mom fits there
# couldn't miss the opportunity
7. (probably) If the variable can't be negative and you check it to be bigger than 0, use != or not keyword. If the variable can be negative, ignore this.
7 mistakes on 13 lines! I mean, that's just mostly syntactic sugar, but umm... BrainError: brain exploded of such bad code
Your brain gonna explode, if you will see my java code. This is using in tortures.
that speed is like lighting :0
Ka-chow!
@@ServetGulnaroglu I am programmer too !
@@ServetGulnaroglu and Bro the job you did was amazing I used you Asmar like 10 times now !
best way to train! followed step by step :)
Question. How do you move these screens? What shortcut is that? 0:00
In Windows is alt + tab
That the loudest keyboard I ever Heard
Amazing work dude, how long do You learn coding?
Probably a while this looks pretty hard
@@IoanaMuthi this is ez
@@IoanaMuthi not that hard but not that easy
@@baki82737 lol
اقسم بالله صوت الكيبورد طرب ولا احسن عازف ارجوا إن تفيد البشرية ...
keep up with this good work! and try to make more python projects for begginers and avanced programmers
This pleases my ears
I am waiting for you to post this code to your github
Sorry for the delay. The link is in the description now.
@@ServetGulnaroglu thank you my bro
He just coded the game without any testing!!! End he just tested the gane at end 😱😱😅😅
Why the heck are u so good at goddamn snake?
nice work dude,what's the name of that keyboard??
Steve
You are very amazing programmer
This is music to my ears
Very good job . You must doing videos every day
This is the code I used to program snake in python. I changed the colors from green and red to blue and yellow to give it the python colors. You can change the speed, screen size, how many tails to start with, and the colors. All that will be located at the top of the code, so feel free to modify the code however you like.
from tkinter import *
import random
GAME_WIDTH = 1000
GAME_HEIGHT = 700
SPEED = 80
SPACE_SIZE = 50
BODY_PARTS = 3
SNAKE_COLOR = "#0000FF"
FOOD_COLOR = "#FFFF00"
BACKGROUND_COLOR = "#000000"
class Snake:
def __init__(self):
self.body_size = BODY_PARTS
self.coordinates = []
self.squares = []
for i in range(0, BODY_PARTS):
self.coordinates.append([0,0])
for x, y in self.coordinates:
square = canvas.create_rectangle(x, y, x + SPACE_SIZE, y + SPACE_SIZE, fill=SNAKE_COLOR, tag="snake")
self.squares.append(square)
class Food:
def __init__(self):
x = random.randint(0, (GAME_WIDTH / SPACE_SIZE)-1) * SPACE_SIZE
y = random.randint(0, (GAME_HEIGHT / SPACE_SIZE) - 1) * SPACE_SIZE
self.coordinates = [x, y]
canvas.create_oval(x, y, x + SPACE_SIZE, y + SPACE_SIZE, fill=FOOD_COLOR, tag="food")
def next_turn(snake, food):
x, y = snake.coordinates[0]
if direction == "up":
y -= SPACE_SIZE
elif direction == "down":
y += SPACE_SIZE
elif direction == "left":
x -= SPACE_SIZE
elif direction == "right":
x += SPACE_SIZE
snake.coordinates.insert(0, (x, y))
square = canvas.create_rectangle(x, y, x + SPACE_SIZE, y + SPACE_SIZE, fill=SNAKE_COLOR)
snake.squares.insert(0, square)
if x == food.coordinates[0] and y == food.coordinates[1]:
global score
score += 1
label.config(text="Score:{}".format(score))
canvas.delete("food")
food = Food()
else:
del snake.coordinates[-1]
canvas.delete(snake.squares[-1])
del snake.squares[-1]
if check_collisions(snake):
game_over()
else:
window.after(SPEED, next_turn, snake, food)
def change_direction(new_direction):
global direction
if new_direction == 'left':
if direction != 'right':
direction = new_direction
elif new_direction == 'right':
if direction != 'left':
direction = new_direction
elif new_direction == 'up':
if direction != 'down':
direction = new_direction
elif new_direction == 'down':
if direction != 'up':
direction = new_direction
def check_collisions(snake):
x, y = snake.coordinates[0]
if x < 0 or x >= GAME_WIDTH:
return True
elif y < 0 or y >= GAME_HEIGHT:
return True
for body_part in snake.coordinates[1:]:
if x == body_part[0] and y == body_part[1]:
print("Game Over")
return True
return False
def game_over():
canvas.delete(ALL)
canvas.create_text(canvas.winfo_width()/2, canvas.winfo_height()/2,font=('consolas',50), text="GAME OVER", fill="red", tag="gameover!")
window = Tk()
window.title("Snake Game")
window.resizable(False, False)
score = 0
direction = "down"
label = Label(window, text="Score:{}".format(score), font=('consolas', 40))
label.pack()
canvas = Canvas(window, bg=BACKGROUND_COLOR, height=GAME_HEIGHT, width=GAME_WIDTH)
canvas.pack()
window.update()
window_width = window.winfo_width()
window_height = window.winfo_height()
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
x = int ((screen_width/2) - (window_width/2))
y = int ((screen_height/10) - (window_height/10))
window.geometry(f"{window_width}x{window_height}+{x}+{y}")
window.bind('', lambda event: change_direction('left'))
window.bind('', lambda event: change_direction('right'))
window.bind('', lambda event: change_direction('up'))
window.bind('', lambda event: change_direction('down'))
snake = Snake()
food = Food()
next_turn(snake, food)
window.mainloop()
please make video: "How I setup vim/nvim". Tks
This is my new sleeping music
Im Motivated by your coding so i try to code like this.But it shows 50 error, 11 warning,4 weak warning..lol😂😂😂
game_window = pygame.display.set_mode(frame_size_x, frame_size_y). I am getting an error that size must be two numbers... Any help
Same , did you find answer ?
i dont get, why you never read doc for pygame and so on
pygame.display.set_mode((1920, 1080))
# Initialize a window or screen for display
set_mode(size=(0, 0), flags=0, depth=0, display=0, vsync=0)
As a game dev, I can confirm that game development is for chads
Ah yes the art of copying from a second monitor
Also the framework you are using, pygame, a wrapper for SDL2 written in C
Allows you to use colors within strings
You dont need to define constant global variables at the top, and can directly use "blue" or "black" wherever you want.
This is why I wanted to studies ICT In my senior high.
Your Device?
abi çok güzel yazıyorsun ama ben bunu yazdım harfi harfine bana hata veriyor diyorki pygame olmaz pygame'i yanlış yazıyor ne için böyle oluyor abi?
Did you install pygame from the command prompt!? If not you need to and if you are asking how just go to command prompt and type pip install pygame
Программисты: а ты знаешь как меня возбудить ;)
Hey at 4:50 how can I get that star !?
We need more video on python plzzzzz
really loved the first bug lol
Could you do a video where you explain why you are doing what your doing when coding
Because he likes games 💁♀️
What keyboard is that?
Skylong SK64 Red Switches
Past out during watching (got sleepy)
Time for me to buy both camera 📸 & mic
after a long type got something I want
What is that OS?
P.D: Great video. Like and sub :)
Thanks mate 🎉🎉🎉🚀🙏 macOs monterey
It's great but I'm still finding difficult to run ..I'm still beginner..what did you type it's abit fast so I couldn't get it....
You should try to make this with java !! Loved your video
Thank you a lot 🚀💥🚀💥💥
Is java complicated?
@@theabominator2152 no , java basic is really easy but difficult to master
@@amiteshwarsingh6099 thanks, appreciate your feedback
@@amiteshwarsingh6099 hmm I know c # and I am a small game dev using unity
9:15 can someone explain this part? Im little confused
gotta lube those spacebar stabs
Can you tell your vs code font your font is very nice
just a quick question. why are we making a init_vars a function instead of __init__ and just passing vars? Thanks in advance.
Great video! Just had a quick question how did you and are learning code?
I'm still learning it and I'm self learning
spek engrish num nuts
@@user-nf3vd6kv7ewhat- WHAT THE F-
I’m a noob :< and I am wondering what are those things that you import in the beginning ?
Are you using linux or mac
Write a dinosaur running game on Javascript or on Python. I'd like to watch a video about a dinosaur :)
keyboard sound cool
It sounds like a mechanical keyboard you can find on Amazon, but it is WAY too small. Not sure what he thinks he's accomplishing by using something that isn't ergonomic.
have u tried brown key switch
what brand are this switchs gateron or cherry mx
if u have tried brown which do u like red or brown
What extensions on vs code do you use for this project?
.py
Does anyone know how to change the square defined as a food into any image I want?
smooth sounds
what extensions do you use? btw nice video
Visual Studio Code😊
in line 21 its showing in mine that size should be number .....what should i do ?
Hi, what switches do you use?
interesting pygame python game though
Could you extend the code? like adding more features and superpowers
Making python games with python
next time tetris pleaseee!!
would be a bit challenging but on the way !!!!!
can you tell me that your extension in vscode,i want to know to setup my vscode,please help me,thanks you very much
I need that pygame library where can i find it?
Where did you buy the keyboard from?
have u tried brown key switchs
what are your vscode settings, like font, font size, etc.
seems like a nice setup
Mf fr these are the defaults💀
@@HTWwpzIuqaObMt lmao
Hello! I rlly like ur videos, can u make a chess nrxt time plz)
I copied the same code and my key left is not working
so cool,i like this video
What extension do you do???
i want to see a cheese game in next video..... please😀
what is the mouse you are using?
Plot twist: he put space after the first y
what to do if a snake sometimes passes through an apple?
For some reason, when I launch vscode on my Mac m1, later it is burning hot. Anyone else got the same problem? If so any solutions?
I dunno why, but many programmer use keychron keyboard, does it have something special?
what is your vs theme?
, line 1, in
import pygame, sys, time, random
ModuleNotFoundError: No module named 'pygame'
any solution ?
Try to install ‘pygame’ libraries with a virtual environment, search on RUclips bro
@@francescoabrate4454 I had already solved it by searching in Google XD, thanks anyway
@@NChindas How??? Help me, please, I can't solve this problem.
@@NChindas The library is pygame installed, I checked through pip list
As someone who has just started learning Python, I'm just like "How the hell does he know all of this from memory" I feel like I will never be capable of doing this on my own...
Did anyone else feel the same at the beginning?
Yes
@@Gamer-XO What about know? You feel the same xD
Yes 😂 XD
@@Pedro19893 mememe
I feel the same but I think this comes from experience. He/she has probably done this a million times, it's almost like a second nature to them.
Just like driving a car or a bike.
"TypeError: size must be two numbers"
try with:
game_window = pygame.display.set_mode(size=(frame_size_x,frame_size_y))
How did you play the game after coding it
What is your keyboard
This video is great.
Thank you for motivating me to Giveup 🙂
Ayo time to copy some codes hehe
My terminal said , line 21, in
TypeError: size must be two number
How to fix it?
replace line 21 with this " game_window = pygame.display.set_mode(size=(frame_size_x, frame_size_y)) "
@@jonanthonii hello i did this and i still have that error can you help me please ?