So my game is nearing completion (finally). One of my last problems is making the level selection screen fit the proper amount of level "buttons" per row on the screen depending on the screen's resolution. I didn't notice this (well at least the extent of the problem) until I got my new 2013 Nexus 7, whose screen size is much larger than the previous generation's (720p vs 1080p).
Basically I'm having trouble dynamically fitting objects on the screen based on the screen's resolution.
The current code I'm using as of now to fit items on the screen:
elif gameState == "levelSelect":
if doOnce:
buttons = pygame.sprite.Group()
buttList = []
buttText = []
buttRect = []
numbers = 0
for lv in android.assets.list():
if lv.endswith(".level"):
if (numbers > -1) and (numbers < 9):
h = 64
buttList.append(LevelButton((numbers+1)*128-64,h,str(numbers + 1)))
elif (numbers > 8) and (numbers < 17):
h = 192
buttList.append(LevelButton((numbers-8)*128-64,h,str(numbers + 1)))
buttons.add(buttList[numbers])
buttText.append(myFont.render(buttList[numbers].text,False,color))
buttRect.append(buttText[numbers].get_rect())
buttRect[numbers].center = buttList[numbers].rect.center
numbers += 1
screen.fill((0,0,0))
buttons.draw(screen)
numbers = 0
for button in buttText:
screen.blit(button, buttRect[numbers])
numbers += 1
pygame.display.flip()
doOnce = False
I'd like to point out I have the screen's native resolution stored in mynative[0][0] and mynative[0][1]
Its like I just hit a writer's sort of block while doing this.