MCPcopy Index your code
hub / github.com/python/cpython / Stick

Class Stick

Lib/turtledemo/nim.py:87–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85
86
87class Stick(turtle.Turtle):
88 def __init__(self, row, col, game):
89 turtle.Turtle.__init__(self, visible=False)
90 self.row = row
91 self.col = col
92 self.game = game
93 x, y = self.coords(row, col)
94 self.shape("square")
95 self.shapesize(HUNIT/10.0, WUNIT/20.0)
96 self.speed(0)
97 self.pu()
98 self.goto(x,y)
99 self.color("white")
100 self.showturtle()
101
102 def coords(self, row, col):
103 packet, remainder = divmod(col, 5)
104 x = (3 + 11 * packet + 2 * remainder) * WUNIT
105 y = (2 + 3 * row) * HUNIT
106 return x - SCREENWIDTH // 2 + WUNIT // 2, SCREENHEIGHT // 2 - y - HUNIT // 2
107
108 def makemove(self, x, y):
109 if self.game.state != Nim.RUNNING:
110 return
111 self.game.controller.notify_move(self.row, self.col)
112
113
114class NimView(object):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…