-
Notifications
You must be signed in to change notification settings - Fork 0
Table & Fade
One simple element of the simulator is the actual table image. Because it depends on the quallity of the source you aquire the image from, we couldn't create an abstract way to load the image, yet. Because of this, the 'table.py' file is just a separation of applying some pre-defined settings to showcase the table on the simulator.
Thanks to this implementation, the user can toggle it on and on whenever he desires to.
Changes to the field table will be made by the creators each season. We'll try to improve the implementation of this feature, mostly because it's the weakest in the library.
The 'fade.py' file is a wrapper for pygame's opacity functionality. They use an alpha ( [0, 255] ) to set the opacity of any surface. Our implementation takes as parameter a surface or any text (later transformed into a surface) to be displayed on the screen. The opacity is transformed into a percent ( [0%, 100%] ), which is then automatically gradually decreased by the class, until it reaches 0:
def onScreen(self, screen: pygame.Surface):
if self.opacity < 0:
return None
current_time = pygame.time.get_ticks()
if msToS(current_time - self.reset_time) > self.constants.TIME_UNTIL_FADE:
self.opacity -= self.constants.FADE_PERCENT
self.opacity = max(0, self.opacity)
self.obj.set_alpha(percent2Alpha(self.opacity))
screen.blit(self.obj, self.obj_rectangle)
This feature is used when displaying feedback for the user on manual (joystick) control.