MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / Game

Class Game

galleries/examples/event_handling/pong_sgskip.py:132–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130
131
132class Game:
133 def __init__(self, ax):
134 # create the initial line
135 self.ax = ax
136 ax.xaxis.set_visible(False)
137 ax.set_xlim(0, 7)
138 ax.yaxis.set_visible(False)
139 ax.set_ylim(-1, 1)
140 pad_a_x = 0
141 pad_b_x = .50
142 pad_a_y = pad_b_y = .30
143 pad_b_x += 6.3
144
145 # pads
146 pA, = self.ax.barh(pad_a_y, .2,
147 height=.3, color='k', alpha=.5, edgecolor='b',
148 lw=2, label="Player B",
149 animated=True)
150 pB, = self.ax.barh(pad_b_y, .2,
151 height=.3, left=pad_b_x, color='k', alpha=.5,
152 edgecolor='r', lw=2, label="Player A",
153 animated=True)
154
155 # distractors
156 self.x = np.arange(0, 2.22*np.pi, 0.01)
157 self.line, = self.ax.plot(self.x, np.sin(self.x), "r",
158 animated=True, lw=4)
159 self.line2, = self.ax.plot(self.x, np.cos(self.x), "g",
160 animated=True, lw=4)
161 self.line3, = self.ax.plot(self.x, np.cos(self.x), "g",
162 animated=True, lw=4)
163 self.line4, = self.ax.plot(self.x, np.cos(self.x), "r",
164 animated=True, lw=4)
165
166 # center line
167 self.centerline, = self.ax.plot([3.5, 3.5], [1, -1], 'k',
168 alpha=.5, animated=True, lw=8)
169
170 # puck (s)
171 self.puckdisp = self.ax.scatter([1], [1], label='_nolegend_',
172 s=200, c='g',
173 alpha=.9, animated=True)
174
175 self.canvas = self.ax.figure.canvas
176 self.background = None
177 self.cnt = 0
178 self.distract = True
179 self.res = 100.0
180 self.on = False
181 self.inst = True # show instructions from the beginning
182 self.pads = [Pad(pA, pad_a_x, pad_a_y),
183 Pad(pB, pad_b_x, pad_b_y, 'r')]
184 self.pucks = []
185 self.i = self.ax.annotate(instructions, (.5, 0.5),
186 name='monospace',
187 verticalalignment='center',
188 horizontalalignment='center',
189 multialignment='left',

Callers 1

pong_sgskip.pyFile · 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…