Adds a sky.

This commit is contained in:
William Hubbard
2023-02-05 16:10:11 -07:00
parent 3afe5322b3
commit 8aab7d94f1
2 changed files with 18 additions and 1 deletions

View File

@@ -112,6 +112,22 @@ class GameLoop(Room):
def get_obstacle_slice(self): def get_obstacle_slice(self):
return OBSTACLE_SLICES[randrange(0, len(OBSTACLE_SLICES))] 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): def draw_water(self):
# bookwater # bookwater
@@ -201,7 +217,7 @@ class GameLoop(Room):
}) })
thumby.display.fill(0) thumby.display.fill(0)
self.draw_sky()
# Draw the entities # Draw the entities
for entity in self.entities: for entity in self.entities:
entity.render(tpf, self.camera) entity.render(tpf, self.camera)

View File

@@ -4,3 +4,4 @@ ROOM_START = 0
ROOM_MAIN = 1 ROOM_MAIN = 1
ROOM_END = 2 ROOM_END = 2
ROOM_NEXT = -1 ROOM_NEXT = -1