-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeginning_fixed.py
99 lines (65 loc) · 6.31 KB
/
beginning_fixed.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 beginning_day_cruising
# Define cursors
arrow_cursor = pygame.SYSTEM_CURSOR_ARROW
hand_cursor = pygame.SYSTEM_CURSOR_HAND
# ═══════════════════════════════════════════════════════════════════════════ #
# ═══ LEVEL IMAGES, DIALOGUE TEXT, AND GAME LOOP ════════════════════════════ #
def fixed_civic(screen):
# ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ #
# ═══ SHIMMER FUNCTION ══════════════════════════════════════════════════════════════════════════════════════════════ #
shimmer_progress_continue = 0 # Initialize shimmer progress
hovered_continue = False # Check if cursor is over 'continue' arrow (used to reset hover effect)
# ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ #
# ═══ DIALOGUE TEXT ═════════════════════════════════════════════════════════════════════════════════════════════════ #
font = pygame.font.Font("assets/arial.ttf", 20)
beginning_fixed_dialogue_1 = "You installed a new Cold Air Intake (CAI) kit and stainless steel cat-back exhaust, taking the car's stock engine with its 106 horsepower and 103 lb-ft of torque up to a more acceptable 166 HP and 159 lb-ft of torque. Along with that, you also gave it a new splash of paint, a lowered suspension, and some custom wheels. Now, the car finally feels like it's yours and, as a bonus, your dad gave you an additional gift of $1000 to help you with your journey."
beginning_fixed_dialogue_2 = "Now, it is time to hit the open road and head west!"
# ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ #
# ═══ IMAGES ════════════════════════════════════════════════════════════════════════════════════════════════════════ #
""" Blue Civic in garage """
garage_with_civic = pygame.image.load("assets/blue_civic_in_garage.png")
garage_with_civic_rect = garage_with_civic.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):
beginning_day_cruising.start_cruising(screen)
# ─── ▼ Display all necessary images and text ▼ ───────────────────────────── #
screen.fill((0, 0, 0))
screen.blit(garage_with_civic, garage_with_civic_rect.topleft)
screen.blit(continue_arrow, continue_arrow_rect.topleft)
text_wrap(screen, beginning_fixed_dialogue_1, (screen.get_width() // 10, screen.get_height() // 9), font, WHITE, screen.get_width() - screen.get_width() // 5)
text_wrap(screen, beginning_fixed_dialogue_2, (screen.get_width() // 10, screen.get_height() // 3), font, WHITE, screen.get_width() - screen.get_width() // 5)
# ─── ▲ 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.02
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()