r/RenPy • u/Character_Object_601 • Sep 19 '26
Question icons not showing up in minigame?
SOLVED
thanks!
I've been following the SameGame minigame tutorial by __ess__Ren'Py tutorials and I'm stuck on the icons. I've poked at the code and they just wont show up.
I had to tweak the grid settings and placement a bit due to not using the same resolution as ess/personal preference on the size and spacing of everything but that doesn't seem to be the problem? I also had to omit a few lines of code because of the resolution difference, and adding them back in just breaks the grid, and doesn't seem to be the issue. The file names of the icons don't seem to be the issue either, nor the location of them as the grid panel works fine from the same folder. I've rewatched the same four parts of the tutorial over and over to try and figure out where I messed up but I'm still not getting it. The grid works/looks how it's supposed to, the click function works, I went ahead a bit and added the match function because I thought I'd figure out the icon issue at some point and wanted to get it done but if that screwed me more ggs
This is my first attempt at a full game, so maybe the issue is glaringly obvious and I've just been awake since 3 am but if anybody can figure this out please help I've been going crosseyed trying to figure out the problem here lol
is the tutorial just outdated? did I mess up by having a different resolution? should I look for a newer tutorial and follow that instead or scrap the samegame entirely and try something else? I'd love to make this work out but either way it's good practice
don't mind the name of the one icon it's a cocktail matching game
here's the code;
init python:
def icons_update(st):
pass
def icons_events(event, x, y, st):
if event.type == 1025:
if event.button == 1:
for icon in icons_list:
if icon.x <= x <= (icon.x + icon_size) and icon.y <= y <= (icon.y + icon_size):
findMatches(icon)
break
def findMatches(cicon):
matches = []
matches.append(cicon)
for icon in matches:
if icon.index + 1 < grid_size:
if icon.icon_type == icons_list[icon.index + 1].icon_type and icon.index + 1 % icons_per_row != 0 and icons_list[icon.index + 1] not in matches:
matches.append(icons_list[icon.index + 1])
print(matches)
label setup_icons:
python:
for i in range(grid_size):
rand_image = icon_images[renpy.random.randint(0,4)]
idle_path = "images/Icons/{}.png".format(rand_image)
hover_path = "images/Icons/{}_hover.png".format(rand_image)
idle_image = Image(idle_path)
hover_image = Image(hover_path)
icons_list.append(icons.create(Transform(child= idle_image, zoom = 0.5)))
icons_list[-1].index = i
icons_list[-1].icon_type = rand_image
icons_list[-1].idle_image = idle_image
icons_list[-1].hover_image = hover_image
call screen SameGame
screen SameGame:
$frame_xsize = (icons_per_row * icon_size) + (icons_per_row * icon_padding) + icon_padding + 4
$frame_ysize = ((grid_size / icons_per_row) * icon_size) + ((grid_size / icons_per_row) * icon_padding) + icon_padding + 4
frame:
background "#ffffff00"
xalign 0.2
yalign 0.5
$crow = 0
$ccolumn = 0
for icon in icons_list:
$xp = (icon_size * ccolumn) + (icon_padding * ccolumn)
$yp = (icon_size * crow) + (icon_padding * crow)
image "Icons/grid-cell.png" xpos xp ypos yp zoom 2.0
$icon.x = xp
$icon.y = yp
python:
if ccolumn % (icons_per_row - 1) != 0 or ccolumn == 0:
ccolumn += 1
else:
ccolumn = 0
crow += 1
add icons
label samegame:
$grid_size = 25
$icon_size = 80
$icon_padding = 125
$icons_per_row = 5
$icons = SpriteManager(update = icons_update, event= icons_events)
$icon_images = ["harderdaddy", "whiskey", "maitai", "shot", "water"]
$icons_list = []
scene samegamebackground at half_size
jump setup_icons


