Skip to content

Commit 754d4fa

Browse files
Added loading screen
1 parent a3e83dd commit 754d4fa

File tree

6 files changed

+70
-3
lines changed

6 files changed

+70
-3
lines changed

flightsim.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import math
1717
import random
18+
import time
1819

1920
# Check for updates
2021
import requests
@@ -55,6 +56,7 @@
5556
planes = ["assets/plane.png", "assets/plane2.png", "assets/plane3.png", "assets/plane4.png"]
5657
plane_index = 0
5758

59+
# ==========================================================================
5860

5961
# Function to rotate an image
6062
def rotate_image(image, angle):
@@ -83,16 +85,36 @@ def __init__(self, x, y, length):
8385
def draw(self, surface):
8486
pygame.draw.line(surface, white, (self.x, self.y), (self.x, self.y + self.length), 1)
8587

88+
# ==========================================================================
89+
8690

8791
# Initialize Pygame
8892
pygame.init()
8993

9094
# Set up the display window
91-
screen = pygame.display.set_mode((1000, 800)) # (width, height)
95+
screen = pygame.display.set_mode((1000, 750), pygame.RESIZABLE) # (width, height)
9296
pygame.display.set_caption(f"HyperAir {version}")
9397

9498
# Set up fonts
9599
font = pygame.font.Font("fonts/courierprime.ttf", 15) # (font, size)
100+
logofont = pygame.font.Font("fonts/RobotoMono-Regular.ttf", 70)
101+
102+
# ==========================================================================
103+
104+
# Loading Screen
105+
logo = pygame.image.load("assets/logo.png")
106+
loadingtitle = logofont.render("Hyper Studios", True, white)
107+
108+
screen.fill((0, 0, 0))
109+
110+
screen.blit(logo, (90, (screen.get_height() - logo.get_height()) // 2))
111+
screen.blit(loadingtitle, (360, (screen.get_height() - loadingtitle.get_height()) // 2))
112+
113+
pygame.display.flip()
114+
115+
time.sleep(5)
116+
117+
# ==========================================================================
96118

97119
# Load the image of the plane
98120
plane_image = pygame.image.load(planes[plane_index])
@@ -117,6 +139,7 @@ def draw(self, surface):
117139
bird_image = pygame.image.load("assets/bird.png")
118140

119141
# ==========================================================================
142+
120143
# Load the icon image
121144
icon_image = pygame.image.load("assets/jetengine.png")
122145

@@ -125,7 +148,6 @@ def draw(self, surface):
125148

126149
# ==========================================================================
127150

128-
129151
# Set up text
130152
title = font.render(f"[HyperAir {version}]", True, gray)
131153
speedtxt = font.render(f"[Speed: {speed:.2f}]", True, gray)
@@ -334,4 +356,4 @@ def draw(self, surface):
334356
pygame.display.flip()
335357

336358
# Quit Pygame
337-
pygame.quit()
359+
# pygame.quit()

fonts/CairoPlay-Regular.ttf

159 KB
Binary file not shown.

fonts/Honk-Regular.ttf

392 KB
Binary file not shown.

fonts/Nabla-Regular.ttf

1.38 MB
Binary file not shown.

fonts/RobotoMono-Regular.ttf

85.2 KB
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import pygame
2+
import sys
3+
4+
# Initialize Pygame
5+
pygame.init()
6+
7+
# Set up the display window
8+
screen_width = 800
9+
screen_height = 600
10+
screen = pygame.display.set_mode((screen_width, screen_height))
11+
pygame.display.set_caption("Vertical Alignment Example")
12+
13+
# Define colors
14+
WHITE = (255, 255, 255)
15+
16+
# Example item to align (text)
17+
font = pygame.font.Font(None, 36) # You can choose your own font
18+
text_surface = font.render("Aligned Text", True, WHITE)
19+
text_rect = text_surface.get_rect()
20+
21+
# Calculate vertical position to align to the middle of the screen
22+
vertical_position = (screen_height - text_rect.height) // 2
23+
24+
# Set the vertical position of the item
25+
text_rect.y = vertical_position
26+
27+
# Game loop
28+
running = True
29+
while running:
30+
for event in pygame.event.get():
31+
if event.type == pygame.QUIT:
32+
running = False
33+
34+
# Fill the screen with a background color (optional)
35+
screen.fill((0, 0, 0)) # Black background
36+
37+
# Draw the aligned item (text in this case)
38+
screen.blit(text_surface, text_rect)
39+
40+
# Update the display
41+
pygame.display.flip()
42+
43+
# Quit Pygame
44+
pygame.quit()
45+
sys.exit()

0 commit comments

Comments
 (0)