21 lines
568 B
Python
21 lines
568 B
Python
import pygame
|
|
from colors import *
|
|
import math
|
|
|
|
class CircleButton:
|
|
|
|
def __init__(self, gui, x, y, radius):
|
|
self.screen = gui.screen
|
|
self.x = x
|
|
self.y = y
|
|
self.radius = radius
|
|
self.color = color_primary
|
|
|
|
def check_click(self, pos, action):
|
|
if math.sqrt(math.pow(pos[0] - self.x, 2) +
|
|
math.pow(pos[1] - self.y, 2)) < self.radius:
|
|
action()
|
|
|
|
def display(self):
|
|
pygame.draw.circle(self.screen, self.color,
|
|
(self.x, self.y), self.radius) |