Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.ru/trac/snake/changeset/179
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 17:48:49 2016
Êîäèðîâêà: IBM-866
Changeset 179:d73d8cecc812 òÀÓ Python Battle

Changeset 179:d73d8cecc812


Ignore:
Timestamp:
12/26/10 15:47:19 (5 years ago)
Author:
Alex Martynov
Branch:
default
Message:

engine.field_geometry_calc() added

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • engine.py

    r170 r179 ˆà
    225225        """Clear the field Widget and redraw cells images on it"""ˆà
    226226        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"""ˆà
    227238        w = self.canvas.winfo_width()ˆà
    228239        h = self.canvas.winfo_height()ˆà
    òÀæ òÀæ ˆà
    232243        field_geometry = (self.field.w*c,self.field.h*c)ˆà
    233244        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ˆà
    237246    ˆà
    238247    def legal_moves(self, snake):ˆà
  • main.py

    r176 r179 ˆà
    162162        self.run_cancel()ˆà
    163163        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]ˆà
    171165        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")ˆà
    172166        passˆà
Note: See TracChangeset for help on using the changeset viewer.