basic dial on screen
This commit is contained in:
parent
9fd904583c
commit
f65bb04f5b
@ -1,19 +1,51 @@
|
|||||||
import pygame
|
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):
|
def main(windowed_mode):
|
||||||
pygame.init()
|
pygame.init()
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
if windowed_mode:
|
if windowed_mode:
|
||||||
window = pygame.display.set_mode((720, 720))
|
window = pygame.display.set_mode((SCREEN_SIZE, SCREEN_SIZE))
|
||||||
else:
|
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))
|
window.fill((0, 0, 0))
|
||||||
|
all_sprites.draw(window)
|
||||||
|
|
||||||
|
# Update the entire display
|
||||||
|
pygame.display.flip()
|
||||||
|
|
||||||
running = True
|
running = True
|
||||||
while running:
|
while running:
|
||||||
clock.tick(60)
|
clock.tick(FPS)
|
||||||
|
|
||||||
# pygame.mouse.set_visible(False)
|
# pygame.mouse.set_visible(False)
|
||||||
|
|
||||||
@ -25,12 +57,7 @@ def main(windowed_mode):
|
|||||||
running = False
|
running = False
|
||||||
|
|
||||||
mouse_pos = pygame.mouse.get_pos()
|
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()
|
pygame.quit()
|
||||||
|
Loading…
Reference in New Issue
Block a user