-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtruck_interior_and_civic.py
99 lines (65 loc) · 6.82 KB
/
truck_interior_and_civic.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from sys import exit
import pygame
from ui_elements import *
from parameters import *
import first_time_sale
# Define cursors
arrow_cursor = pygame.SYSTEM_CURSOR_ARROW
hand_cursor = pygame.SYSTEM_CURSOR_HAND
# ═══════════════════════════════════════════════════════════════════════════ #
# ═══ LEVEL IMAGES, DIALOGUE TEXT, AND GAME LOOP ════════════════════════════ #
def truck_interior(screen):
# ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ #
# ═══ SHIMMER FUNCTION ══════════════════════════════════════════════════════════════════════════════════════════════ #
shimmer_progress_continue = 0
hovered_continue = False
# ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ #
# ═══ DIALOGUE TEXT ═════════════════════════════════════════════════════════════════════════════════════════════════ #
font = pygame.font.Font("assets/arial.ttf", 20)
truck_interior_dialogue_1 = "Even though you've never met this man, despite a nagging feeling that you have seen him before, you decide it's perfectly safe and drive your car up the loading ramps and into the truck's interior. It's only then that you noticed that the mysterious man is now standing in front of your car. How'd he get inside so fast without you noticing?"
truck_interior_dialogue_2 = "\"Let's do some business then, eh!\", says the seller. \"I reserved some items, just for you! My other customers don't know about these, heh heh heh.\" You can almost sense a grin hidden behind his mask as you look over the selection of parts he has to offer."
# ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ #
# ═══ IMAGES ════════════════════════════════════════════════════════════════════════════════════════════════════════ #
""" Blue Civic inside truck container """
truck_interior = pygame.image.load("assets/truck_interior_and_civic.png")
truck_interior_rect = truck_interior.get_rect(center=(screen.get_width() // 2, screen.get_height() // 1.45))
""" 'Continue' arrow button """
continue_arrow = pygame.image.load("assets/continue_arrow.png")
continue_arrow_rect = continue_arrow.get_rect(bottomright=(screen.get_width() // 1.005, screen.get_height() // 1.01))
# ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ #
# ═══ GAME LOOP ═════════════════════════════════════════════════════════════════════════════════════════════════════ #
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
elif event.type == pygame.MOUSEBUTTONUP:
if event.button == 1:
if is_hovered(continue_arrow_rect):
first_time_sale.parts_sale(screen)
# ┌─── ▼ Display all necessary images and text ▼ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
screen.fill((0, 0, 0))
text_wrap(screen, truck_interior_dialogue_1, (screen.get_width() // 10, screen.get_height() // 20), font, WHITE, screen.get_width() - screen.get_width() // 5)
text_wrap(screen, truck_interior_dialogue_2, (screen.get_width() // 10, screen.get_height() // 3.5), font, WHITE, screen.get_width() - screen.get_width() // 5)
screen.blit(truck_interior, truck_interior_rect.topleft)
screen.blit(continue_arrow, continue_arrow_rect.topleft)
# └─── ▲ Display all necessary images and text ▲ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
# ┌─── ▼ 'Continue' arrow shimmer effect ▼ ──────────────────────────────────────┐
cursor_changed = False
if is_hovered(continue_arrow_rect):
if not hovered_continue:
shimmer_progress_continue = 0
hovered_continue = True
if shimmer_progress_continue < 1:
shimmer_progress_continue += 0.015
draw_shimmer(screen, continue_arrow_rect, shimmer_progress_continue)
pygame.mouse.set_cursor(hand_cursor)
cursor_changed = True
else:
hovered_continue = False
if not cursor_changed:
pygame.mouse.set_cursor(arrow_cursor)
# └─── ▲ 'Continue' arrow shimmer effect ▲ ──────────────────────────────────────┘
pygame.display.flip()
pygame.quit()