资源简介
要安装pygame模块
代码片段和文件信息
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import random
import pygame
import sys
from pygame.locals import *
Snakespeed = 17
Window_Width = 800
Window_Height = 500
Cell_Size = 20 # Width and height of the cells
# Ensuring that the cells fit perfectly in the window. eg if cell size was
# 10 and window width or windowheight were 15 only 1.5 cells would
# fit.
assert Window_Width % Cell_Size == 0 “Window width must be a multiple of cell size.“
# Ensuring that only whole integer number of cells fit perfectly in the window.
assert Window_Height % Cell_Size == 0 “Window height must be a multiple of cell size.“
Cell_W = int(Window_Width / Cell_Size) # Cell Width
Cell_H = int(Window_Height / Cell_Size) # Cellc Height
White = (255 255 255)
Black = (0 0 0)
评论
共有 条评论