basic dial on screen

This commit is contained in:
Nicholas Dyer 2023-02-19 17:33:53 -05:00
parent 9fd904583c
commit f65bb04f5b
No known key found for this signature in database
GPG Key ID: E4E6388793FA2105

View File

@ -1,21 +1,53 @@
import pygame
DIAL_SIZE = 500
SCREEN_SIZE = 720
FPS = 60
PI = 3.14159265
class Dial(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.Surface((DIAL_SIZE, DIAL_SIZE))
self.rect = self.image.get_rect()
self.max = (10.0 / 6.0) * PI
self.min = (8.0 / 6.0) * PI
self.value = 1
def update(self):
self.image.fill((0, 0, 0))
pygame.draw.arc(self.image, (255, 255, 255), self.rect, self.min - (self.max * self.value), self.min, 32)
def main(windowed_mode):
pygame.init()
clock = pygame.time.Clock()
if windowed_mode:
window = pygame.display.set_mode((720, 720))
window = pygame.display.set_mode((SCREEN_SIZE, SCREEN_SIZE))
else:
window = pygame.display.set_mode((720, 720), pygame.FULLSCREEN)
window = pygame.display.set_mode((SCREEN_SIZE, SCREEN_SIZE), pygame.FULLSCREEN)
all_sprites = pygame.sprite.Group()
dial = Dial()
all_sprites.add(dial)
def draw():
# Draws all the sprites on a black background
all_sprites.update()
window.fill((0, 0, 0))
all_sprites.draw(window)
# Update the entire display
pygame.display.flip()
running = True
while running:
clock.tick(60)
clock.tick(FPS)
#pygame.mouse.set_visible(False)
# pygame.mouse.set_visible(False)
for event in pygame.event.get():
if event.type == pygame.QUIT:
@ -25,12 +57,7 @@ def main(windowed_mode):
running = False
mouse_pos = pygame.mouse.get_pos()
window.fill((0, 0, 0))
pygame.draw.line(window, (255, 255, 255), (0, 0), mouse_pos, 10)
pygame.draw.line(window, (255, 255, 255), (0, 720), mouse_pos, 10)
pygame.draw.line(window, (255, 255, 255), (720, 720), mouse_pos, 10)
pygame.draw.line(window, (255, 255, 255), (720, 0), mouse_pos, 10)
pygame.display.flip()
draw()
pygame.quit()