enabled tap to test

This commit is contained in:
Nicholas Dyer 2023-02-19 19:34:28 -05:00
parent 4442bed2c2
commit 36ca8638f6
No known key found for this signature in database
GPG Key ID: E4E6388793FA2105

View File

@ -20,24 +20,27 @@ class Dial(pygame.sprite.Sprite):
self.image = pygame.transform.rotate(self._base_image, self.rotation) self.image = pygame.transform.rotate(self._base_image, self.rotation)
self.rect = self._base_image.get_rect() self.rect = self._base_image.get_rect()
self.test_cw = True self.test_cw = True
self.test = True
def update(self): def update(self):
if self.test_cw: if self.test:
self.position += 0.01 if self.test_cw:
else: self.position += 0.01
self.position -= 0.01 else:
if self.position > 1: self.position -= 0.01
self.position = 1 if self.position > 1:
self.test_cw = not self.test_cw self.position = 1
if self.position < 0: self.test_cw = not self.test_cw
self.position = 0 if self.position < 0:
self.test_cw = not self.test_cw self.position = 0
self.test_cw = not self.test_cw
self.rotation = 77 - (2 * 77.5 * self.position) self.rotation = 77 - (2 * 77.5 * self.position)
self.image = pygame.transform.rotate(self._base_image, self.rotation) self.image = pygame.transform.rotate(self._base_image, self.rotation)
self.rect = self.image.get_rect(center=self.rect.center) self.rect = self.image.get_rect(center=self.rect.center)
self.rect.center = (math.sin(math.radians(self.rotation)) * -300 + 360, self.rect.center = (math.sin(math.radians(self.rotation)) * -300 + 360,
math.cos(math.radians(self.rotation + 180)) * 300 + 360) math.cos(math.radians(self.rotation + 180)) * 300 + 360)
def set_test(self, test_value):
self.test = test_value
def main(windowed_mode): def main(windowed_mode):
pygame.init() pygame.init()
@ -74,6 +77,11 @@ def main(windowed_mode):
if event.type == pygame.KEYDOWN: if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE: if event.key == pygame.K_ESCAPE:
running = False running = False
if event.type == pygame.MOUSEBUTTONDOWN:
dial.set_test(True)
if event.type == pygame.MOUSEBUTTONUP:
dial.set_test(False)
mouse_pos = pygame.mouse.get_pos() mouse_pos = pygame.mouse.get_pos()