Here's the deal -- I want my engine to draw four layers of graphics on every field in the dice game environment, so far I successfully managed to make the engine draw two of them, but that was absolutely easy, since those take their render from a single variable.
But, what if I want to take data from a list, and render multiple graphics in a for loop?
I store graphics paths in a list, like this:
Code: Select all
def bgMapData():
Vbg[0] = "images/bg/dgs1_1.jpg"
Vbg[1] = "images/bg/dgs1_1b.png"
Vbg[2] = "images/bg/dgs1_2.jpg"
Vbg[3] = "images/bg/dgs1_2b.png"
Vbg[4] = "images/bg/dgs1_3.jpg"
Vbg[5] = "images/bg/dgs1_3b.png"
Vbg[6] = "images/bg/dgs1_4.jpg"
Vbg[7] = "images/bg/dgs1_5.jpg"
Vbg[8] = "images/bg/dgs1_6.jpg"
Vbg[9] = "images/bg/dgs1_7.jpg"
Vbg[10] = "images/bg/dgs1_8.jpg"
Vbg[11] = "images/bg/dgs1_9.jpg"
Vlib[0] = "images/bg/component0.png"
Vlib[1] = "images/bg/component1.png"
Code: Select all
def bgFieldData():
diceGameStage[1].fldEnv[0].layerA = 0
diceGameStage[1].fldEnv[0].layerB = 1
diceGameStage[1].fldEnv[0].layerC[1].decorIndex = 0
diceGameStage[1].fldEnv[0].layerC[1].pos = 20, 20
diceGameStage[1].fldEnv[0].layerC[2].decorIndex = 1
diceGameStage[1].fldEnv[0].layerC[2].pos = 700, 20
Code: Select all
def __init__(self):
self.decorIndex = None
self.pos = 0, 0
self.size = 1.0
layerA - Background
layerC - Decorations above background
layerB - Overlay
layerD - Decorations above overlay
grass is layerA, trees are layerB, layerC would render its graphics below the trees, while layerD would render above the trees
However clunky this may seem(and my friend told me that Python lists are slower than other ways), I successfuly adopted this method and it works with non-list rendering, here's how the rendering works:
Code: Select all
class drawLocation(renpy.Displayable):
def __init__(self, loc, fld, **kwargs):
super(drawLocation, self).__init__(**kwargs)
self.loc = loc
self.fld = fld
self.loc_bg = None
self.loc_over = None
def render(self, width, height, st, at):
render = renpy.Render(width, height)
if diceGameStage[self.loc].fldEnv[self.fld].layerA != None:
bgpath = Vbg[diceGameStage[self.loc].fldEnv[self.fld].layerA]
else:
bgpath = None
if diceGameStage[self.loc].fldEnv[self.fld].layerB != None:
ovpath = Vbg[diceGameStage[self.loc].fldEnv[self.fld].layerB]
else:
ovpath = None
if bgpath != None:
self.loc_bg = renpy.displayable(Image(bgpath))
if ovpath != None:
self.loc_over = renpy.displayable(Image(ovpath))
if bgpath != None:
bgimg = renpy.render(self.loc_bg, width, height, st, at)
if ovpath != None:
overlay = renpy.render(self.loc_over, width, height, st, at)
if bgpath != None:
render.blit(bgimg, (0, 0))
if ovpath != None:
render.blit(overlay, (0, 0))
return render
def visit(self):
return [ self.loc_bg, self.loc_over ]
Thus, I decided to ask about it here. Whether I'll be suggested a different way of rendering a set of graphics as decorations than using lists, I'd be happy to learn. Other than that, any helpful points as to why this error happens would be greatly appreciated, as I don't have an idea what it could mean, and I got it almost everytime when I was beginning to learn how to render displayables.
Thank you for your time.