Skip to content

Commit 53e8403

Browse files
committed
tilemap game cp7 updates and text location fix
1 parent bd7536a commit 53e8403

File tree

1 file changed

+11
-6
lines changed
  • Tilemap_Game_With_CircuitPython

1 file changed

+11
-6
lines changed

Tilemap_Game_With_CircuitPython/code.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def is_tile_moveable(tile_coords):
130130
)
131131

132132
# Create a Group to hold the sprite and castle
133-
group = displayio.Group(max_size=33)
133+
group = displayio.Group()
134134

135135
# Add castle to the group
136136
group.append(castle)
@@ -430,7 +430,8 @@ def draw_camera_view():
430430
def show_splash(new_text, color, vertical_offset=18):
431431
text_area.text = ""
432432
text_area.text = new_text
433-
text_area.y = round(text_area.text.count("\n") * vertical_offset / 2)
433+
text_area.anchor_point = (0, 0)
434+
text_area.anchored_position = (0, vertical_offset)
434435
text_area.color = color
435436
group.append(splash)
436437

@@ -440,16 +441,20 @@ def show_splash(new_text, color, vertical_offset=18):
440441
"tilegame_assets/game_message_background.bmp", "rb"
441442
) as game_message_background:
442443
# Make the splash context
443-
splash = displayio.Group(max_size=4)
444+
splash = displayio.Group()
444445

446+
# CircuitPython 6 & 7 compatible
445447
odb = displayio.OnDiskBitmap(game_message_background)
446-
447448
bg_grid = displayio.TileGrid(odb, pixel_shader=getattr(odb, 'pixel_shader', displayio.ColorConverter()))
448449

450+
# # CircuitPython 7+ compatible
451+
# odb = displayio.OnDiskBitmap("tilegame_assets/game_message_background.bmp")
452+
# bg_grid = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
453+
449454
splash.append(bg_grid)
450455

451456
# Text for the message
452-
text_group = displayio.Group(max_size=8, scale=1, x=14, y=18)
457+
text_group = displayio.Group(x=14, y=8)
453458
text_area = label.Label(terminalio.FONT, text=" " * 180, color=0xD39AE5)
454459
text_group.append(text_area)
455460
splash.append(text_group)
@@ -625,7 +630,7 @@ def show_splash(new_text, color, vertical_offset=18):
625630
GAME_STATE["STATE"] = STATE_WAITING
626631
random_fact = random.choice(FACTS)
627632
minerva_txt = wrap_nicely("Minerva: {}".format(random_fact), 23)
628-
show_splash(minerva_txt, 0xD39AE5, 10)
633+
show_splash(minerva_txt, 0xD39AE5, 0)
629634

630635
# store the last update time
631636
last_update_time = now

0 commit comments

Comments
 (0)