6 examples of 'pygame draw line' in Python

Every line of 'pygame draw line' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
185def draw_line(self,pt1,pt2,color=(1,1,1,1)):
186 if len(color) == 3:
187 color = (*color,1)
188 glBegin(GL_LINES)
189 glColor4f(*color)
190 glVertex2f(*pt1)
191 glVertex2f(*pt2)
192 glEnd()
436def drawHorLine(self,xx,yy,length,screen,color = 0):
437 for x in xrange(length):
438 screen[(xx+x)%0xFF,yy&0xFF] = color
64def draw_circle(self, position, radius, color, width=0):
65 position = self.map_point(position)
66 r = int(radius*self.scale)
67 width = int(width*self.scale)
68 x, y = position
69
70 if width == 0:
71 pygame.gfxdraw.filled_circle(self.surface, x, y, r, color)
72
73 if r > 1:
74 pygame.gfxdraw.aacircle(self.surface, x, y, r, color)
154def drawPath(self, path):
155 for line in path:
156 self.drawLine(line)
313def draw_circle(self, circ, surface):
314 obj = pygame.image.load(circ.get_sprite())
315 obj = pygame.transform.scale(obj, (circ.radius*2, circ.radius*2))
316 obj = pygame.transform.rotate(obj, np.rad2deg(circ.angle))
317 surface.blit(obj, (circ.x-circ.radius,circ.y-circ.radius))
318 return
52def draw(self):
53 self.screen.fill((0, 100, 0))
54 pygame.draw.rect(self.screen, (135, 206, 235), pygame.Rect(0, 0, self.width, 100))
55 for i in range(2):
56 if self.dead[i]:
57 img = CrackGame.DEAD_IMAGE
58 elif not self.jumps[i]:
59 img = CrackGame.IMAGES[self.current_frame]
60 else:
61 img = CrackGame.JUMP_IMAGE
62
63 pygame.draw.rect(self.screen, (200, 200, 200), pygame.Rect(0, self.sidewalk_y + i*2*self.sidewalk_height, self.width, self.sidewalk_height))
64 pygame.draw.rect(self.screen, (150, 150, 150), pygame.Rect(0, self.sidewalk_y+self.sidewalk_height + i*2*self.sidewalk_height, self.width, self.sidewalk_height/5))
65 p = 0
66 for crack in self.cracks:
67 pygame.draw.aaline(self.screen, (0, 0, 0), (p + crack - 10, self.sidewalk_y+self.sidewalk_height + i*2*self.sidewalk_height), (p + crack + 10, self.sidewalk_y + i*2*self.sidewalk_height))
68 pygame.draw.aaline(self.screen, (0, 0, 0), (p + crack - 10, self.sidewalk_y+self.sidewalk_height + i*2*self.sidewalk_height), (p + crack - 10, self.sidewalk_y+self.sidewalk_height + i*2*self.sidewalk_height + self.sidewalk_height/5))
69 p += crack
70 if not self.jumping[i]:
71 if (self.positions[i][0] < self.width) and (self.positions[i][0] - img.get_rect().width/4 < p < self.positions[i][0] + img.get_rect().width/4):
72 self.dead[i] = True
73
74 if not self.dead[i]:
75 width = img.get_rect().width - ((self.sidewalk_y+self.sidewalk_height/2 + 2*i*self.sidewalk_height - self.positions[i][1]) / 8)
76 pygame.draw.ellipse(self.screen, (180, 180, 180), pygame.Rect(self.positions[i][0] - img.get_rect().width/2, self.sidewalk_y + i*2*self.sidewalk_height + 60, width, 20))
77 self.screen.blit(img, pygame.Rect(self.positions[i][0] - img.get_rect().width/2, self.positions[i][1] - 0.75*img.get_rect().height, img.get_rect().width, img.get_rect().height))

Related snippets