From 8aab7d94f175b96e8e5bed33b1f4627f83700112 Mon Sep 17 00:00:00 2001 From: William Hubbard <75867393+Markil3@users.noreply.github.com> Date: Sun, 5 Feb 2023 16:10:11 -0700 Subject: [PATCH] Adds a sky. --- Throot.py | 18 +++++++++++++++++- constants.py | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Throot.py b/Throot.py index 9973fd6..0895943 100644 --- a/Throot.py +++ b/Throot.py @@ -111,6 +111,22 @@ class GameLoop(Room): def get_obstacle_slice(self): return OBSTACLE_SLICES[randrange(0, len(OBSTACLE_SLICES))] + + def draw_sky(self): + sky_x = 0 + sky_y = -thumby.display.height + sky_width = thumby.display.width + sky_height = thumby.display.height + if self.camera.entity_in_camera(sky_x, sky_y, sky_width, sky_height): + sky_x, sky_y = self.camera.relative_to_camera(sky_x, sky_y) + thumby.display.drawFilledRectangle(int(sky_x), int(sky_y), int(sky_width), int(sky_height), 1) + sky_x = 0 + sky_y = 0 + sky_width = thumby.display.width + sky_height = thumby.display.height + if self.camera.entity_in_camera(sky_x, sky_y, sky_width, sky_height): + sky_x, sky_y = self.camera.relative_to_camera(sky_x, sky_y) + thumby.display.drawFilledRectangle(int(sky_x), int(sky_y), int(sky_width), int(sky_height), 0) def draw_water(self): # bookwater @@ -201,7 +217,7 @@ class GameLoop(Room): }) thumby.display.fill(0) - + self.draw_sky() # Draw the entities for entity in self.entities: entity.render(tpf, self.camera) diff --git a/constants.py b/constants.py index 6806087..2c386f5 100644 --- a/constants.py +++ b/constants.py @@ -4,3 +4,4 @@ ROOM_START = 0 ROOM_MAIN = 1 ROOM_END = 2 ROOM_NEXT = -1 +