<reponame>wnzlff/pygame-rpg<gh_stars>1-10
# ---------------------------------------------------
# Import Packages
# ---------------------------------------------------
import pygame
import os
import pathlib

# ---------------------------------------------------
# Import Config
# ---------------------------------------------------
from config.settings.config_colors import *
from config.settings.config_game import *
from config.settings.config_layer import *
from config.settings.config_player import *
from config.settings.config_resolution import *

# ---------------------------------------------------
# GAME_PATH
# ---------------------------------------------------
GAME_PATH = pathlib.Path().resolve()
CONFIG_PATH = os.path.join(GAME_PATH, 'config')

# ---------------------------------------------------
# Font Paths
# ---------------------------------------------------
FONT_PATH = os.path.join(CONFIG_PATH, 'fonts')
ARIAL_FONT = os.path.join(FONT_PATH, 'arial.ttf')

# ---------------------------------------------------
# Button Class
# ---------------------------------------------------
class Button():
    def __init__(self,x, y, width, height, fg, bg, content, font_size) -> None:
        self.font = pygame.font.Font(ARIAL_FONT, FONT_SIZE)
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.fg = fg
        self.bg = bg
        self.content = content
        self.font_size = font_size
        self.image = pygame.Surface((self.width, self.height))
        self.image.fill(self.bg)
        self.rect = self.image.get_rect()
        self.rect.x = self.x
        self.rect.y = self.y
        self.text = self.font.render(self.content, True, self.fg)
        self.text_rect = self.text.get_rect(center=(self.width/2, self.height/2))
        self.image.blit(self.text, self.text_rect)

    def is_pressed(self, pos, pressed):
        if self.rect.collidepoint(pos):
            if pressed[0]:
                return True
            return False
        return False
# ---------------------------------------------------
# Import Packages
# ---------------------------------------------------
import pygame
import os
import pathlib

# ---------------------------------------------------
# Import Config
# ---------------------------------------------------
from config.settings.config_colors import *
from config.settings.config_game import *
from config.settings.config_layer import *
from config.settings.config_player import *
from config.settings.config_resolution import *

# ---------------------------------------------------
# GAME_PATH
# ---------------------------------------------------
GAME_PATH = pathlib.Path().resolve()
CONFIG_PATH = os.path.join(GAME_PATH, 'config')

# ---------------------------------------------------
# Font Paths
# ---------------------------------------------------
FONT_PATH = os.path.join(CONFIG_PATH, 'fonts')
ARIAL_FONT = os.path.join(FONT_PATH, 'arial.ttf')

# ---------------------------------------------------
# Button Class
# ---------------------------------------------------
class Button():
    def __init__(self,x, y, width, height, fg, bg, content, font_size) -> None:
        self.font = pygame.font.Font(ARIAL_FONT, FONT_SIZE)
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.fg = fg
        self.bg = bg
        self.content = content
        self.font_size = font_size
        self.image = pygame.Surface((self.width, self.height))
        self.image.fill(self.bg)
        self.rect = self.image.get_rect()
        self.rect.x = self.x
        self.rect.y = self.y
        self.text = self.font.render(self.content, True, self.fg)
        self.text_rect = self.text.get_rect(center=(self.width/2, self.height/2))
        self.image.blit(self.text, self.text_rect)

    def is_pressed(self, pos, pressed):
        if self.rect.collidepoint(pos):
            if pressed[0]:
                return True
            return False
        return False
# --------------------------------------------------- # Import Packages # --------------------------------------------------- # --------------------------------------------------- # Import Config # --------------------------------------------------- # --------------------------------------------------- # GAME_PATH # --------------------------------------------------- # --------------------------------------------------- # Font Paths # --------------------------------------------------- # --------------------------------------------------- # Button Class # ---------------------------------------------------