MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / Stick

Class Stick

tools/python-3.11.9-amd64/Lib/turtledemo/nim.py:89–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected