Verified Commit 6354ef37 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add PyGame display which exposes apygame surface

parent 0c91171e
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
from dataclasses import dataclass
from functools import cached_property

import pygame
from pygame import Surface

from poolpay.display.Display import Display


@dataclass(frozen=True)
class PygameDisplay(Display):
    @cached_property
    def surface(self) -> Surface:
        pygame.init()
        return pygame.Surface((self.width, self.height))

    def refresh(self) -> None:
        self.show(self.surface.convert(16, 0).get_buffer())