本文实例为大家分享了python实现贪吃蛇的具体代码,供大家参考,具体内容如下
import pygame
import sys
import random
SCREEN_X=600
SCREEN_Y=600
class Snake(object):
def __init__(self):
self.direction=pygame.K_RIGHT
self.body = []
for i in range(5):
self.addnode()
def addnode(self):
left, top = (0, 0)
if self.body:
left, top =
1