updated graphics

This commit is contained in:
Nicholas Dyer 2023-02-19 18:56:11 -05:00
parent 8ee2660fb9
commit 4eb0bfcafe
No known key found for this signature in database
GPG Key ID: E4E6388793FA2105

View File

@ -1,36 +1,35 @@
import pygame
import os
DIAL_SIZE = 500
SCREEN_SIZE = 720
FPS = 60
PI = 3.14159265
script_dir = os.path.dirname(os.path.abspath(__file__))
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
self.reverse = True
self._base_image = pygame.image.load(script_dir + '/resources/dial-face.png')
self.rotation = 0
self.image = pygame.transform.rotate(self._base_image, 77-(2*77.5*self.rotation))
self.rect = self._base_image.get_rect()
self.test_cw = True
def update(self):
if self.reverse:
self.value -= 0.01
if self.test_cw:
self.rotation += 0.01
else:
self.value += 0.01
if self.value < 0:
self.value = 0
self.reverse = not self.reverse
if self.value > 1:
self.value = 1
self.reverse = not self.reverse
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)
self.rotation -= 0.01
if self.rotation > 1:
self.rotation = 1
self.test_cw = not self.test_cw
if self.rotation < 0:
self.rotation = 0
self.test_cw = not self.test_cw
self.image = pygame.transform.rotate(self._base_image, 77-(2*77.5*self.rotation))
self.rect = self.image.get_rect(center=self.rect.center)
def main(windowed_mode):
@ -41,15 +40,16 @@ def main(windowed_mode):
else:
window = pygame.display.set_mode((SCREEN_SIZE, SCREEN_SIZE), pygame.FULLSCREEN)
all_sprites = pygame.sprite.Group()
bg_image = pygame.image.load(script_dir + '/resources/dial-bg.png')
dial = Dial()
all_sprites.add(dial)
all_sprites = pygame.sprite.Group(dial)
def draw():
# Draws all the sprites on a black background
all_sprites.update()
window.fill((0, 0, 0))
window.blit(bg_image, (0, 0))
all_sprites.draw(window)
# Update the entire display