| How to create a Snake game using python | | AK python |

| How to create a Snake game using python | | AK python |

AK Python

4 года назад

1,154,828 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@AKPython
@AKPython - 11.01.2021 15:42

Full code:

from turtle import *
from random import randrange
from freegames import square, vector

food = vector(0, 0)
snake = [vector(10, 0)]
aim = vector(0, -10)

def change(x, y):
"Change snake direction."
aim.x = x
aim.y = y

def inside(head):
"Return True if head inside boundaries."
return -200 < head.x < 190 and -200 < head.y < 190

def move():
"Move snake forward one segment."
head = snake[-1].copy()
head.move(aim)

if not inside(head) or head in snake:
square(head.x, head.y, 9, 'red')
update()
return

snake.append(head)

if head == food:
print('Snake:', len(snake))
food.x = randrange(-15, 15) * 10
food.y = randrange(-15, 15) * 10
else:
snake.pop(0)

clear()

for body in snake:
square(body.x, body.y, 9, 'green')

square(food.x, food.y, 9, 'red')
update()
ontimer(move, 100)


hideturtle()
tracer(False)
listen()
onkey(lambda: change(10, 0), 'Right')
onkey(lambda: change(-10, 0), 'Left')
onkey(lambda: change(0, 10), 'Up')
onkey(lambda: change(0, -10), 'Down')
move()
done()

Ответить
@princesinghaniya9652
@princesinghaniya9652 - 21.11.2023 17:45

Module name head not found
Plsss fix it

Ответить
@user-oh2dr7ey7z
@user-oh2dr7ey7z - 08.11.2023 15:50

No module named 'freegames'

Ответить
@user-oi2no6vr5i
@user-oi2no6vr5i - 31.10.2023 21:14

fack you
from turtle import*
from random import randrange
from freegames import square,vector

Ответить
@MauliksCricketShorts
@MauliksCricketShorts - 30.10.2023 19:01

bro please reply
when i tap on run module it shows error about that freegames in the 3rd line

Ответить
@ahmadsulaiman1723
@ahmadsulaiman1723 - 28.10.2023 13:42

I finished, no error, but its not opening

Ответить
@CHICKENSY
@CHICKENSY - 11.10.2023 05:20

thank you sir!

Ответить
@jas_ars_...1167
@jas_ars_...1167 - 05.10.2023 21:34

From freegames import square, vector
Modulenotfiunderror: no module named 'freegames'



WHY THiS IS COMING TO ME
PLEASE TELL ME THE SOLUTION GUYSS????

Ответить
@sarthaksaxena7920
@sarthaksaxena7920 - 15.09.2023 17:20

Bro at my end it was showing that no module like freegames was found 😢

Ответить
@esam71
@esam71 - 10.09.2023 18:42

Sir,how to package it?

Ответить
@farley500fns
@farley500fns - 28.08.2023 21:26

I created the code inside pycharm but it didn't open the graphic screen with snake. what is missing?

Ответить
@sanatan_tech
@sanatan_tech - 01.07.2023 17:33

hi ak i know you very well

Ответить
@user-pm3oh6vi8j
@user-pm3oh6vi8j - 23.06.2023 08:36

I got this Error :- ModuleNotFoundError: No module named 'freegames'

Ответить
@keshavkumar-vd1zr
@keshavkumar-vd1zr - 14.06.2023 13:36

bhai error bol raha hai no modules with freegames likh raha hai kya karko

Ответить
@Ry_an20
@Ry_an20 - 04.06.2023 03:46

App name? Please 🙏

Ответить
@XJozhX
@XJozhX - 26.05.2023 13:13

No module named 'freegames' (i use pycharm)

Ответить
@lalitasharma6715
@lalitasharma6715 - 22.05.2023 20:04

Thanks bro love u❤❤❤

Ответить
@lalitasharma6715
@lalitasharma6715 - 22.05.2023 20:04

Thanks bro love u❤❤❤

Ответить
@banubogdan-alexandru167
@banubogdan-alexandru167 - 17.05.2023 21:47

Is not working at all

Ответить
@bhavaninandam8078
@bhavaninandam8078 - 15.05.2023 09:41

its good

Ответить
@jawadhaidar8116
@jawadhaidar8116 - 22.04.2023 09:55

They are puting no module named 'freegames'

Ответить
@VireshHadalagi-yn8lc
@VireshHadalagi-yn8lc - 21.04.2023 15:52

How to download the page

Ответить
@vireshhadalagi7493
@vireshhadalagi7493 - 19.04.2023 17:07

bhai page ka download

Ответить
@ASkb582
@ASkb582 - 18.04.2023 20:04

good

Ответить
@cyla6556
@cyla6556 - 16.04.2023 22:16

What if u don’t have free games how do u run the project?

Ответить
@satyamamte8138
@satyamamte8138 - 16.04.2023 14:23

Op bro 👍

Ответить
@user-ec1rc5gz6f
@user-ec1rc5gz6f - 12.04.2023 13:09

fuckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

Ответить
@harsh_shantoriya
@harsh_shantoriya - 08.04.2023 06:48

My device is showing a "module not found error" ... Apparently it says that there is no module named freegames

Ответить
@boopathysunil5227
@boopathysunil5227 - 23.03.2023 05:39

There are no errors but program isn't running ?

Ответить
@daddydaddy9840
@daddydaddy9840 - 18.03.2023 18:15

can we put this in our resume?

Ответить
@_bombiaszgaming_8463
@_bombiaszgaming_8463 - 16.03.2023 21:25

dosnt work i dont give for you free robux

Ответить
@ashis166
@ashis166 - 10.03.2023 11:12

Sir what is the engine

Ответить
@savithashwetha6397
@savithashwetha6397 - 09.03.2023 16:37

That showing No module named 'freegames'

Ответить
@savithashwetha6397
@savithashwetha6397 - 09.03.2023 16:33

That showing in red colour error
Why

Ответить
@Ayash.2010
@Ayash.2010 - 09.03.2023 07:43

I am not getting the output please help me

Ответить
@tasinvideo1926
@tasinvideo1926 - 07.03.2023 00:57

What applications have you used?

Ответить
@parmanandsingh8679
@parmanandsingh8679 - 05.03.2023 08:16

Do we need anything else after script this code in python to run this program??

Ответить
@mishelranaweeera7370
@mishelranaweeera7370 - 04.03.2023 22:55

To me its not working ... its showing NO module named 'freegames' how can i make it

Ответить
@bhavaniangadi611
@bhavaniangadi611 - 04.03.2023 18:46

I need assets??? Can u provide???

Ответить
@OmniStar_Boy
@OmniStar_Boy - 19.02.2023 13:21

bhai mjhe module ka msla arha he koi help krdo jesei code type krta hn


from turtle import *
from random import randrange
from freegames import square, vector

to module error deta hai
ye error deta h
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'freegames'

plZ koi solution btado

Ответить
@slovenia_cool
@slovenia_cool - 14.02.2023 18:36

this suck 😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡😡

Ответить
@yatharth8562
@yatharth8562 - 14.02.2023 12:27

good

Ответить
@archanaborade3202
@archanaborade3202 - 12.02.2023 10:20

Which software are u using for python

Ответить
@BHUPENDRAlodhi-lv3xx
@BHUPENDRAlodhi-lv3xx - 09.02.2023 16:49

Program is not run

Ответить
@Muhammad-Mairaj
@Muhammad-Mairaj - 05.02.2023 19:47

IF YOU LIKE THIS VIDEO THEN LIKE THIS COMMENT

Ответить
@fbi7993
@fbi7993 - 03.02.2023 21:03

Also I copied your codes and it didn't work

Ответить
@fbi7993
@fbi7993 - 03.02.2023 21:02

I can't move the snake in the game

Ответить
@shubhampratapsingh2683
@shubhampratapsingh2683 - 03.02.2023 12:58

but there is a bug in this code when we move forward and collecting food and if i move backward then snake has dead.... conclusion is we can not use up key with down key after eating 2,3 food

Ответить
@Toman888
@Toman888 - 01.02.2023 09:14

Sir no module name 'freegames' ??

Ответить
@worldskill1472
@worldskill1472 - 28.01.2023 12:56

not work

Ответить