MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / draw

Method draw

DemoPrograms/Demo_Pong_Multiple_Platforms.py:80–107  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

78 return False
79
80 def draw(self):
81 self.curx += self.x
82 self.cury += self.y
83 self.graph.relocate_figure(self.id, self.curx, self.cury)
84 if self.cury <= 0: # see if hit top or bottom of play area. If so, reverse y direction
85 self.y = 4
86 self.cury = 0
87 if self.cury >= GAMEPLAY_SIZE[1]-BALL_RADIUS/2:
88 self.y = -4
89 self.cury = GAMEPLAY_SIZE[1]-BALL_RADIUS/2
90 if self.curx <= 0: # see if beyond player
91 self.player_1_Score += 1
92 self.graph.relocate_figure(
93 self.id, STARTING_BALL_POSITION[0], STARTING_BALL_POSITION[1])
94 self.x = 4
95 self.update_player2_score(self.player_1_Score)
96 self.curx, self.cury = STARTING_BALL_POSITION
97 if self.curx >= GAMEPLAY_SIZE[0]:
98 self.player_2_Score += 1
99 self.graph.relocate_figure(
100 self.id, STARTING_BALL_POSITION[0], STARTING_BALL_POSITION[1])
101 self.x = -4
102 self.update_player1_score(self.player_2_Score)
103 self.curx, self.cury = STARTING_BALL_POSITION
104 if self.hit_bat((self.curx, self.cury)):
105 self.x = 4
106 if self.hit_bat2((self.curx, self.cury)):
107 self.x = -4
108
109
110class PongBall():

Callers 15

pongFunction · 0.95
draw_figureFunction · 0.45
mainFunction · 0.45
draw_figureFunction · 0.45
mainFunction · 0.45
AxesGridFunction · 0.45
draw_figureFunction · 0.45
create_axis_gridFunction · 0.45
draw_figureFunction · 0.45
create_axis_gridFunction · 0.45
draw_figure_w_toolbarFunction · 0.45

Calls 5

update_player2_scoreMethod · 0.95
update_player1_scoreMethod · 0.95
hit_batMethod · 0.95
hit_bat2Method · 0.95
relocate_figureMethod · 0.80

Tested by

no test coverage detected