8 ball game source code
Import pyame import sys from math import * import random pygame.init() width = 660 height = 360 outerHeight = 400 margin = 30 display = pygame.display.set_mode((width, outerHeight)) pygame.display.set_caption("8 Ball Pool") clock = pygame.time.Clock() background = (51, 51, 51) white = (236, 240, 241) gray = (123, 125, 125) black = (23, 32, 42) yellow = (244, 208, 63) blue = (52, 152, 219) red = (203, 67, 53) purple = (136, 78, 160) orange = (230, 126, 34) green = (40, 180, 99) brown = (100, 30, 22) stickColor = (249, 231, 159) colors = [yellow, blue, red, purple, orange, green, brown, black, yellow, blue, red, purple, orange, green, brown] balls = [] noBalls = 15 radius = 10 friction = 0.005 # Ball Class class Ball: def __init__(self, x, y, speed, color, angle, ballNum): self.x = x + radius self.y = y + radius self.color = color self.angle = angle ...
