Changeset 101:a5011e14a23d
Legend:
- Unmodified
- Added
- Removed
-
engine.py
r100 r101 ˆà 17 17 field_size = min(self.canvas.winfo_height(), self.canvas.winfo_width())ˆà 18 18 offset = (self.canvas.winfo_width() - field_size, self.canvas.winfo_height() - field_size)ˆà ˆà 19 x0=offset[0] + self.x*field_size/21.0ˆà ˆà 20 y0=offset[1] + self.y*field_size/21.0ˆà ˆà 21 x1=offset[0] + (self.x+1)*field_size/21.0ˆà ˆà 22 y1=offset[1] + (self.y+1)*field_size/21.0ˆà ˆà 23 x2=offset[0] + (self.x+1/2.0)*field_size/21.0ˆà 19 24 if self.type == 'wall':ˆà 20 ˆà self.canvas.create_rectangle( offset[0], offset[1], offset[0] + self.x*field_size/21.0, offset[1] + self.y*field_size/21.0, fill="grey")ˆàˆà 25 self.canvas.create_rectangle(x0, y0, x1, y1, fill="grey")ˆà 21 26 passˆà 22 27 elif self.type == 'empty':ˆà 23 ˆà self.canvas.create_rectangle( offset[0], offset[1], offset[0] + self.x*field_size/21.0, offset[1] + self.y*field_size/21.0, fill="black")ˆàˆà 28 self.canvas.create_rectangle(x0, y0, x1, y1, fill="black")ˆà 24 29 passˆà 25 30 elif self.type == 'body':ˆà 26 ˆà self.canvas.create_rectangle( offset[0], offset[1], offset[0] + self.x*field_size/21.0, offset[1] + self.y*field_size/21.0, fill=self.snake.color)ˆàˆà 31 self.canvas.create_rectangle(x0, y0, x1, y1, fill=self.snake.color)ˆà 27 32 passˆà 28 33 elif self.type == 'head':ˆà 29 ˆà self.canvas.create_oval( offset[0], offset[1], offset[0] + self.x*field_size/21.0, offset[1] + self.y*field_size/21.0, fill=self.snake.color)ˆàˆà 34 self.canvas.create_oval(x0, y0, x1, y1, fill=self.snake.color)ˆà 30 35 passˆà 31 36 elif self.type == 'tail':ˆà 32 ˆà self.canvas.create_polygon( offset[0], offset[1], offset[0] + self.x*field_size/21.0, offset[1], offset[0] + self.x*field_size/(2*21.0), offset[1] + self.y*field_size/21.0, fill=self.snake.color)ˆàˆà 37 self.canvas.create_polygon(x0, y0, x1, y0, x2, y1, fill=self.snake.color)ˆà 33 38 passˆà 34 39 returnˆà
Note: See TracChangeset
for help on using the changeset viewer.