
Making Snake Move On Arrow Key Press – Python Game Development Using Pygame In Hindi #14
CodeWithHarry
Views: 23835
Like: 1848
Source Code –
This video is a part of this Pygame Game Development Playlist –
►Click here to subscribe –
This video is a part of this Pygame Game Development Playlist –
►Click here to subscribe –
Best Hindi Videos For Learning Programming:
►Learn Python In One Video –
►Learn JavaScript in One Video –
►Learn PHP In One Video –
►Machine Learning Using Python –
►Creating & Hosting A Website (Tech Blog) Using Python –
►Advanced Python Tutorials –
►Object Oriented Programming In Python –
►Python Data Science and Big Data Tutorials –
Follow Me On Social Media
►Website (created using Flask) –
►Facebook –
►Instagram –
►Personal Facebook A/c –
Twitter –
23.07.2022
Mast ha bhai
bhai majjja aaa gya thanks for this asm content
Loving it Harry Bhai
Thanku
😭😭😭😭
I tried learning c by book for one year and now I am makings by watching your channel only in just some days. You are a blessing for this world.
I am having fun while making this game……
Mast
bhot mast
2:53 bricks break
It is giving me vibes
Sir game toh badi acchi ban rahi ha❤❤❤❤
awesome vai
hwavyyyyy
I am in class 7th😇
Mera snake up down move nhi kr raha harry sir kitni bar comment kr diya ab toh btado
Most amazing tutorial
Awesome bhai 💕
Sur problem solved of arrow movement
I m 12 years old and I m learning cooding to make bright future
Love you sir ❤️
Yes Harry sir 💚.bachpan ki bhaavnayien chalk gyii.
bai ga,e bana kar maja aa gaya hai
Nice
Great
Multiple comments
very interesting
thanks for this series thanks*1000000000000000000000 times 🙂
Bahut Achha Feel kar Raha hon
I have a question
I press any particular arrow key again and and again
It's velocity increase with each press
How I make velocity constant for entire game.
maza aagya thanks sir you are best
Thank you for teaching us!🤓
Owo
Thanks
Seriously it's the best feeling to play ur own game
bhai sachme itna amza aarahe kya batau thank you so much
🙂🙂🙂
One question: Only when I hover my mouse over the window only then the snake moves. Other wise it stops, what is the reason?
you are my idol bro in case of python.
# mja to tvv aaata hai jbbb first time ya phle kuch time me error aaye aur try krne ke baaad errror shh ho jaye aur programme run krne lge…………………mja aaaa gya snake kon run kra ke
# date 09 july 2022
#-
———–giving right velocity to snake in all direction——————-import pygame
print (pygame.init())
# colours
white=(255,255,255)
red=(255,0,0)
black=(0,0,0)
# creating windows
raghavgame_window=pygame.display.set_mode((600,600))
pygame.display.set_caption("game_by_raghav")
# game specific variable
exit_game=False
over_game=False
snake_x=20
snake_y=20
snake_size=20
fps=30 # frame per second
velocity_x=0
velocity_y=0
clock = pygame.time.Clock()
# game loop
while not exit_game:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit_game=True
if event.type==pygame.KEYDOWN:
if event.key==pygame.K_RIGHT:
# snake_x=snake_x+10
velocity_x = 4
velocity_y = 0
if event.key==pygame.K_LEFT:
# snake_x=snake_x-10
velocity_x = -4
velocity_y = 0
if event.key==pygame.K_UP:
# snake_y=snake_y-10
velocity_y = -4
velocity_x = 0
if event.key==pygame.K_DOWN:
# snake_y=snake_y+10
velocity_y = 4
velocity_x = 0
snake_x=snake_x + velocity_x
snake_y=snake_y + velocity_y
raghavgame_window.fill(red)
pygame.draw.rect(raghavgame_window,white,[snake_x,snake_y,snake_size,snake_size])
pygame.display.update()
clock.tick(fps)
pygame.quit()
quit()
superrbbbbbbbbbbbbbbbbbb
Great Sir
woooooooooooooooooo i feel so great . thank you sir for this
your sach a wonderful person ever
❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
Cocoa
🌹🌹❤️
👍👍👍❤️🌹
✋✋✋✋
🥰🥰🥰