summaryrefslogtreecommitdiffstats
path: root/Geometry-Dash/splash.py
blob: 2e60c2149580169d6c3526c84bf3ffd67cac1e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from setup import *
from math import sin


class Splash:

    def __init__(self):
        self.time = 0
        self.position_x, self.position_y = SCREEN_WIDTH / 2, SCREEN_HEIGHT * 0.35
        self.text_surface = pygame.image.load('textures/title.png')
        self.text_surface = pygame.transform.scale(self.text_surface, (1200, 150))
        self.top_left = (
            self.position_x - self.text_surface.get_width() / 2, self.position_y - self.text_surface.get_height() / 2)

    def update(self, delta_time):
        self.time += delta_time
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return COMMAND_EXIT
            if event.type == pygame.MOUSEBUTTONDOWN:
                return COMMAND_START
            # x, y = event.pos
            # if self.text_surface.get_rect().collidepoint(x, y):
            # print('clicked on image')
            if event.type == pygame.KEYUP:
                if event.key == pygame.K_SPACE:
                    return COMMAND_START

    def draw(self, screen):

        # text_surface = pygame.image.load('textures/title.png')
        # text_surface = pygame.transform.scale(text_surface, (1200, 150))

        screen.blit(self.text_surface, self.top_left)

        # Press Space...
        text_font = FONT_SMALL
        text_color = (100, 100, 100)
        position_x, position_y = SCREEN_WIDTH / 2, SCREEN_HEIGHT * 0.65
        text_surface = text_font.render("Click anywhere to play!", True, text_color)

        text_scale = sin(self.time / 500) / 6 + 5 / 6
        text_scale_width = int(text_surface.get_width() * text_scale)
        text_scale_height = int(text_surface.get_height() * text_scale)
        text_surface = pygame.transform.scale(text_surface, (text_scale_width, text_scale_height))

        top_left = (position_x - text_surface.get_width() / 2, position_y - text_surface.get_height() / 2)
        screen.blit(text_surface, top_left)