-
Notifications
You must be signed in to change notification settings - Fork 0
/
angle_meter.py
40 lines (33 loc) · 1.15 KB
/
angle_meter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from cannon import Cannon
import pygame
class AngleMeter:
def __init__(
self, x: int, y: int, font: str, font_size: int, cannon: Cannon
) -> None:
"""Constructor
Args:
x (int): The x position in pixels
y (int): The y position in pixels
font (str): The name of the desired font
font_size (int): The size of the font in pixels
cannon (Cannon): The cannon object to read the angle from
"""
self.x = x
self.y = y
self.font = pygame.font.SysFont(font, font_size)
self.cannon = cannon
def update(self, time_step: float) -> None:
"""Empty update function. Must be here because it is a game object
Args:
time_step (float): Time since last frame
"""
pass
def render(self, window: pygame.display) -> None:
"""Renders the angle meter
Args:
window (pygame.display): The window to blit the text to
"""
text = self.font.render(
str(round(self.cannon.angle, 2)), 1, pygame.Color(255, 255, 255)
)
window.blit(text, (self.x, self.y))