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