clock = pygame.time.Clock()
light_grey = (224, 224, 224)
light_blue = (173, 216, 230)
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption("золотя лихорадка")
class Coin(pygame.sprite.Sprite):
def __init__(self, x, y):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load('coin.png')
self.image = pygame.transform.scale(self.image, (120, 120))
self.rect = self.image.get_rect()
def DrawText(text, Textcolor, Rectcolor, x, y, fsize):
font = pygame.font.Font('freesansbold.ttf', fsize)
text = font.render(text, True, Textcolor, Rectcolor)
textRect = text.get_rect()
gameDisplay.blit(text, textRect)
def rectangle(display, color, x, y, w, h):
pygame.draw.rect(display, color, (x, y, w, h))
sprites = pygame.sprite.Group()
sprites.add(Coin(400, 260))
for event in pygame.event.get():
if event.type == pygame.QUIT:
if event.type == pygame.MOUSEBUTTONDOWN:
mouse_position = pygame.mouse.get_pos()
if mouse_position >= (350, 0):
if mouse_position <= (450, 0):
if mouse_position <= (800, 0):
if mouse_position >= (600, 0):
if mouse_position >= (50, 0):
if mouse_position <= (245, 0):
gameDisplay.fill(light_blue)
DrawText("Копай золото!", yellow, light_blue, 400, 100, 40)
DrawText("у тебя " + str(f'{coins:.2f}') + " монет", black, light_blue, 100, 50, 20)
DrawText("улучшить лопату " + str(cost), black, light_blue, 700, 300, 20)
DrawText("Улучшить авто майнер " + str(cost2), black, light_blue, 150, 370, 20)
DrawText("собери миллиард!", black, light_blue, 650, 50, 20)
rectangle(gameDisplay, blue, 50, 400, 200, 300)
rectangle(gameDisplay, blue, 600, 317, 200, 300)
sprites.draw(gameDisplay)