Many of the forum elders promoted using creator defined displayables with ATL, so that is what I have tried to do. After much wailing and gnashing of teeth, I have created a decent looking particle burst.
However, when I put it into the minigame it introduces a delay every time it is generated. I'm sure that there are a whole host of reasons why this might be, but I'd like to start by getting some feedback on the displayable and transform that I'm using, because I'm certain that I still don't really understand creator defined displayables.
Code: Select all
transform particleTransform(d, speed, endX, endY):
d
subpixel True
parallel:
linear speed xpos endX ypos endY
parallel:
linear speed alpha 0
init python:
import math
import random
class particle(renpy.Displayable):
def __init__(self, xPos, yPos, **kwargs):
renpy.Displayable.__init__(self, **kwargs)
self.xPos = xPos
self.yPos = yPos
self.speed = random.random()
self.endX = random.randint(-200, 200)
self.endY = random.randint(-200, 200)
randomValueForColor = lambda: random.randint(0,255)
self.color = '#%02X%02X%02X' % (randomValueForColor(),randomValueForColor(),randomValueForColor())
def render(self, width, height, st, at):
render = renpy.Render(width, height)
canvas = render.canvas()
canvas.circle(self.color, (self.xPos, self.yPos), 2)
return render
class particleBurst(renpy.Displayable):
def __init__(self, xPos, yPos, **kwargs):
renpy.Displayable.__init__(self, **kwargs)
self.particles = []
self.xPos = xPos
self.yPos = yPos
for i in range(0, 50):
thing = particle(self.xPos, self.yPos)
self.particles.append(particleTransform(thing, thing.speed, thing.endX, thing.endY))
def render(self, width, height, st, at):
renderForReturn = renpy.Render(width, height)
for thing in self.particles:
renderForReturn.place(thing)
return renderForReturn