本小游戏采用了pygame模块
1.产生随机颜色的小球。2.小球具有移动、吃别的小球、绘制这3个方法。3.鼠标点击事件
上源码
// 大球吃小球
from enum import Enum, unique
from math import sqrt
from random import randint
import pygame
@unique
class Color(Enum):
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GRAY = (242, 242, 242)
@staticmethod
def random_color():
r = randint(0, 255)
g = randint(0, 255)
b