I wrote this function as part of a scrolling panel I was trying to make in pygame. The function is part of a class called slot, which is a part of the panel class, slots being the bars on the panel containing strings or data. this method draws the slots to the screen, drawing only a part of a slot if the screen in in between slots. The if/elif/else syntax is tripping me up:
def mydraw(self,my_pygame,scrn,panel_x,panel_y,scroll_at,window_size,virtual_size):
if((self.y<(scrollat+window_size))or((self.e_y)>scrollat)):
onscreensy = (self.y-scrollat)+panel_y
onscreeney = onscreensy + self.dim_y
"""the top case"""
if(onscreensy<panel_y):
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<(panel_y+window_size)): #### right here ####
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)
error:
me$ python testscrolling3.py
File "testscrolling3.py", line 164
elif(onscreeney<(panel_y+window_size)):
^
SyntaxError: invalid syntax
elifbecause the strings are code at the same indent-level as theif.