我在pygame中编写了这个函数作为滚动面板的一部分。该函数是名为slot的类的一部分,slot是panel类的一部分,slot是面板上包含字符串或数据的条。此方法将插槽绘制到屏幕,如果屏幕位于插槽之间,则只绘制插槽的一部分。if/elif/else语法把我绊倒了:def mydraw(self,my_pygame,scrn,panel_x,panel_y,scroll_at,window_size,virtual_size):
if((self.yscrollat)):
onscreensy = (self.y-scrollat)+panel_y
onscreeney = onscreensy + self.dim_y
"""the top case"""
if(onscreensy
onscrnwidth = (onscreensy+self.dim_y)-panel_y
onbitmapwidth = self.dim_y-onscrnwidth
holder = self.bitmap.subsurface(0,onbitmapwidth-1,self.dim_x,onbitmapwidth-1)
scrn.blit(holder,(panel_x,panel_y))
"""end top case"""
"""the normal case"""
elif(onscreeney
scrn.blit(self.bitmap,(panel_x,onscreensy))
"""end normal case"""
"""the bottom case"""
else:
onscrnwidth = (panel_y+window_size)-self.y
onbitmapwidth = self.dim_y-onscrnwidth
holder = self.bitmap.subsurface(0,0,self.dim_x,onbitmapwidth-1)
scrn.blit(holder,(panel_x,onscreensy))
"""end bottom case"""
if(self.has_next==True):
self.next.mydraw(my_pygame,scrn,panel_x,panel_y,scroll_at,window_size,virtual_size)
错误:
^{pr2}$