예제 #1
0
 def generate_seeds(self, n):
     xl, xh, yl, yh = self.x + 15, self.x + self.w - 15, self.y + 15, self.y + self.h - 15
     seeds = []
     for i in xrange(n):
         x, y = get_pos(random.randint(xl, xh), random.randint(yl, yh))
         seeds.append((x, y, COLOR_MAGENTA))
     return seeds
예제 #2
0
 def generate_seeds(self,n):
     xl, xh, yl, yh = self.x + 15, self.x + self.w - 15, self.y + 15, self.y + self.h - 15
     seeds = []
     for i in xrange(n):
         x,y = get_pos(random.randint(xl,xh), random.randint(yl,yh))
         seeds.append((x,y,COLOR_MAGENTA))
     return seeds
예제 #3
0
 def __init__(self, x, y, c, dir):
     x,y = get_pos(x,y)
     self.points, self.max_points = 0,0
     self.color = c
     self.dir = dir
     self.nodes = [SnakeNode(x-i, y, c, dir) for i in xrange(BASE_SIZE)]
     self.head = self.nodes[0]
     self.head.is_head = True
     self.tail = self.nodes[-1]
     for i in xrange(len(self.nodes)):
         self.nodes[i].prev = self.nodes[i+1] if i+1 < len(self.nodes) else None
         self.nodes[i].next = self.nodes[i-1] if i-1 >= 0 else None
예제 #4
0
 def generate_random_pos(self):
     xl, xh, yl, yh = self.x + 15, self.x + self.w - 15, self.y + 15, self.y + self.h - 15
     return get_pos(random.randint(xl, xh), random.randint(yl, yh))
예제 #5
0
 def generate_random_pos(self):
     xl, xh, yl, yh = self.x + 15, self.x + self.w - 15, self.y + 15, self.y + self.h - 15
     return get_pos(random.randint(xl,xh), random.randint(yl,yh))