Ejemplo n.º 1
0
 def init_offset(self): # centers offset
     board_rect = board.get_rect()
     disp_rect = data.get_display_rect()
     board_rect.centerx = disp_rect.centerx
     top, left = board_rect.topleft
     self.old_camera_offset = [top, left]
     data.camera_offset = [top, left]
Ejemplo n.º 2
0
 def init_offset(self):  # centers offset
     board_rect = board.get_rect()
     disp_rect = data.get_display_rect()
     board_rect.centerx = disp_rect.centerx
     top, left = board_rect.topleft
     self.old_camera_offset = [top, left]
     data.camera_offset = [top, left]
Ejemplo n.º 3
0
 def center_on_square(self, square):
     square_rect = square.get_rect()
     disp_rect = data.get_display_rect()
     square_rect.center = disp_rect.center
     square_rect.left -= square.xy[0] * data.square_size
     square_rect.top -= square.xy[1] * data.square_size
     self.old_camera_offset = list(data.camera_offset)        
     data.camera_offset = list(square_rect.topleft)
Ejemplo n.º 4
0
 def center_on_square(self, square):
     square_rect = square.get_rect()
     disp_rect = data.get_display_rect()
     square_rect.center = disp_rect.center
     square_rect.left -= square.xy[0] * data.square_size
     square_rect.top -= square.xy[1] * data.square_size
     self.old_camera_offset = list(data.camera_offset)
     data.camera_offset = list(square_rect.topleft)
Ejemplo n.º 5
0
    def __init__(self, name, rect, color, visible, font):
        Window.__init__(self, name, rect, color, visible, font)
    
    def update_contents(self): # MENU1 CONTENTS
        self.contents = ["F1 - exit this menu",
                            "1 - 1024x768",
                            "2 - 1280x800"
                            ]
                           
def toggle_boolvar(var):
    if var: var = False
    elif not var: var = True
    return var

def get_centered_window_rect(border = (50, 50), (x_offset,y_offset) = (0,0)):
        d_rect = data.get_display_rect()
        height = d_rect.height - (border[1] * 2)
        width = d_rect.width - (border[0] * 2)
        w_rect = pygame.rect.Rect(0, 0, width, height)
        w_rect.center = d_rect.center
        w_rect.top += y_offset
        w_rect.left += x_offset
        w_rect = w_rect.clip(d_rect)
        return w_rect 
    
def get_percent_of_display(axis, percent):
    if axis == "x":
        x = (data.display_size[0] * percent) / 100
        return x
    if axis == "y":
        y = (data.display_size[1] * percent) / 100
Ejemplo n.º 6
0
class Menu(Window):
    def __init__(self, name, rect, color, visible, font):
        Window.__init__(self, name, rect, color, visible, font)

    def update_contents(self):  # MENU1 CONTENTS
        self.contents = ["F1 - exit this menu", "1 - 1024x768", "2 - 1280x800"]


def toggle_boolvar(var):
    if var: var = False
    elif not var: var = True
    return var


def get_centered_window_rect(border=(50, 50), (x_offset, y_offset)=(0, 0)):
    d_rect = data.get_display_rect()
    height = d_rect.height - (border[1] * 2)
    width = d_rect.width - (border[0] * 2)
    w_rect = pygame.rect.Rect(0, 0, width, height)
    w_rect.center = d_rect.center
    w_rect.top += y_offset
    w_rect.left += x_offset
    w_rect = w_rect.clip(d_rect)
    return w_rect


def get_percent_of_display(axis, percent):
    if axis == "x":
        x = (data.display_size[0] * percent) / 100
        return x
    if axis == "y":