Making Snake Move On Arrow Key Press - Python Game Development Using Pygame In Hindi #14 - playproduction.de

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 –

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 –

500 Comments

  1. bhai majjja aaa gya thanks for this asm content

  2. 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.

  3. I am having fun while making this game……

  4. Sir game toh badi acchi ban rahi ha❤❤❤❤

  5. Mera snake up down move nhi kr raha harry sir kitni bar comment kr diya ab toh btado

  6. I m 12 years old and I m learning cooding to make bright future

  7. Yes Harry sir 💚.bachpan ki bhaavnayien chalk gyii.

  8. thanks for this series thanks*1000000000000000000000 times 🙂

  9. 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.

  10. Seriously it's the best feeling to play ur own game

  11. bhai sachme itna amza aarahe kya batau thank you so much

  12. One question: Only when I hover my mouse over the window only then the snake moves. Other wise it stops, what is the reason?

  13. # 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()

  14. woooooooooooooooooo i feel so great . thank you sir for this

  15. ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤

Leave a Reply

Your email address will not be published.