Skip to content

fix backgrounds and remove CP6 compatibility #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions adafruit_pyoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,22 +401,12 @@ def set_background(self, filename, *, with_fade=True):
self._background_group.pop()

if filename:
if self._background_file:
self._background_file.close()
with open(
self._gamedirectory + "/" + filename, "rb"
) as self._background_file:
# TODO: Once CP6 is no longer supported, pass combined filename into OnDiskBitmap
background = displayio.OnDiskBitmap(self._background_file)
self._background_sprite = displayio.TileGrid(
background,
pixel_shader=getattr(
background, "pixel_shader", displayio.ColorConverter()
),
# TODO: Once CP6 is no longer supported, replace the above line with below
# pixel_shader=background.pixel_shader,
)
self._background_group.append(self._background_sprite)
background = displayio.OnDiskBitmap(self._gamedirectory + "/" + filename)
self._background_sprite = displayio.TileGrid(
background,
pixel_shader=background.pixel_shader,
)
self._background_group.append(self._background_sprite)
if with_fade:
self._display.refresh(target_frames_per_second=60)
self.backlight_fade(1.0)
Expand Down