“”"
Snake Game template, using classes.
Derived from:
Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/
“”"
import pygame
import random
— Globals —
Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
Screen size
height = 600
width = 600
Margin between each segment
segment_margin = 3
Set the width and height of each snake segment
segment_width = min(height, width) / 40 - segment_margin
segment_height = min(height, width) / 40 - segment_margin
Set initial speed
x_change = segment_width + segment_margin
y_change = 0
position=[ i for i in range(0, 600, 15)]
class Snake():
“”" Class to represent one snake. “”"
# Constructor
def __init__(self):
# Food().__init__()
# Sfoodlists = Food().foodlists
# S