-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.py
More file actions
57 lines (46 loc) · 1.91 KB
/
Copy pathboot.py
File metadata and controls
57 lines (46 loc) · 1.91 KB
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
# boot.py
import pygame
import constants
class BootScene:
def __init__(self):
self.frame_count = 0
self.is_finished = False
self.typed_command = ""
self.command = 'RUN "DUNGEON"'
self.font = pygame.font.SysFont("monospace", 12, bold=True)
def update(self, dt):
self.frame_count += dt / 16
if 60 <= self.frame_count < 150:
idx = int(((self.frame_count - 60) / 90) * len(self.command))
self.typed_command = self.command[:idx]
if self.frame_count > 250:
self.is_finished = True
def draw(self, surface):
surface.fill(constants.COLOR_CPC_BLUE)
margin_left = 20
y = 20
header = [
"Amstrad 128K Microcomputer (v3)",
"(c)1985 Amstrad Consumer Electronics plc",
" and Locomotive Software Ltd.",
"BASIC 1.1",
"",
"Ready"
]
for line in header:
if line != "":
img = self.font.render(line, False, constants.COLOR_YELLOW)
surface.blit(img, (margin_left, y))
y += 15
# --- AFFICHAGE DE LA COMMANDE ET DU CURSEUR CARRÉ ---
# On affiche le texte tapé
cmd_surf = self.font.render(self.typed_command, False, constants.COLOR_YELLOW)
surface.blit(cmd_surf, (margin_left, y))
# Logique du curseur clignotant
# On calcule la position X juste après le texte tapé
cursor_x = margin_left + cmd_surf.get_width() + 2
# Clignotement : visible 50% du temps (toutes les 20 frames environ)
if int(self.frame_count / 15) % 2 == 0:
# On dessine un carré jaune de 8x12 pixels (taille typique d'un caractère)
cursor_rect = pygame.Rect(cursor_x, y, 8, 12)
pygame.draw.rect(surface, constants.COLOR_YELLOW, cursor_rect)