
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
21.05.2022
Did you use Pygame?
But i can't use curse on windows D : how you do that ?
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)
are you ok your room seems sad and lonely
When there are no games on the school computer
Me on my ti-84 + ce python edition
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?
i got a modulenotfounderror it here says no module named _curses
Creating python using python
Dude literally already had it coded and up in a different window and he just copying it over. Watch his eyes.
"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"
You are remarkable, man♥️👏♥️👏♥️👏
Merry Christmas and happy new year Brother
Glad to see your channel is doing great
wait what plugins are you using
Wow! Thanks but now I'm probably going to spend the rest of the day studying how you did that.
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.
A snake game in Python? lol
Redirection is not supported.
can someone tell me how to fix this
could u tell me where did u type all this?
This guy is from another world
How to i open the game?
can you please tell me what UI you are using?
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.
Can we develop it on python 2.7?
OpenAI Version: Creating a Snake game with Python in under 5 seconds xD
I was trying the same thing but it was full of errors random was not recognized please help me
This was really cool.
Fail is not defined
What version of python is it
Pov: CodeCademy Appears in your Ad when you tried to watch dis
Did this guy just hack the govermente?
That was so informative and usefull. I think I'm goning to ge an A+.
What app does he use to code
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?
He keeps looking over to the side so he obviously already did this and is just rewriting it 😂
All the python rookies in the comments just reminds me of my start of the code journey
– a c++ developer
line 13 and 17 my visual studio errors [ is not closed
This is a fake coding.
what IDE are you using?
What interpreter did you use
clean
Not work
it cannot even work
do you worked???
Goddamn. I couldn't build it this fast if I had it on paper right in front of me .
cool!
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.
very cool..thanks for the video
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)
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.