DRincs-Productions / Renpygame

Renpygame is a framework that allows pygame games to be integrated with Ren'Py. It's intended for people who are capable programmers.
https://drincs-website.web.app
MIT License
10 stars 2 forks source link

Fix blinking during draw #15

Closed BlackRam-oss closed 1 year ago

BlackRam-oss commented 1 year ago
class RenpyGameByTimer(renpy.Displayable):

    def __init__(
        self,
        **kwargs,
    ):
        self.child_render = renpy.Render(1920, 1080)
        self.current_frame_number = 0

        # renpy.Displayable init
        super(RenpyGameByTimer, self).__init__(**kwargs)

    def render(self, width: int, height: int, st: float, at: float) -> renpy.Render:
        return self.child_render

    def event(self, ev: EventType, x: int, y: int, st: float):
        self.current_frame_number += 1
        canvas = self.child_render.canvas()
        # if self.current_frame_number % 2 == 0:
        canvas.circle((255, 0, 0), (100, 100), 50)
        # elif self.current_frame_number % 3 == 0:
        canvas.circle((0, 255, 0), (200, 200), 50)
        # elif self.current_frame_number % 5 == 0:
        canvas.circle((255, 255, 255), (300, 300), 50)
        print("event", self.current_frame_number)