Games write their own displayables with render(), renpy.Render, blit, fill, canvas() and renpy.redraw. render.ts keeps a tree of placed pieces (child renders, ordinary displayables, fills and drawing commands) and turns it into DOM elements that stay put between redraws; pointer events reach event() as pygame-style objects, and a returned value ends the interaction. Shaders and GPU properties are accepted and ignored. The converter whitelists the calls and methods and accepts `import pygame`. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
23 lines
652 B
Python
23 lines
652 B
Python
class Meter(renpy.Displayable):
|
|
def __init__(self, value, **kwargs):
|
|
super(Meter, self).__init__(**kwargs)
|
|
self.value = value
|
|
self.moves = 0
|
|
|
|
def render(self, width, height, st, at):
|
|
renpy.redraw(self, 0.1)
|
|
rv = renpy.Render(width, 20)
|
|
rv.fill("#fff", (0, 0, self.value, 20))
|
|
canvas = rv.canvas()
|
|
canvas.circle("#f00", (5, 5), 4)
|
|
rv.blit(renpy.render("pic.png", width, height, st, at), (3, 4))
|
|
return rv
|
|
|
|
def event(self, ev, x, y, st):
|
|
if ev.type == pygame.MOUSEMOTION:
|
|
self.moves += 1
|
|
raise renpy.IgnoreEvent()
|
|
|
|
|
|
meter = Meter(60)
|