Skip to content

Commit c97a881

Browse files
Minor changes, made plane appear in center even when resized
1 parent d195e5d commit c97a881

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

flightsim.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Check for updates
2121
import requests
2222

23-
version = "v1.1.4"
23+
version = "v1.1.5"
2424
response = requests.get("https://github.com/HyperSourceGithub/hyperair/releases/latest")
2525
latest_version = response.url.split("/").pop()
2626
print(f"Using version {version}")
@@ -191,6 +191,19 @@ def draw(self, surface):
191191
plane_index += 1
192192
plane_image = pygame.image.load(planes[plane_index])
193193

194+
# Resize Checker
195+
elif event.type == pygame.VIDEORESIZE:
196+
# Get the rectangle of the plane image
197+
plane_rect = plane_image.get_rect()
198+
199+
# Calculate the position of the plane to make it appear in the center of the screen
200+
plane_x = (screen.get_width() - plane_rect.width) / 2
201+
plane_y = (screen.get_height() - plane_rect.height) / 2
202+
203+
# Set the position of the plane
204+
plane_rect.topleft = (plane_x, plane_y)
205+
# ==========================================================================
206+
194207
# Get the state of all keyboard keys
195208
keys = pygame.key.get_pressed()
196209

0 commit comments

Comments
 (0)