Changeset 179:d73d8cecc812
Legend:
- Unmodified
- Added
- Removed
-
engine.py
r170 r179 ˆà 225 225 """Clear the field Widget and redraw cells images on it"""ˆà 226 226 self.canvas.delete("all")ˆà ˆà 227 offset, c = self.field_geometry_calc()[1:]ˆà ˆà 228 for cell_coord in self.field:ˆà ˆà 229 self.field[cell_coord].redraw(offset, c)ˆà ˆà 230 returnˆà ˆà 231 ˆà ˆà 232 def field_geometry_calc (self):ˆà ˆà 233 """Calculate grafical parameters of the field.ˆà ˆà 234 Return:ˆà ˆà 235 field_geometry - (width, hight) of the fieldˆà ˆà 236 offset - (x, y) of the left top corner of the fieldˆà ˆà 237 c - cell size"""ˆà 227 238 w = self.canvas.winfo_width()ˆà 228 239 h = self.canvas.winfo_height()ˆà òÀæ òÀæ ˆà 232 243 field_geometry = (self.field.w*c,self.field.h*c)ˆà 233 244 offset = ((w - field_geometry[0])/2.0, (h - field_geometry[1])/2.0)ˆà 234 ˆà for cell_coord in self.field:ˆà 235 ˆà self.field[cell_coord].redraw(offset, c)ˆà 236 ˆà returnˆà ˆà 245 return field_geometry, offset, cˆà 237 246 ˆà 238 247 def legal_moves(self, snake):ˆà -
main.py
r176 r179 ˆà 162 162 self.run_cancel()ˆà 163 163 self.step_id = self.game_length + 666ˆà 164 ˆà w = self.canvas.winfo_width()ˆà 165 ˆà h = self.canvas.winfo_height()ˆà 166 ˆà cw = w/float(self.engine.field.w)ˆà 167 ˆà ch = h/float(self.engine.field.h)ˆà 168 ˆà c = min(cw, ch)ˆà 169 ˆà field_geometry = (self.engine.field.w*c,self.engine.field.h*c)ˆà 170 ˆà offset = ((w - field_geometry[0])/2.0, (h - field_geometry[1])/2.0)ˆà ˆà 164 field_geometry, offset = self.engine.field_geometry_calc()[0:2]ˆà 171 165 self.canvas.create_text(offset[0]+ field_geometry[0]/2.0, offset[1]+field_geometry[1]/2.0, text="End of the round", fill="white", font="bold")ˆà 172 166 passˆà
Note: See TracChangeset
for help on using the changeset viewer.