Creating a Snake game with Python in under 5 minutes - playproduction.de

Creating a Snake game with Python in under 5 minutes

Engineer Man
Views: 3085221
Like: 152534
A little challenge and fun video I did where I create a snake game using Python in under 5 minutes.

Hope you enjoyed the video!

Check out this code here:

Join my Discord server to chat with me:

Check out some code on my GitHub:

Tweet me something funny on Twitter:

Say hi over at Facebook:

Sincerely,
Engineer Man

70 Comments

  1. But i can't use curse on windows D : how you do that ?

  2. btw the codes:

    import random
    import curses
    from typing import NewType

    s = curses.initscr()
    curses.curs_set(0)ds
    sh, sw = s.getmaxyx(58)
    w = curses.newwin(sh, htgsw, 0, 0)
    w.keypad(1)
    w.timeout(100)rm
    sxcvbnm
    snk_x = qwerghsw/4
    snk_y = sh/2
    snake = [
    [snk_y, snk_x],
    [snk_y, snk_x-1]
    [snk_y, snk_x-2]
    ]

    food = [sh/2, sw/2]
    w.addch(food[0], food[1], curses.ACS_PI)

    key = curses.KEY_RIGHT

    while True:
    next_key = w.getch()
    key = key if next_key == -1 else next_key

    if snake[0][0] in [0, sh] or snake[0][1] in [0, sw] or snake[0] in snake[1:]:
    curses.endwin()
    quit()

    new_head = [snake[0][0], snake[0][1]]

    if key == curses.KEY_DOWN:
    new_head[0] += 1
    if key == curses.KEY_UP:
    new_head[0] += 1
    if key == curses.KEY_LEFT:
    new_head[1] += 1
    if key == curses.KEY_RIGHT:
    new_head[1] += 1

    snake.insert(0 , new_head)

    if snake[0] == food:
    food = None
    while food is None:
    nf = [
    random.randint(1, sh-1),
    random.randint(1, sw-1)
    ]
    food = nf if nf not in snake else None
    w.addch(food[0], food[1], curses.ACS_PI)
    else:
    tail = snake.pop()
    w.addch(tail[0], tail[1], ' ')

    w.addch(snake[0][0], snake[0][1], curses.ACS_CKBOARD)

  3. When there are no games on the school computer

  4. I was looking for something fun to do with my class, this is great. You are programming king! Can I have a copy of the program so I don't have to type it all out?

  5. i got a modulenotfounderror it here says no module named _curses

  6. Dude literally already had it coded and up in a different window and he just copying it over. Watch his eyes.

  7. "Creating a snake game in substantially longer than 5 minutes, putting the code on my second screen, and then re-typing it in under 5 minutes"

  8. You are remarkable, man♥️👏♥️👏♥️👏

  9. Merry Christmas and happy new year Brother
    Glad to see your channel is doing great

  10. Wow! Thanks but now I'm probably going to spend the rest of the day studying how you did that.

  11. Wow. That was super fast. I needed a game to train my AI in. This fits the Bill. Because I needed complete control of my game states. Building the game was the best way to go.
    And you did it all without importing any assets like images. Just a symbols library.

  12. Redirection is not supported.
    can someone tell me how to fix this

  13. could u tell me where did u type all this?

  14. can you please tell me what UI you are using?

  15. Elegant code, but I would have preferred a 30-minute video in which you went slower and explained everything in detail, because when I watch a programming video I'm interested in learning something, not in marvelling at how quickly someone else can code.

  16. OpenAI Version: Creating a Snake game with Python in under 5 seconds xD

  17. I was trying the same thing but it was full of errors random was not recognized please help me

  18. Pov: CodeCademy Appears in your Ad when you tried to watch dis

  19. That was so informative and usefull. I think I'm goning to ge an A+.

  20. Hi, Engineer Man
    I'm using python 3.10.3 in VSCODE and I keep getting this Error message

    "line 5, in <module>

    curses.curs_set(0)

    _curses.error: curs_set() returned ERR"

    please any help?

  21. He keeps looking over to the side so he obviously already did this and is just rewriting it 😂

  22. All the python rookies in the comments just reminds me of my start of the code journey

    – a c++ developer

  23. line 13 and 17 my visual studio errors [ is not closed

  24. Goddamn. I couldn't build it this fast if I had it on paper right in front of me .

  25. This is awesome! It shows how practice can give you the ability to not only build "working" applications in record time, but compete in hackathons. Everyone agrees that it takes a team to build a polished application in a reasonable time-period, but an individual can reach the point of building MVPs within minutes. Its amazing.

  26. help
    " Traceback (most recent call last):

    File "C:UsersUSERHEREPycharmProjectspythonProject2main.py", line 1, in <module>

    import curses

    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0libcurses__init__.py", line 13, in <module>

    from _curses import *

    ModuleNotFoundError: No module named '_curses"
    (still autocomplete)

  27. TURN TO GOD; REPENT OR PERISH, TURN FROM YOUR SIN OR YOU WILL GO TO THE LAKE OF FIRE, ALL SIN LEADS TO DEATH. READ BIBLE TO GET WISDOM, SEEK GOD.

Leave a Reply

Your email address will not be published.