def click(self,pos): list = [o for o in self.objs.values() if isinstance(o,gameobjs.actionObj)] if list: list = [o for o in list if o.rect.collidepoint(pos)] if list: for o in list: o.onClick() return 1 x,y = iso_math.getIsoPoint(pos, self.curent_level.total_size, self.curent_level.original_size, self.curent_level.floor_size) a,b = iso_math.isoProjection( (x,y,0), self.curent_level.floor_size, self.curent_level.original_size, self.curent_level.total_size ) if x>=0 and x<self.curent_level.x and y>=0 and y<self.curent_level.y: self.event_handler((x,y,0)) return 1 return 0
def render(self,rect): x0, t = iso_math.getIsoPoint(rect.topleft , self.total_size, self.original_size, self.floor_size) t, y0 = iso_math.getIsoPoint(rect.topright , self.total_size, self.original_size, self.floor_size) t, y1 =iso_math.getIsoPoint(rect.bottomleft , self.total_size, self.original_size, self.floor_size) x1, t = iso_math.getIsoPoint(rect.bottomright , self.total_size, self.original_size, self.floor_size) x0-=1 y0-=1 x1+=1 y1+=1 if x0 < 0: x0 = 0 if y0 < 0: y0 = 0 if x1>self.x: x1 = self.x if y1>self.y: y1 = self.y tam_x, tam_y = rect.size self.surface = pygame.surface.Surface( (tam_x, tam_y) ) #color of a blue sky self.colorKey = (124, 172, 253) self.surface.fill(self.colorKey) for x in range(x0,x1): for y in range(y0,y1): i = self.__floor_array[y][x] posx, posy = iso_math.isoProjection( (x,y,0) , self.floor_size, self.original_size, self.total_size ) posx -= rect.left + self.floor_factor_size posy -= rect.top self.surface.blit(self.images[i],(posx,posy))
def isometricProjection(self,pos3d): return iso_math.isoProjection(pos3d, self.curent_level.floor_size, self.curent_level.original_size, self.curent_level.total_size )